Bug 823230 - (Part 1) Pass search term along with "keyword-search" notification. r=gavin
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 10 Apr 2013 11:02:04 -0700
changeset 128355 26bc83f8c555135569a0ece338104c1f7994b6ba
parent 128354 9f10c5b3c41830d52745430e36347398d821e690
child 128356 49b44cd1cdb12c97cf07eb3fd9669edb6bfcff64
push id24528
push userryanvm@gmail.com
push dateThu, 11 Apr 2013 19:19:41 +0000
treeherdermozilla-central@7b8ed29c6bc0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs823230
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 823230 - (Part 1) Pass search term along with "keyword-search" notification. r=gavin
browser/components/nsBrowserGlue.js
docshell/base/nsDefaultURIFixup.cpp
docshell/test/browser/browser_search_notification.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -296,17 +296,18 @@ BrowserGlue.prototype = {
                          .healthReporter;
 
         if (!reporter) {
           return;
         }
 
         reporter.onInit().then(function record() {
           try {
-            reporter.getProvider("org.mozilla.searches").recordSearch(data,
+            let name = subject.QueryInterface(Ci.nsISearchEngine).name;
+            reporter.getProvider("org.mozilla.searches").recordSearch(name,
                                                                       "urlbar");
           } catch (ex) {
             Cu.reportError(ex);
           }
         });
         break;
 #endif
     }
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -358,19 +358,17 @@ NS_IMETHODIMP nsDefaultURIFixup::Keyword
                 // can increment counts from the search engine. The assumption
                 // here is that this keyword/submission will eventually result
                 // in a search. Since we only generate a URI here, there is the
                 // possibility we'll increment the counter without actually
                 // incurring a search. A robust solution would involve currying
                 // the search engine's name through various function calls.
                 nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
                 if (obsSvc) {
-                  nsAutoString name;
-                  defaultEngine->GetName(name);
-                  obsSvc->NotifyObservers(nullptr, "keyword-search", name.get());
+                    obsSvc->NotifyObservers(defaultEngine, "keyword-search", NS_ConvertUTF8toUTF16(keyword).get());
                 }
 
                 return submission->GetUri(aURI);
             }
         }
     }
 #endif
 
--- a/docshell/test/browser/browser_search_notification.js
+++ b/docshell/test/browser/browser_search_notification.js
@@ -8,17 +8,18 @@ function test() {
   gBrowser.selectedTab = tab;
 
   function observer(subject, topic, data) {
     Services.obs.removeObserver(observer, "keyword-search");
     is(topic, "keyword-search", "Got keyword-search notification");
 
     let engine = Services.search.defaultEngine;
     ok(engine, "Have default search engine.");
-    is(engine.name, data, "Notification data is engine name.");
+    is(engine, subject, "Notification subject is engine.");
+    is("firefox health report", data, "Notification data is search term.");
 
     executeSoon(function cleanup() {
       gBrowser.removeTab(tab);
       finish();
     });
   }
 
   Services.obs.addObserver(observer, "keyword-search", false);