Back out 471f236c32cb bug 959594 for bustage on a CLOSED TREE.
authorDrew Willcoxon <adw@mozilla.com>
Thu, 11 Jun 2015 15:39:23 -0700
changeset 248514 ae1d2c1b1d18a1b37b674ea6df3f4f065e7d94bb
parent 248513 c7a65bc7d69fb19c255971cb4b6ee0801cffaeaf
child 248515 a3399f552e3bb8b671df36456ef9107381279837
push id28898
push userryanvm@gmail.com
push dateFri, 12 Jun 2015 18:52:56 +0000
treeherdermozilla-central@bd930c91d042 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs959594
milestone41.0a1
backs out471f236c32cb8704108fd066149361ee155e0b98
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
Back out 471f236c32cb bug 959594 for bustage on a CLOSED TREE.
browser/app/profile/firefox.js
browser/base/content/browser.js
testing/profiles/prefs_general.js
toolkit/components/places/PlacesSearchAutocompleteProvider.jsm
toolkit/components/places/UnifiedComplete.js
toolkit/components/places/mozIPlacesAutoComplete.idl
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -342,17 +342,16 @@ pref("browser.urlbar.restrict.typed", "~
 pref("browser.urlbar.match.title", "#");
 pref("browser.urlbar.match.url", "@");
 
 // The default behavior for the urlbar can be configured to use any combination
 // of the match filters with each additional filter adding more results (union).
 pref("browser.urlbar.suggest.history",              true);
 pref("browser.urlbar.suggest.bookmark",             true);
 pref("browser.urlbar.suggest.openpage",             true);
-pref("browser.urlbar.suggest.searches",             true);
 
 // Restrictions to current suggestions can also be applied (intersection).
 // Typed suggestion works only if history is set to true.
 pref("browser.urlbar.suggest.history.onlyTyped",    false);
 
 pref("browser.urlbar.formatting.enabled", true);
 pref("browser.urlbar.trimURLs", true);
 
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -7184,28 +7184,25 @@ let gPrivateBrowsingUI = {
             newWindow.label = newPrivateWindow.label;
             newWindow.accessKey = newPrivateWindow.accessKey;
             newWindow.command = newPrivateWindow.command;
           }
         });
       }
     }
 
-    if (gURLBar) {
+    if (gURLBar &&
+        !PrivateBrowsingUtils.permanentPrivateBrowsing) {
+      // Disable switch to tab autocompletion for private windows.
+      // We leave it enabled for permanent private browsing mode though.
       let value = gURLBar.getAttribute("autocompletesearchparam") || "";
-      if (!PrivateBrowsingUtils.permanentPrivateBrowsing &&
-          !value.includes("disable-private-actions")) {
-        // Disable switch to tab autocompletion for private windows.
-        // We leave it enabled for permanent private browsing mode though.
-        value += " disable-private-actions";
+      if (!value.includes("disable-private-actions")) {
+        gURLBar.setAttribute("autocompletesearchparam",
+                             value + " disable-private-actions");
       }
-      if (!value.includes("private-window")) {
-        value += " private-window";
-      }
-      gURLBar.setAttribute("autocompletesearchparam", value);
     }
   }
 };
 
 let gRemoteTabsUI = {
   init: function() {
     if (window.location.href != getBrowserURL() &&
         // Also check hidden window for the Mac no-window case
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -322,12 +322,8 @@ user_pref("network.proxy.pac_generator",
 user_pref("lightweightThemes.selectedThemeID", "");
 user_pref("browser.devedition.theme.enabled", false);
 
 // Disable periodic updates of service workers.
 user_pref("dom.serviceWorkers.periodic-updates.enabled", false);
 
 // Enable speech synth test service, and disable built in platform services.
 user_pref("media.webspeech.synth.test", true);
-
-// Turn off search suggestions in the location bar so as not to trigger network
-// connections.
-user_pref("browser.urlbar.suggest.searches", false);
--- a/toolkit/components/places/PlacesSearchAutocompleteProvider.jsm
+++ b/toolkit/components/places/PlacesSearchAutocompleteProvider.jsm
@@ -12,19 +12,16 @@ this.EXPORTED_SYMBOLS = [ "PlacesSearchA
 
 const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "SearchSuggestionController",
-  "resource://gre/modules/SearchSuggestionController.jsm");
-
 const SEARCH_ENGINE_TOPIC = "browser-search-engine-modified";
 
 const SearchAutocompleteProviderInternal = {
   /**
    * Array of objects in the format returned by findMatchByToken.
    */
   priorityMatches: null,
 
@@ -108,75 +105,20 @@ const SearchAutocompleteProviderInternal
         // we may need an URL which includes an affiliate code (bug 990799).
         url: engine.searchForm,
         engineName: engine.name,
         iconUrl: engine.iconURI ? engine.iconURI.spec : null,
       });
     }
   },
 
-  getSuggestionController(searchToken, inPrivateContext, maxResults) {
-    let engine = Services.search.currentEngine;
-    if (!engine) {
-      return null;
-    }
-    return new SearchSuggestionControllerWrapper(engine, searchToken,
-                                                 inPrivateContext, maxResults);
-  },
-
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                          Ci.nsISupportsWeakReference]),
 }
 
