Bug 915355 - Part 2: Add clarifying comments on keyword-search to Android code. r=rnewman
authorMichael Comella <michael.l.comella@gmail.com>
Fri, 27 Sep 2013 09:38:25 -0700
changeset 149084 50a9cd1bc956f19ae011df072f57bcc93bd7f6f5
parent 149083 d725f6930fbd5b61a360d694ccbb25a270eb93ec
child 149085 06c93b10958f1d6515f5d9197f98a987db4e7388
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersrnewman
bugs915355
milestone27.0a1
Bug 915355 - Part 2: Add clarifying comments on keyword-search to Android code. r=rnewman
mobile/android/base/health/BrowserHealthRecorder.java
mobile/android/chrome/content/browser.js
--- a/mobile/android/base/health/BrowserHealthRecorder.java
+++ b/mobile/android/base/health/BrowserHealthRecorder.java
@@ -60,19 +60,20 @@ import java.util.concurrent.atomic.Atomi
  */
 public class BrowserHealthRecorder implements GeckoEventListener {
     private static final String LOG_TAG = "GeckoHealthRec";
     private static final String PREF_BLOCKLIST_ENABLED = "extensions.blocklist.enabled";
     private static final String EVENT_ADDONS_ALL = "Addons:All";
     private static final String EVENT_ADDONS_CHANGE = "Addons:Change";
     private static final String EVENT_ADDONS_UNINSTALLING = "Addons:Uninstalling";
     private static final String EVENT_PREF_CHANGE = "Pref:Change";
- 
-    // This is raised from Gecko. It avoids browser.js having to know about the
-    // location that invoked it (the URL bar).
+
+    // This is raised from Gecko and signifies a search via the URL bar (not a bookmarks keyword
+    // search). Using this event (rather than passing the invocation location as an arg) avoids
+    // browser.js having to know about the invocation location.
     public static final String EVENT_KEYWORD_SEARCH = "Search:Keyword";
 
     // This is raised from Java. We include the location in the message.
     public static final String EVENT_SEARCH = "Search:Event";
 
     public enum State {
         NOT_INITIALIZED,
         INITIALIZING,
@@ -676,16 +677,19 @@ public class BrowserHealthRecorder imple
                 Log.d(LOG_TAG, "Pref changed: " + pref);
                 handlePrefValue(pref, message.getBoolean("value"));
                 this.onEnvironmentChanged();
                 return;
             }
 
             // Searches.
             if (EVENT_KEYWORD_SEARCH.equals(event)) {
+                // A search via the URL bar. Since we eliminate all other search possibilities
+                // (e.g. bookmarks keyword, search suggestion) when we initially process the
+                // search URL, this is considered a default search.
                 recordSearch(message.getString("identifier"), "bartext");
                 return;
             }
             if (EVENT_SEARCH.equals(event)) {
                 if (!message.has("location")) {
                     Log.d(LOG_TAG, "Ignoring search without location.");
                     return;
                 }
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1397,17 +1397,19 @@ var BrowserApp = {
         this._handleTabSelected(this.getTabForId(parseInt(aData)));
         break;
 
       case "Tab:Closed":
         this._handleTabClosed(this.getTabForId(parseInt(aData)));
         break;
 
       case "keyword-search":
-        // This assumes that the user can only perform a keyword search on the selected tab.
+        // This event refers to a search via the URL bar, not a bookmarks
+        // keyword search. Note that this code assumes that the user can only
+        // perform a keyword search on the selected tab.
         this.selectedTab.userSearch = aData;
 
         let engine = aSubject.QueryInterface(Ci.nsISearchEngine);
         sendMessageToJava({
           type: "Search:Keyword",
           identifier: engine.identifier,
           name: engine.name,
         });