Bug 724116 - Add additional URL types to implement channel parameter for Google search plugin. r=gavin
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 18 Mar 2011 14:56:46 -0700
changeset 86849 94cd5a4d7a103bd1cba6ce394b4c8d8392534a64
parent 86848 a5bd3f716d86363c88baf33f0d92409a55e4338a
child 86850 c7423cda433c3b978726f328ba2911754261571c
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersgavin
bugs724116, 596439
milestone13.0a1
Bug 724116 - Add additional URL types to implement channel parameter for Google search plugin. r=gavin Based on Gavin's patch for bug 596439.
browser/base/content/browser-context.inc
browser/base/content/browser.js
browser/base/content/test/browser_canonizeURL.js
browser/base/content/test/browser_keywordSearch.js
browser/components/search/test/Makefile.in
browser/components/search/test/browser_426329.js
browser/components/search/test/browser_contextmenu.js
browser/components/search/test/testEngine_mozsearch.xml
browser/locales/en-US/searchplugins/google-params.inc
browser/locales/en-US/searchplugins/google.xml
--- a/browser/base/content/browser-context.inc
+++ b/browser/base/content/browser-context.inc
@@ -256,17 +256,18 @@
                 accesskey="&selectAllCmd.accesskey;"
                 command="cmd_selectAll"/>
       <menuseparator id="context-sep-selectall"/>
       <menuitem id="context-keywordfield"
                 label="&keywordfield.label;"
                 accesskey="&keywordfield.accesskey;"
                 oncommand="AddKeywordForSearchField();"/>
       <menuitem id="context-searchselect"