-function SearchSuggestionControllerWrapper(engine, searchToken,
-                                           inPrivateContext, maxResults) {
-  this._controller = new SearchSuggestionController();
-  this._controller.maxLocalResults = 0;
-  this._controller.maxRemoteResults = maxResults;
-  let promise = this._controller.fetch(searchToken, inPrivateContext, engine);
-  this._suggestions = [];
-  this._promise = promise.then(results => {
-    this._suggestions = (results ? results.remote : null) || [];
-  }).catch(err => {
-    // fetch() rejects its promise if there's a pending request.
-  });
-}
-
-SearchSuggestionControllerWrapper.prototype = {
-
-  /**
-   * Resolved when all suggestions have been fetched.
-   */
-  get fetchCompletePromise() {
-    return this._promise;
-  },
-
-  /**
-   * Returns one suggestion, if any are available.  The returned value is an
-   * array [match, suggestion].  If none are available, returns [null, null].
-   * Note that there are two reasons that suggestions might not be available:
-   * all suggestions may have been fetched and consumed, or the fetch may not
-   * have completed yet.
-   *
-   * @return An array [match, suggestion].
-   */
-  consume() {
-    return !this._suggestions.length ? [null, null] :
-           [SearchAutocompleteProviderInternal.defaultMatch,
-            this._suggestions.shift()];
-  },
-
-  /**
-   * Stops the fetch.
-   */
-  stop() {
-    this._controller.stop();
-  },
-};
-
 let gInitializationPromise = null;
 
 this.PlacesSearchAutocompleteProvider = Object.freeze({
   /**
    * Starts initializing the component and returns a promise that is resolved or
    * rejected when initialization finished.  The same promise is returned if
    * this function is called multiple times.
    */
@@ -267,17 +209,9 @@ this.PlacesSearchAutocompleteProvider = 
     }
 
     let parseUrlResult = Services.search.parseSubmissionURL(url);
     return parseUrlResult.engine && {
       engineName: parseUrlResult.engine.name,
       terms: parseUrlResult.terms,
     };
   },
