Back out 471f236c32cb bug 959594 for bustage on a CLOSED TREE.

This commit is contained in:
Drew Willcoxon 2015-06-11 15:39:23 -07:00
parent 025b14f5f5
commit e510953036
6 changed files with 11 additions and 165 deletions

View File

@ -347,7 +347,6 @@ pref("browser.urlbar.match.url", "@");
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.

View File

@ -7189,18 +7189,15 @@ let gPrivateBrowsingUI = {
}
}
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);
}
}
};

View File

@ -327,7 +327,3 @@ 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);

View File

@ -17,9 +17,6 @@ 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 = {
@ -113,65 +110,10 @@ const SearchAutocompleteProviderInternal = {
}
},
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({
@ -272,12 +214,4 @@ this.PlacesSearchAutocompleteProvider = Object.freeze({
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);
},
});

View File

@ -35,7 +35,6 @@ 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.
@ -66,13 +65,6 @@ 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.
@ -352,15 +344,10 @@ XPCOMUtils.defineLazyGetter(this, "SwitchToTabStorage", () => Object.seal({
*/
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.
@ -369,7 +356,6 @@ XPCOMUtils.defineLazyGetter(this, "Prefs", () => {
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) {
@ -409,7 +395,6 @@ XPCOMUtils.defineLazyGetter(this, "Prefs", () => {
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) {
@ -581,7 +566,6 @@ function Search(searchString, searchParam, autocompleteListener,
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));
@ -615,8 +599,6 @@ function Search(searchString, searchParam, autocompleteListener,
// These are used to avoid adding duplicate entries to the results.
this._usedURLs = new Set();
this._usedPlaceIds = new Set();
this._searchSuggestionInsertCounter = 0;
}
Search.prototype = {
@ -722,10 +704,6 @@ Search.prototype = {
this._sleepDeferred.resolve();
this._sleepDeferred = null;
}
if (this._searchSuggestionController) {
this._searchSuggestionController.stop();
this._searchSuggestionController = null;
}
this.pending = false;
},
@ -828,22 +806,7 @@ Search.prototype = {
// 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;
@ -874,13 +837,6 @@ Search.prototype = {
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) {
@ -1174,43 +1130,12 @@ Search.prototype = {
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.

View File

@ -13,7 +13,7 @@ interface nsIURI;
* 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
{
//////////////////////////////////////////////////////////////////////////////
@ -102,11 +102,6 @@ interface mozIPlacesAutoComplete : nsISupports
*/
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.
*