Bug 587719: look for special application/x-moz-keyword-url URL type for keyword searches, to allow keyword-search-specific URLs, r=jrmuizel/Pike, a=beltzner
authorGavin Sharp <gavin@gavinsharp.com>
Mon, 16 Aug 2010 13:47:39 -0400
changeset 50687 50334c9ac182310db9dc4a1ab2a1c453b3610d63
parent 50686 235a99fd59fda60eeffe99952a24fe4978121163
child 50688 096ac689dbe96c8bdee96432f062057f70a335ce
push idunknown
push userunknown
push dateunknown
reviewersjrmuizel, Pike, beltzner
bugs587719
milestone2.0b4pre
Bug 587719: look for special application/x-moz-keyword-url URL type for keyword searches, to allow keyword-search-specific URLs, r=jrmuizel/Pike, a=beltzner
browser/app/profile/firefox.js
browser/locales/en-US/chrome/browser-region/region.properties
docshell/base/nsDefaultURIFixup.cpp
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -178,17 +178,19 @@ pref("extensions.{972ce4c6-7e08-4474-a28
 pref("extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.description", "chrome://browser/locale/browser.properties");
 
 pref("xpinstall.whitelist.add", "addons.mozilla.org");
 pref("xpinstall.whitelist.add.36", "getpersonas.com");
 
 pref("lightweightThemes.update.enabled", true);
 
 pref("keyword.enabled", true);
-pref("keyword.URL", "chrome://browser-region/locale/region.properties");
+// Override the default keyword.URL. Empty value means
+// "use the search service's default engine"
+pref("keyword.URL", "");
 
 pref("general.useragent.locale", "@AB_CD@");
 pref("general.skins.selectedSkin", "classic/1.0");
 pref("general.useragent.extra.firefox", "@APP_UA_NAME@/@APP_VERSION@");
 
 pref("general.smoothScroll", false);
 #ifdef UNIX_BUT_NOT_MAC
 pref("general.autoScroll", false);
--- a/browser/locales/en-US/chrome/browser-region/region.properties
+++ b/browser/locales/en-US/chrome/browser-region/region.properties
@@ -9,19 +9,16 @@ browser.search.order.2=Yahoo
 # selection UI
 browser.contentHandlers.types.0.title=Bloglines
 browser.contentHandlers.types.0.uri=http://www.bloglines.com/login?r=/sub/%s
 browser.contentHandlers.types.1.title=My Yahoo!
 browser.contentHandlers.types.1.uri=http://add.my.yahoo.com/rss?url=%s
 browser.contentHandlers.types.2.title=Google
 browser.contentHandlers.types.2.uri=http://fusion.google.com/add?feedurl=%s
 
-# Keyword URL (for location bar searches)
-keyword.URL=
-
 # URL for site-specific search engines
 # TRANSLATION NOTE: {moz:domain} and {searchTerms} are placeholders for the site
 # to be searched and the user's search query. Place them in the appropriate location
 # for your locale's URL but do not translate them.
 browser.search.siteSearchURL=http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&q=site%3A{moz:domain}+{searchTerms}
 
 # increment this number when anything gets changed in the list below.  This will
 # cause Firefox to re-read these prefs and inject any new handlers into the 
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -401,19 +401,32 @@ NS_IMETHODIMP nsDefaultURIFixup::Keyword
 
     // Try falling back to the search service's default search engine
     nsCOMPtr<nsIBrowserSearchService> searchSvc = do_GetService("@mozilla.org/browser/search-service;1");
     if (searchSvc) {
         nsCOMPtr<nsISearchEngine> defaultEngine;
         searchSvc->GetDefaultEngine(getter_AddRefs(defaultEngine));
         if (defaultEngine) {
             nsCOMPtr<nsISearchSubmission> submission;
+            // We want to allow default search plugins to specify alternate
+            // parameters that are specific to keyword searches. For the moment,
+            // do this by first looking for a magic
+            // "application/x-moz-keywordsearch" submission type. In the future,
+            // we should instead use a solution that relies on bug 587780.
             defaultEngine->GetSubmission(NS_ConvertUTF8toUTF16(aKeyword),
-                                         EmptyString(),
+                                         NS_LITERAL_STRING("application/x-moz-keywordsearch"),
                                          getter_AddRefs(submission));
+            // If getting the special x-moz-keywordsearch submission type failed,
+            // fall back to the default response type.
+            if (!submission) {
+                defaultEngine->GetSubmission(NS_ConvertUTF8toUTF16(aKeyword),
+                                             EmptyString(),
+                                             getter_AddRefs(submission));
+            }
+
             if (submission) {
                 // The submission depends on POST data (i.e. the search engine's
                 // "method" is POST), we can't use this engine for keyword
                 // searches
                 nsCOMPtr<nsIInputStream> postData;
                 submission->GetPostData(getter_AddRefs(postData));
                 if (postData) {
                     return NS_ERROR_NOT_AVAILABLE;