-                oncommand="BrowserSearch.loadSearch(getBrowserSelection(), true);"/>
+                oncommand="BrowserSearch.loadSearch(getBrowserSelection(), true,
+                                                    'application/x-moz-contextsearch');"/>
       <menuseparator id="frame-sep"/>
       <menu id="frame" label="&thisFrameMenu.label;" accesskey="&thisFrameMenu.accesskey;">
         <menupopup>
           <menuitem id="context-showonlythisframe"
                     label="&showOnlyThisFrameCmd.label;"
                     accesskey="&showOnlyThisFrameCmd.accesskey;"
                     oncommand="gContextMenu.showOnlyThisFrame();"/>
           <menuitem id="context-openframeintab"
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3520,28 +3520,38 @@ const BrowserSearch = {
    * engine if the search bar is visible, or the default engine otherwise.
    *
    * @param searchText
    *        The search terms to use for the search.
    *
    * @param useNewTab
    *        Boolean indicating whether or not the search should load in a new
    *        tab.
+   *
+   * @param responseType [optional]
+   *        The MIME type that we'd like to receive in response
+   *        to this submission.  If null or the the response type is not supported
+   *        for the search engine, will fallback to "text/html".
    */
-  loadSearch: function BrowserSearch_search(searchText, useNewTab) {
+  loadSearch: function BrowserSearch_search(searchText, useNewTab, responseType) {
     var engine;
 
     // If the search bar is visible, use the current engine, otherwise, fall
     // back to the default engine.
     if (isElementVisible(this.searchBar))
       engine = Services.search.currentEngine;
     else
       engine = Services.search.defaultEngine;
 
-    var submission = engine.getSubmission(searchText); // HTML response
+    var submission = engine.getSubmission(searchText, responseType);
+
+    // If a response type was specified and getSubmission returned null,
+    // fallback to the default response type.
+    if (!submission && responseType)
+      submission = engine.getSubmission(searchText);
 
     // getSubmission can return null if the engine doesn't have a URL
     // with a text/html response type.  This is unlikely (since
     // SearchService._addEngineToStore() should fail for such an engine),
     // but let's be on the safe side.
     if (!submission)
       return;
 
--- a/browser/base/content/test/browser_canonizeURL.js
+++ b/browser/base/content/test/browser_canonizeURL.js
@@ -12,17 +12,17 @@ var pairs = [
   ["example.net", "http://example.net/"],
   ["http://example", "http://example/"],
   ["example:8080", "http://example:8080/"],
   ["ex-ample.foo", "http://ex-ample.foo/"],
   ["example.foo/bar ", "http://example.foo/bar"],
   ["1.1.1.1", "http://1.1.1.1/"],
   ["ftp://example", "ftp://example/"],
   ["ftp.example.bar", "ftp://ftp.example.bar/"],
-  ["ex ample", Services.search.originalDefaultEngine.getSubmission("ex ample").uri.spec],
+  ["ex ample", Services.search.originalDefaultEngine.getSubmission("ex ample", "application/x-moz-keywordsearch").uri.spec],
 ];
 
 function testNext() {
   if (!pairs.length) {
     finish();
     return;
   }
 
--- a/browser/base/content/test/browser_keywordSearch.js
+++ b/browser/base/content/test/browser_keywordSearch.js
@@ -2,22 +2,22 @@
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  **/
 
 var gTests = [
   {
     name: "normal search (search service)",
     testText: "test search",
-    searchURL: Services.search.originalDefaultEngine.getSubmission("test search").uri.spec
+    searchURL: Services.search.originalDefaultEngine.getSubmission("test search", "application/x-moz-keywordsearch").uri.spec
   },
   {
     name: "?-prefixed search (search service)",
     testText: "?   foo  ",
-    searchURL: Services.search.originalDefaultEngine.getSubmission("foo").uri.spec
+    searchURL: Services.search.originalDefaultEngine.getSubmission("foo", "application/x-moz-keywordsearch").uri.spec
   },
   {
     name: "normal search (keyword.url)",
     testText: "test search",
     keywordURLPref: "http://example.com/?q=",
     searchURL: "http://example.com/?q=test+search"
   },
   {
--- a/browser/components/search/test/Makefile.in
+++ b/browser/components/search/test/Makefile.in
@@ -41,17 +41,19 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  =  browser/components/search/test
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _BROWSER_TEST_FILES = 	  browser_405664.js \
 	                  browser_addEngine.js \
+	                  browser_contextmenu.js \
 	                  testEngine.xml \
+	                  testEngine_mozsearch.xml \
 	                  testEngine.src \
 	                  browser_426329.js \
 	                  426329.xml \
 	                  browser_483086.js \
 	                  483086-1.xml \
 	                  483086-2.xml \
 	                  test.html \
 	                  $(NULL)
--- a/browser/components/search/test/browser_426329.js
+++ b/browser/components/search/test/browser_426329.js
@@ -3,16 +3,18 @@
 var chromeUtils = {};
 this._scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
                      getService(Ci.mozIJSSubScriptLoader);
 this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js", chromeUtils);
 
 function test() {
   waitForExplicitFinish();
 
+  const ENGINE_HTML_BASE = "http://mochi.test:8888/browser/browser/components/search/test/test.html";
+
   var searchEntries = ["test", "More Text", "Some Text"];
   var searchBar = BrowserSearch.searchBar;
   var searchButton = document.getAnonymousElementByAttribute(searchBar,
                      "anonid", "search-go-button");
   ok(searchButton, "got search-go-button");
 
   searchBar.value = "test";
 
@@ -52,31 +54,33 @@ function test() {
   function testReturn() {
     init();
     EventUtils.synthesizeKey("VK_RETURN", {});
     doOnloadOnce(function(event) {
 
       is(gBrowser.tabs.length, preTabNo, "Return key did not open new tab");
       is(event.originalTarget, preSelectedBrowser.contentDocument,
          "Return key loaded results in current tab");
+      is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
 
       testAltReturn();
     });
   }
 
   function testAltReturn() {
     init();
     EventUtils.synthesizeKey("VK_RETURN", { altKey: true });
     doOnloadOnce(function(event) {
 
       is(gBrowser.tabs.length, preTabNo + 1, "Alt+Return key added new tab");
       isnot(event.originalTarget, preSelectedBrowser.contentDocument,
             "Alt+Return key loaded results in new tab");
       is(event.originalTarget, gBrowser.contentDocument,
          "Alt+Return key loaded results in foreground tab");
+      is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
 
       //Shift key has no effect for now, so skip it
       //testShiftAltReturn();
       testLeftClick();
     });
   }
 
   function testShiftAltReturn() {
@@ -84,59 +88,63 @@ function test() {
     EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true, altKey: true });
     doOnloadOnce(function(event) {
 
       is(gBrowser.tabs.length, preTabNo + 1, "Shift+Alt+Return key added new tab");
       isnot(event.originalTarget, preSelectedBrowser.contentDocument,
             "Shift+Alt+Return key loaded results in new tab");
       isnot(event.originalTarget, gBrowser.contentDocument,
             "Shift+Alt+Return key loaded results in background tab");
+      is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
 
       testLeftClick();
     });
   }
 
   function testLeftClick() {
     init();
     simulateClick({ button: 0 }, searchButton);
     doOnloadOnce(function(event) {
 
       is(gBrowser.tabs.length, preTabNo, "LeftClick did not open new tab");
       is(event.originalTarget, preSelectedBrowser.contentDocument,
          "LeftClick loaded results in current tab");
+      is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
 
       testMiddleClick();
     });
   }
 
   function testMiddleClick() {
     init();
     simulateClick({ button: 1 }, searchButton);
     doOnloadOnce(function(event) {
 
       is(gBrowser.tabs.length, preTabNo + 1, "MiddleClick added new tab");
       isnot(event.originalTarget, preSelectedBrowser.contentDocument,
             "MiddleClick loaded results in new tab");
       is(event.originalTarget, gBrowser.contentDocument,
          "MiddleClick loaded results in foreground tab");
+      is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
 
       testShiftMiddleClick();
     });
   }
 
   function testShiftMiddleClick() {
     init();
     simulateClick({ button: 1, shiftKey: true }, searchButton);
     doOnloadOnce(function(event) {
 
       is(gBrowser.tabs.length, preTabNo + 1, "Shift+MiddleClick added new tab");
       isnot(event.originalTarget, preSelectedBrowser.contentDocument,
             "Shift+MiddleClick loaded results in new tab");
       isnot(event.originalTarget, gBrowser.contentDocument,
             "Shift+MiddleClick loaded results in background tab");
+      is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
 
       testDropText();
      });
    }
  
   // prevent the search buttonmenu from opening during the drag tests
   function stopPopup(event) { event.preventDefault(); }
 
@@ -227,16 +235,23 @@ function test() {
     var buttonArg   = aEvent.button   || 0;
     event.initMouseEvent("click", true, true, window,
                           0, 0, 0, 0, 0,
                           ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg,
                           buttonArg, null); 
     aTarget.dispatchEvent(event);
   }
 
+  function expectedURL(aSearchTerms) {
+    var textToSubURI = Cc["@mozilla.org/intl/texttosuburi;1"].
+                       getService(Ci.nsITextToSubURI);
+    var searchArg = textToSubURI.ConvertAndEscape("utf-8", aSearchTerms);
+    return ENGINE_HTML_BASE + "?test=" + searchArg;
+  }
+
   // modified from toolkit/components/satchel/test/test_form_autocomplete.html
   function checkMenuEntries(expectedValues) {
     var actualValues = getMenuEntries();
     is(actualValues.length, expectedValues.length, "Checking length of expected menu");
     for (var i = 0; i < expectedValues.length; i++)
       is(actualValues[i], expectedValues[i], "Checking menu entry #"+i);
   }
 
new file mode 100644
--- /dev/null
+++ b/browser/components/search/test/browser_contextmenu.js
@@ -0,0 +1,97 @@
+/* Any copyright is dedicated to the Public Domain.
+ *  * http://creativecommons.org/publicdomain/zero/1.0/ */
+/*
+ * Test searching for the selected text using the context menu
+ */
+
+function test() {
+  waitForExplicitFinish();
+
+  const ss = Services.search;
+  const ENGINE_NAME = "Foo";
+  var contextMenu;
+
+  function observer(aSub, aTopic, aData) {
+    switch (aData) {
+      case "engine-added":
+        var engine = ss.getEngineByName(ENGINE_NAME);
+        ok(engine, "Engine was added.");
+        //XXX Bug 493051
+        //ss.currentEngine = engine;
+        break;
+      case "engine-current":
+        ok(ss.currentEngine.name == ENGINE_NAME, "currentEngine set");
+        startTest();
+        break;
+      case "engine-removed":
+        Services.obs.removeObserver(observer, "browser-search-engine-modified");
+        finish();
+        break;
+    }
+  }
+
+  Services.obs.addObserver(observer, "browser-search-engine-modified", false);
+  ss.addEngine("http://mochi.test:8888/browser/browser/components/search/test/testEngine_mozsearch.xml",
+               Ci.nsISearchEngine.DATA_XML, "data:image/x-icon,%00",
+               false);
+
+  function startTest() {
+    contextMenu = document.getElementById("contentAreaContextMenu");
+    ok(contextMenu, "Got context menu XUL");
+
+    doOnloadOnce(testContextMenu);
+    var tab = gBrowser.addTab("data:text/plain,test%20search");
+    gBrowser.selectedTab = tab;
+  }
+
+  function testContextMenu() {
+    function rightClickOnDocument(){
+      var clickTarget = content.document.body;
+      var eventDetails = { type: "contextmenu", button: 2 };
+      EventUtils.synthesizeMouseAtCenter(clickTarget, eventDetails, content);
+      SimpleTest.executeSoon(checkContextMenu);
+    }
+
+    // check the search menu item and then perform a search
+    function checkContextMenu() {
+      var searchItem = contextMenu.getElementsByAttribute("id", "context-searchselect")[0];
+      ok(searchItem, "Got search context menu item");
+      is(searchItem.label, 'Search ' + ENGINE_NAME + ' for "test search"', "Check context menu label");
+      is(searchItem.disabled, false, "Check that search context menu item is enabled");
+      searchItem.click();
+    }
+
+    function checkSearchURL(event){
+      is(event.originalTarget.URL,
+         "http://mochi.test:8888/browser/browser/components/search/test/?test=test+search&ie=utf-8&client=app&channel=contextsearch",
+         "Checking context menu search URL");
+      finalize();
+    }
+
+    doOnloadOnce(checkSearchURL);
+
+    // select the text on the page
+    var selectAllItem = contextMenu.getElementsByAttribute("id", "context-selectall")[0];
+    ok(selectAllItem, "Got select all context menu item");
+    selectAllItem.click();
+
+    // wait for the selection to take effect
+    SimpleTest.executeSoon(rightClickOnDocument);
+  }
+
+  function finalize() {
+    while (gBrowser.tabs.length != 1) {
+      gBrowser.removeTab(gBrowser.tabs[0]);
+    }
+    content.location.href = "about:blank";
+    var engine = ss.getEngineByName(ENGINE_NAME);
+    ss.removeEngine(engine);
+  }
+
+  function doOnloadOnce(callback) {
+    gBrowser.addEventListener("DOMContentLoaded", function handleLoad(event) {
+      gBrowser.removeEventListener("DOMContentLoaded", handleLoad, true);
+      callback(event);
+    }, true);
+  }
+}
copy from browser/components/search/test/testEngine.xml
copy to browser/components/search/test/testEngine_mozsearch.xml
--- a/browser/components/search/test/testEngine.xml
+++ b/browser/components/search/test/testEngine_mozsearch.xml
@@ -1,12 +1,25 @@
-<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
-                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">
+<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
   <ShortName>Foo</ShortName>
   <Description>Foo Search</Description>
   <InputEncoding>utf-8</InputEncoding>
   <Image width="16" height="16">data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC</Image>
-  <Url type="text/html" method="GET" template="http://mochi.test:8888/browser/browser/components/search/test/?search">
+  <Url type="application/x-suggestions+json" method="GET" template="http://mochi.test:8888/browser/browser/components/search/test/?suggestions&amp;locale={moz:locale}&amp;test={searchTerms}"/>
+  <Url type="text/html" method="GET" template="http://mochi.test:8888/browser/browser/components/search/test/">
     <Param name="test" value="{searchTerms}"/>
+    <Param name="ie" value="utf-8"/>
+    <MozParam name="client" condition="defaultEngine" trueValue="app-default" falseValue="app"/>
   </Url>
-  <moz:SearchForm>http://mochi.test:8888/browser/browser/components/search/test/</moz:SearchForm>
-  <moz:Alias>fooalias</moz:Alias>
-</OpenSearchDescription>
+  <Url type="application/x-moz-keywordsearch" method="GET" template="http://mochi.test:8888/browser/browser/components/search/test/">
+    <Param name="test" value="{searchTerms}"/>
+    <Param name="ie" value="utf-8"/>
+    <MozParam name="client" condition="defaultEngine" trueValue="app-default" falseValue="app"/>
+    <Param name="channel" value="keywordsearch"/>
+  </Url>
+  <Url type="application/x-moz-contextsearch" method="GET" template="http://mochi.test:8888/browser/browser/components/search/test/">
+    <Param name="test" value="{searchTerms}"/>
+    <Param name="ie" value="utf-8"/>
+    <MozParam name="client" condition="defaultEngine" trueValue="app-default" falseValue="app"/>
+    <Param name="channel" value="contextsearch"/>
+  </Url>
+  <SearchForm>http://mochi.test:8888/browser/browser/components/search/test/</SearchForm>
+</SearchPlugin>
new file mode 100644
--- /dev/null
+++ b/browser/locales/en-US/searchplugins/google-params.inc
@@ -0,0 +1,15 @@
+  <Param name="q" value="{searchTerms}"/>
+  <Param name="ie" value="utf-8"/>
+  <Param name="oe" value="utf-8"/>
+  <Param name="aq" value="t"/>
+  <!-- Dynamic parameters -->
+  <Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>
+#if MOZ_UPDATE_CHANNEL == beta
+  <MozParam name="client" condition="defaultEngine" trueValue="firefox-beta" falseValue="firefox"/>
+#elif MOZ_UPDATE_CHANNEL == aurora
+  <MozParam name="client" condition="defaultEngine" trueValue="firefox-aurora" falseValue="firefox"/>
+#elif MOZ_UPDATE_CHANNEL == nightly
+  <MozParam name="client" condition="defaultEngine" trueValue="firefox-nightly" falseValue="firefox"/>
+#else
+  <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/>
+#endif
--- a/browser/locales/en-US/searchplugins/google.xml
+++ b/browser/locales/en-US/searchplugins/google.xml
@@ -1,25 +1,21 @@
 <SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
 <ShortName>Google</ShortName>
 <Description>Google Search</Description>
 <InputEncoding>UTF-8</InputEncoding>
 <Image width="16" height="16">data:image/png;base64,AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADs9Pt8xetPtu9FsfFNtu%2BTzvb2%2B%2Fne4dFJeBw0egA%2FfAJAfAA8ewBBegAAAAD%2B%2FPtft98Mp%2BwWsfAVsvEbs%2FQeqvF8xO7%2F%2F%2F63yqkxdgM7gwE%2FggM%2BfQA%2BegBDeQDe7PIbotgQufcMufEPtfIPsvAbs%2FQvq%2Bfz%2Bf%2F%2B%2B%2FZKhR05hgBBhQI8hgBAgAI9ewD0%2B%2Fg3pswAtO8Cxf4Kw%2FsJvvYAqupKsNv%2B%2Fv7%2F%2FP5VkSU0iQA7jQA9hgBDgQU%2BfQH%2F%2Ff%2FQ6fM4sM4KsN8AteMCruIqqdbZ7PH8%2Fv%2Fg6Nc%2Fhg05kAA8jAM9iQI%2BhQA%2BgQDQu6b97uv%2F%2F%2F7V8Pqw3eiWz97q8%2Ff%2F%2F%2F%2F7%2FPptpkkqjQE4kwA7kAA5iwI8iAA8hQCOSSKdXjiyflbAkG7u2s%2F%2B%2F%2F39%2F%2F7r8utrqEYtjQE8lgA7kwA7kwA9jwA9igA9hACiWSekVRyeSgiYSBHx6N%2F%2B%2Fv7k7OFRmiYtlAA5lwI7lwI4lAA7kgI9jwE9iwI4iQCoVhWcTxCmb0K%2BooT8%2Fv%2F7%2F%2F%2FJ2r8fdwI1mwA3mQA3mgA8lAE8lAE4jwA9iwE%2BhwGfXifWvqz%2B%2Ff%2F58u%2Fev6Dt4tr%2B%2F%2F2ZuIUsggA7mgM6mAM3lgA5lgA6kQE%2FkwBChwHt4dv%2F%2F%2F728ei1bCi7VAC5XQ7kz7n%2F%2F%2F6bsZkgcB03lQA9lgM7kwA2iQktZToPK4r9%2F%2F%2F9%2F%2F%2FSqYK5UwDKZAS9WALIkFn%2B%2F%2F3%2F%2BP8oKccGGcIRJrERILYFEMwAAuEAAdX%2F%2Ff7%2F%2FP%2B%2BfDvGXQLIZgLEWgLOjlf7%2F%2F%2F%2F%2F%2F9QU90EAPQAAf8DAP0AAfMAAOUDAtr%2F%2F%2F%2F7%2B%2Fu2bCTIYwDPZgDBWQDSr4P%2F%2Fv%2F%2F%2FP5GRuABAPkAA%2FwBAfkDAPAAAesAAN%2F%2F%2B%2Fz%2F%2F%2F64g1C5VwDMYwK8Yg7y5tz8%2Fv%2FV1PYKDOcAAP0DAf4AAf0AAfYEAOwAAuAAAAD%2F%2FPvi28ymXyChTATRrIb8%2F%2F3v8fk6P8MAAdUCAvoAAP0CAP0AAfYAAO4AAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAA</Image>
 <Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&amp;client=firefox&amp;hl={moz:locale}&amp;q={searchTerms}"/>
 <Url type="text/html" method="GET" template="http://www.google.com/search">
-  <Param name="q" value="{searchTerms}"/>
-  <Param name="ie" value="utf-8"/>
-  <Param name="oe" value="utf-8"/>
-  <Param name="aq" value="t"/>
-  <!-- Dynamic parameters -->
-  <Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>
-#if MOZ_UPDATE_CHANNEL == beta
-  <MozParam name="client" condition="defaultEngine" trueValue="firefox-beta" falseValue="firefox"/>
-#elif MOZ_UPDATE_CHANNEL == aurora
-  <MozParam name="client" condition="defaultEngine" trueValue="firefox-aurora" falseValue="firefox"/>
-#elif MOZ_UPDATE_CHANNEL == nightly
-  <MozParam name="client" condition="defaultEngine" trueValue="firefox-nightly" falseValue="firefox"/>
-#else
-  <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/>
-#endif
+#include google-params.inc
+</Url>
+<!-- Keyword search URL is the same as the default, but with an additional parameter -->
+<Url type="application/x-moz-keywordsearch" method="GET" template="http://www.google.com/search">
+#include google-params.inc
+  <Param name="channel" value="fflb"/>
+</Url>
+<!-- Context/Right-click search URL is the same as the default, but with an additional parameter -->
+<Url type="application/x-moz-contextsearch" method="GET" template="http://www.google.com/search">
+#include google-params.inc
+  <Param name="channel" value="rcs"/>
 </Url>
 <SearchForm>http://www.google.com/</SearchForm>
 </SearchPlugin>