Bug 865218: Allow application/x-moz-keywordsearch to work again. r=gavin
authorMike Kaply <mozilla@kaply.com>
Wed, 01 May 2013 22:49:14 -0500
changeset 130588 d62ad9a19c33c521e5473575e7cbdd940aecfd01
parent 130587 a606d921d45aae01f97b86bc6932a6839413c6c4
child 130589 80f36848bcbe1e97e8a8f7c2e1e7f12a7129b6de
push id1579
push userphilringnalda@gmail.com
push dateSat, 04 May 2013 04:38:04 +0000
treeherderfx-team@a56432a42a41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs865218
milestone23.0a1
Bug 865218: Allow application/x-moz-keywordsearch to work again. r=gavin
docshell/base/nsDefaultURIFixup.cpp
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -335,20 +335,29 @@ NS_IMETHODIMP nsDefaultURIFixup::Keyword
     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 allow default search plugins to specify alternate
             // parameters that are specific to keyword searches.
-            defaultEngine->GetSubmission(NS_ConvertUTF8toUTF16(keyword),
-                                         EmptyString(),
-                                         NS_LITERAL_STRING("keyword"),
-                                         getter_AddRefs(submission));
+            NS_NAMED_LITERAL_STRING(mozKeywordSearch, "application/x-moz-keywordsearch");
+            bool supportsResponseType = false;
+            defaultEngine->SupportsResponseType(mozKeywordSearch, &supportsResponseType);
+            if (supportsResponseType)
+              defaultEngine->GetSubmission(NS_ConvertUTF8toUTF16(keyword),
+                                           mozKeywordSearch,
+                                           NS_LITERAL_STRING("keyword"),
+                                           getter_AddRefs(submission));
+            else
+              defaultEngine->GetSubmission(NS_ConvertUTF8toUTF16(keyword),
+                                           EmptyString(),
+                                           NS_LITERAL_STRING("keyword"),
+                                           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;