Bug 1344928 - Enable search suggestions by default in the Location Bar. r=past
Flip the default search suggestions in location bar prefs to true.
Users who didn't previously make a choice regarding the feature will see a hint explaining how to recognize suggestsions and
a link to change search settings.
Users who previously made an explicit choice won't see any hint and their choice will be respected on upgrade.
This doesn't make any guarantee regarding a downgrade/upgrade path and previous choices.
MozReview-Commit-ID: 7pGxwXDmKZO
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -313,17 +313,17 @@ pref("browser.urlbar.restrict.searches",
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", false);
+pref("browser.urlbar.suggest.searches", true);
pref("browser.urlbar.userMadeSearchSuggestionsChoice", false);
// The suggestion opt-in notification will be shown on 4 different days.
pref("browser.urlbar.daysBeforeHidingSuggestionsPrompt", 4);
pref("browser.urlbar.lastSuggestionsPromptDate", 20160601);
// The suggestion opt-out hint will be hidden after being shown 4 times.
pref("browser.urlbar.timesBeforeHidingSuggestionsHint", 4);
// Limit the number of characters sent to the current search engine to fetch
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -578,31 +578,16 @@ BrowserGlue.prototype = {
// apply distribution customizations
// prefs are applied in _onAppDefaults()
this._distributionCustomizer.applyCustomizations();
// handle any UI migration
this._migrateUI();
- // This is support code for the location bar search suggestions; passing
- // from opt-in to opt-out should respect the user's choice, thus we need
- // to cache that choice in a pref for future use.
- // Note: this is not in migrateUI because we need to uplift it. This
- // code is also short-lived, since we can remove it as soon as opt-out
- // search suggestions shipped in release (Bug 1344928).
- try {
- let urlbarPrefs = Services.prefs.getBranch("browser.urlbar.");
- if (!urlbarPrefs.prefHasUserValue("searchSuggestionsChoice") &&
- urlbarPrefs.getBoolPref("userMadeSearchSuggestionsChoice")) {
- urlbarPrefs.setBoolPref("searchSuggestionsChoice",
- urlbarPrefs.getBoolPref("suggest.searches"));
- }
- } catch (ex) { /* missing any of the prefs is not critical */ }
-
listeners.init();
PageThumbs.init();
DirectoryLinksProvider.init();
NewTabUtils.init();
NewTabUtils.links.addProvider(DirectoryLinksProvider);
AboutNewTab.init();
@@ -1688,17 +1673,17 @@ BrowserGlue.prototype = {
return;
this._openPreferences("sync", { origin: "doorhanger" });
}
AlertsService.showAlertNotification(null, title, body, true, null, clickCallback);
},
// eslint-disable-next-line complexity
_migrateUI: function BG__migrateUI() {
- const UI_VERSION = 45;
+ const UI_VERSION = 46;
const BROWSER_DOCURL = "chrome://browser/content/browser.xul";
let currentUIVersion;
if (Services.prefs.prefHasUserValue("browser.migration.version")) {
currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
} else {
// This is a new profile, nothing to migrate.
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
@@ -1991,16 +1976,32 @@ BrowserGlue.prototype = {
const LEGACY_PREF = "browser.shell.skipDefaultBrowserCheck";
if (Services.prefs.prefHasUserValue(LEGACY_PREF)) {
Services.prefs.setBoolPref("browser.shell.didSkipDefaultBrowserCheckOnFirstRun",
!Services.prefs.getBoolPref(LEGACY_PREF));
Services.prefs.clearUserPref(LEGACY_PREF);
}
}
+ if (currentUIVersion < 46) {
+ // Search suggestions are now on by default.
+ // For privacy reasons, we want to respect previously made user's choice
+ // regarding the feature, so if it's known reflect that choice into the
+ // current pref.
+ // Note that in case of downgrade/upgrade we won't guarantee anything.
+ try {
+ Services.prefs.setBoolPref(
+ "browser.urlbar.suggest.searches",
+ Services.prefs.getBoolPref("browser.urlbar.searchSuggestionsChoice")
+ );
+ } catch (ex) {
+ // The pref is not set, nothing to do.
+ }
+ }
+
// Update the migration version.
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
},
// ------------------------------
// public nsIBrowserGlue members
// ------------------------------