-
-  getSuggestionController(searchToken, inPrivateContext, maxResults) {
-    if (!SearchAutocompleteProviderInternal.initialized) {
-      throw new Error("The component has not been initialized.");
-    }
-    return SearchAutocompleteProviderInternal.getSuggestionController(
-             searchToken, inPrivateContext, maxResults);
-  },
 });
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -30,17 +30,16 @@ const PREF_RESTRICT_TAG =           [ "r
 const PREF_RESTRICT_SWITCHTAB =     [ "restrict.openpage",      "%" ];
 const PREF_MATCH_TITLE =            [ "match.title",            "#" ];
 const PREF_MATCH_URL =              [ "match.url",              "@" ];
 
 const PREF_SUGGEST_HISTORY =        [ "suggest.history",        true ];
 const PREF_SUGGEST_BOOKMARK =       [ "suggest.bookmark",       true ];
 const PREF_SUGGEST_OPENPAGE =       [ "suggest.openpage",       true ];
 const PREF_SUGGEST_HISTORY_ONLYTYPED = [ "suggest.history.onlyTyped", false ];
-const PREF_SUGGEST_SEARCHES =       [ "suggest.searches",       true ];
 
 // Match type constants.
 // These indicate what type of search function we should be using.
 const MATCH_ANYWHERE = Ci.mozIPlacesAutoComplete.MATCH_ANYWHERE;
 const MATCH_BOUNDARY_ANYWHERE = Ci.mozIPlacesAutoComplete.MATCH_BOUNDARY_ANYWHERE;
 const MATCH_BOUNDARY = Ci.mozIPlacesAutoComplete.MATCH_BOUNDARY;
 const MATCH_BEGINNING = Ci.mozIPlacesAutoComplete.MATCH_BEGINNING;
 const MATCH_BEGINNING_CASE_SENSITIVE = Ci.mozIPlacesAutoComplete.MATCH_BEGINNING_CASE_SENSITIVE;
@@ -61,23 +60,16 @@ const TITLE_TAGS_SEPARATOR = " \u2013 ";
 const TITLE_SEARCH_ENGINE_SEPARATOR = " \u00B7\u2013\u00B7 ";
 
 // Telemetry probes.
 const TELEMETRY_1ST_RESULT = "PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS";
 const TELEMETRY_6_FIRST_RESULTS = "PLACES_AUTOCOMPLETE_6_FIRST_RESULTS_TIME_MS";
 // The default frecency value used when inserting matches with unknown frecency.
 const FRECENCY_DEFAULT = 1000;
 
-// Search suggestion results are mixed in with all other results after they
-// become available, but they're only inserted once every N results whose
-// frecencies are less than FRECENCY_DEFAULT.  In other words, for every N
-// results that fall below that frecency threshold, one search suggestion is
-// inserted.  This value = N.
-const SEARCH_SUGGESTION_INSERT_INTERVAL = 2;
-
 // A regex that matches "single word" hostnames for whitelisting purposes.
 // The hostname will already have been checked for general validity, so we
 // don't need to be exhaustive here, so allow dashes anywhere.
 const REGEXP_SINGLEWORD_HOST = new RegExp("^[a-z0-9-]+$", "i");
 
 // Sqlite result row index constants.
 const QUERYINDEX_QUERYTYPE     = 0;
 const QUERYINDEX_URL           = 1;
@@ -347,34 +339,28 @@ XPCOMUtils.defineLazyGetter(this, "Switc
   }
 }));
 
 /**
  * This helper keeps track of preferences and keeps their values up-to-date.
  */
 XPCOMUtils.defineLazyGetter(this, "Prefs", () => {
   let prefs = new Preferences(PREF_BRANCH);
-  let types = ["History", "Bookmark", "Openpage", "Typed", "Searches"];
+  let types = ["History", "Bookmark", "Openpage", "Typed"];
 
   function syncEnabledPref(init = false) {
-    let suggestPrefs = [
-      PREF_SUGGEST_HISTORY,
-      PREF_SUGGEST_BOOKMARK,
-      PREF_SUGGEST_OPENPAGE,
-      PREF_SUGGEST_SEARCHES,
-    ];
+    let suggestPrefs = [PREF_SUGGEST_HISTORY, PREF_SUGGEST_BOOKMARK, PREF_SUGGEST_OPENPAGE];
 
     if (init) {
       // Make sure to initialize the properties when first called with init = true.
       store.enabled = prefs.get(...PREF_ENABLED);
       store.suggestHistory = prefs.get(...PREF_SUGGEST_HISTORY);
       store.suggestBookmark = prefs.get(...PREF_SUGGEST_BOOKMARK);
       store.suggestOpenpage = prefs.get(...PREF_SUGGEST_OPENPAGE);
       store.suggestTyped = prefs.get(...PREF_SUGGEST_HISTORY_ONLYTYPED);
-      store.suggestSearches = prefs.get(...PREF_SUGGEST_SEARCHES);
     }
 
     if (store.enabled) {
       // If the autocomplete preference is active, set to default value all suggest
       // preferences only if all of them are false.
       if (types.every(type => store["suggest" + type] == false)) {
         for (let type of suggestPrefs) {
           prefs.set(...type);
@@ -404,17 +390,16 @@ XPCOMUtils.defineLazyGetter(this, "Prefs
     store.restrictTagToken = prefs.get(...PREF_RESTRICT_TAG);
     store.restrictOpenPageToken = prefs.get(...PREF_RESTRICT_SWITCHTAB);
     store.matchTitleToken = prefs.get(...PREF_MATCH_TITLE);
     store.matchURLToken = prefs.get(...PREF_MATCH_URL);
     store.suggestHistory = prefs.get(...PREF_SUGGEST_HISTORY);
     store.suggestBookmark = prefs.get(...PREF_SUGGEST_BOOKMARK);
     store.suggestOpenpage = prefs.get(...PREF_SUGGEST_OPENPAGE);
     store.suggestTyped = prefs.get(...PREF_SUGGEST_HISTORY_ONLYTYPED);
-    store.suggestSearches = prefs.get(...PREF_SUGGEST_SEARCHES);
 
     // If history is not set, onlyTyped value should be ignored.
     if (!store.suggestHistory) {
       store.suggestTyped = false;
     }
     store.defaultBehavior = types.reduce((memo, type) => {
       let prefValue = store["suggest" + type];
       return memo | (prefValue &&
@@ -576,17 +561,16 @@ function Search(searchString, searchPara
   this._matchBehavior = Prefs.matchBehavior;
   // Set the default behavior for this search.
   this._behavior = this._searchString ? Prefs.defaultBehavior
                                       : Prefs.emptySearchDefaultBehavior;
 
   let params = new Set(searchParam.split(" "));
   this._enableActions = params.has("enable-actions");
   this._disablePrivateActions = params.has("disable-private-actions");
-  this._inPrivateWindow = params.has("private-window");
 
   this._searchTokens =
     this.filterTokens(getUnfilteredSearchTokens(this._searchString));
   // The protocol and the host are lowercased by nsIURI, so it's fine to
   // lowercase the typed prefix, to add it back to the results later.
   this._strippedPrefix = this._trimmedOriginalSearchString.slice(
     0, this._trimmedOriginalSearchString.length - this._searchString.length
   ).toLowerCase();
@@ -610,18 +594,16 @@ function Search(searchString, searchPara
   result.setListener(resultListener);
   // Will be set later, if needed.
   result.setDefaultIndex(-1);
   this._result = result;
 
   // These are used to avoid adding duplicate entries to the results.
   this._usedURLs = new Set();
   this._usedPlaceIds = new Set();
-
-  this._searchSuggestionInsertCounter = 0;
 }
 
 Search.prototype = {
   /**
    * Enables the desired AutoComplete behavior.
    *
    * @param type
    *        The behavior type to set.
@@ -717,20 +699,16 @@ Search.prototype = {
    */
   cancel: function () {
     if (this._sleepTimer)
       this._sleepTimer.cancel();
     if (this._sleepDeferred) {
       this._sleepDeferred.resolve();
       this._sleepDeferred = null;
     }
-    if (this._searchSuggestionController) {
-      this._searchSuggestionController.stop();
-      this._searchSuggestionController = null;
-    }
     this.pending = false;
   },
 
   /**
    * Whether this search is active.
    */
   pending: true,
 
@@ -823,32 +801,17 @@ Search.prototype = {
       // If we don't have a result that matches what we know about, then
       // we use a fallback for things we don't know about.
       yield this._matchHeuristicFallback();
     }
 
     // IMPORTANT: No other first result heuristics should run after
     // _matchHeuristicFallback().
 
-    yield this._sleep(Math.round(Prefs.delay / 2));
-    if (!this.pending)
-      return;
-
-    // Start fetching search suggestions a little earlier than Prefs.delay since
-    // they're remote and will probably take longer to arrive.
-    if (this.hasBehavior("searches")) {
-      this._searchSuggestionController =
-        PlacesSearchAutocompleteProvider.getSuggestionController(
-          this._originalSearchString,
-          this._inPrivateWindow,
-          Prefs.maxRichResults
-        );
-    }
-
-    yield this._sleep(Math.round(Prefs.delay / 2));
+    yield this._sleep(Prefs.delay);
     if (!this.pending)
       return;
 
     for (let [query, params] of queries) {
       let hasResult = yield conn.executeCached(query, params, this._onResultRow.bind(this));
 
       if (this.pending && this._enableActions && !hasResult &&
           params.query_type == QUERYTYPE_AUTOFILL_URL) {
@@ -869,23 +832,16 @@ Search.prototype = {
       this._matchBehavior = MATCH_ANYWHERE;
       for (let [query, params] of [ this._adaptiveQuery,
                                     this._searchQuery ]) {
         yield conn.executeCached(query, params, this._onResultRow.bind(this));
         if (!this.pending)
           return;
       }
     }
-
-    // If we still don't have enough results, fill the remaining space with
-    // search suggestions.
-    if (this._searchSuggestionController && this.pending) {
-      yield this._searchSuggestionController.fetchCompletePromise;
-      while (this.pending && this._maybeAddSearchSuggestionMatch());
-    }
   }),
 
   _matchKnownUrl: function* (conn, queries) {
     // Hosts have no "/" in them.
     let lastSlashIndex = this._searchString.lastIndexOf("/");
     // Search only URLs if there's a slash in the search string...
     if (lastSlashIndex != -1) {
       // ...but not if it's exactly at the end of the search string.
@@ -1169,53 +1125,22 @@ Search.prototype = {
     }
 
     // Use the special separator that the binding will use to style the item.
     match.style = "search " + match.style;
     match.comment = parseResult.terms + TITLE_SEARCH_ENGINE_SEPARATOR +
                     parseResult.engineName;
   },
 
-  _maybeAddSearchSuggestionMatch() {
-    if (this._searchSuggestionController) {
-      let [match, suggestion] = this._searchSuggestionController.consume();
-      if (suggestion) {
-        this._addSearchEngineMatch(match, this._originalSearchString,
-                                   suggestion);
-        return true;
-      }
-    }
-    return false;
-  },
-
   _addMatch: function (match) {
     // A search could be canceled between a query start and its completion,
     // in such a case ensure we won't notify any result for it.
     if (!this.pending)
       return;
 
-    // Mix in search suggestions.  Insert one suggestion every N non-suggestion
-    // matches that fall below the default frecency, and start inserting them as
-    // soon as they become available.  N = SEARCH_SUGGESTION_INSERT_INTERVAL.
-    if (match.frecency < FRECENCY_DEFAULT) {
-      if (this._searchSuggestionInsertCounter %
-          SEARCH_SUGGESTION_INSERT_INTERVAL == 0) {
-        // Search engine matches are created with FRECENCY_DEFAULT, so there's
-        // no danger of infinite indirect recursion.
-        if (this._maybeAddSearchSuggestionMatch()) {
-          if (!this.pending) {
-            return;
-          }
-          this._searchSuggestionInsertCounter++;
-        }
-      } else {
-        this._searchSuggestionInsertCounter++;
-      }
-    }
-
     let notifyResults = false;
 
     // Must check both id and url, cause keywords dinamically modify the url.
     let urlMapKey = stripHttpAndTrim(match.value);
     if ((!match.placeId || !this._usedPlaceIds.has(match.placeId)) &&
         !this._usedURLs.has(urlMapKey)) {
       // Add this to our internal tracker to ensure duplicates do not end up in
       // the result.
--- a/toolkit/components/places/mozIPlacesAutoComplete.idl
+++ b/toolkit/components/places/mozIPlacesAutoComplete.idl
@@ -8,17 +8,17 @@
 
 interface nsIURI;
 
 /**
  * This interface provides some constants used by the Places AutoComplete
  * search provider as well as methods to track opened pages for AutoComplete
  * purposes.
  */
-[scriptable, uuid(61b6348a-09e1-4810-8057-f8cb3cec6ef8)]
+[scriptable, uuid(6e252399-77f9-4f11-98cc-6fa9fab96f92)]
 interface mozIPlacesAutoComplete : nsISupports
 {
   //////////////////////////////////////////////////////////////////////////////
   //// Matching Constants
 
   /**
    * Match anywhere in each searchable term.
    */
@@ -98,21 +98,16 @@ interface mozIPlacesAutoComplete : nsISu
 
   /**
    * Use intersection between history, typed, bookmark, tag and openpage
    * instead of union, when the restrict bit is set.
    */
   const long BEHAVIOR_RESTRICT = 1 << 8;
 
   /**
-   * Include search suggestions from the currently selected search provider.
-   */
-  const long BEHAVIOR_SEARCHES = 1 << 9;
-
-  /**
    * Mark a page as being currently open.
    *
    * @note Pages will not be automatically unregistered when Private Browsing
    *       mode is entered or exited.  Therefore, consumers MUST unregister or
    *       register themselves.
    *
    * @param aURI
    *        The URI to register as an open page.