Bug 1893069 - Add 'browser.urlbar.scotchBonnet.enableOverride' pref. r=adw

Differential Revision: https://phabricator.services.mozilla.com/D210374
This commit is contained in:
Dale Harvey 2024-05-27 21:56:56 +00:00
parent 32e1cf70a0
commit 33ece54a86
12 changed files with 44 additions and 18 deletions

View File

@ -420,7 +420,7 @@ pref("browser.urlbar.suggest.engines", true);
pref("browser.urlbar.suggest.calculator", false);
pref("browser.urlbar.suggest.recentsearches", true);
pref("browser.urlbar.secondaryActions.featureGate", false);
pref("browser.urlbar.scotchBonnet.enableOverride", false);
#if defined(EARLY_BETA_OR_EARLIER)
// Enable Trending suggestions.
@ -615,7 +615,7 @@ pref("browser.urlbar.merino.providers", "");
pref("browser.urlbar.merino.clientVariants", "");
// Enable site specific search result.
pref("browser.urlbar.contextualSearch.enabled", false);
pref("browser.urlbar.contextualSearch.enabled", true);
// Feature gate pref for addon suggestions in the urlbar.
pref("browser.urlbar.addons.featureGate", true);

View File

@ -38,7 +38,7 @@ class ProviderContextualSearch extends ActionsProvider {
isActive(queryContext) {
return (
queryContext.trimmedSearchString &&
lazy.UrlbarPrefs.get(ENABLED_PREF) &&
lazy.UrlbarPrefs.getScotchBonnetPref(ENABLED_PREF) &&
!queryContext.searchMode
);
}

View File

@ -29,7 +29,7 @@ class ProviderQuickActions extends ActionsProvider {
isActive(queryContext) {
return (
lazy.UrlbarPrefs.get(ENABLED_PREF) &&
lazy.UrlbarPrefs.getScotchBonnetPref(ENABLED_PREF) &&
!queryContext.searchMode &&
queryContext.trimmedSearchString.length < 50 &&
queryContext.trimmedSearchString.length >

View File

@ -1092,7 +1092,9 @@ export class UrlbarInput {
// and button is provided to switch to tab.
if (
this.hasAttribute("action-override") ||
(lazy.UrlbarPrefs.get("secondaryActions.featureGate") &&
(lazy.UrlbarPrefs.getScotchBonnetPref(
"secondaryActions.featureGate"
) &&
element?.dataset.action !== "tabswitch")
) {
where = "current";

View File

@ -319,6 +319,13 @@ const PREF_URLBAR_DEFAULTS = new Map([
// If true, we show tail suggestions when available.
["richSuggestions.tail", true],
// Disable the urlbar OneOff panel from being shown.
["scotchBonnet.disableOneOffs", false],
// A short-circuit pref to enable all the features that are part of a
// grouped release.
["scotchBonnet.enableOverride", false],
// Hidden pref. Disables checks that prevent search tips being shown, thus
// showing them every time the newtab page or the default search engine
// homepage is opened.
@ -788,6 +795,19 @@ class Preferences {
return makeResultGroups(options);
}
/**
* Gets a pref but allows the `scotchBonnet.enableOverride` pref to
* short circuit them so one pref can be used to enable multiple
* features.
*
* @param {string} pref
* The name of the preference to clear.
* @returns {*} The preference value.
*/
getScotchBonnetPref(pref) {
return this.get("scotchBonnet.enableOverride") || this.get(pref);
}
get resultGroups() {
if (!this.#resultGroups) {
this.#resultGroups = makeResultGroups({

View File

@ -153,7 +153,9 @@ class ProviderInputHistory extends UrlbarProvider {
userContextId: row.getResultByName("userContextId") || 0,
}
);
if (lazy.UrlbarPrefs.get("secondaryActions.featureGate")) {
if (
lazy.UrlbarPrefs.getScotchBonnetPref("secondaryActions.featureGate")
) {
payload[0].action = {
key: "tabswitch",
l10nId: "urlbar-result-action-switch-tab",

View File

@ -337,7 +337,9 @@ function makeUrlbarResult(tokens, info) {
icon: info.icon,
userContextId: info.userContextId,
});
if (lazy.UrlbarPrefs.get("secondaryActions.featureGate")) {
if (
lazy.UrlbarPrefs.getScotchBonnetPref("secondaryActions.featureGate")
) {
payload[0].action = {
key: "tabswitch",
l10nId: "urlbar-result-action-switch-tab",

View File

@ -321,7 +321,9 @@ class ProvidersManager {
// All current global actions are currently memory lookups so it is safe to
// wait on them.
this.#globalAction = lazy.UrlbarPrefs.get("secondaryActions.featureGate")
this.#globalAction = lazy.UrlbarPrefs.getScotchBonnetPref(
"secondaryActions.featureGate"
)
? await this.pickGlobalAction(queryContext, controller)
: null;

View File

@ -64,6 +64,9 @@ export class UrlbarSearchOneOffs extends SearchOneOffs {
* True to enable, false to disable.
*/
enable(enable) {
if (lazy.UrlbarPrefs.getScotchBonnetPref("scotchBonnet.disableOneOffs")) {
enable = false;
}
if (enable) {
this.telemetryOrigin = "urlbar";
this.style.display = "";

View File

@ -1860,7 +1860,9 @@ export class UrlbarView {
switch (result.type) {
case lazy.UrlbarUtils.RESULT_TYPE.TAB_SWITCH:
// Hide chichlet when showing secondaryActions.
if (lazy.UrlbarPrefs.get("secondaryActions.featureGate")) {
if (
lazy.UrlbarPrefs.getScotchBonnetPref("secondaryActions.featureGate")
) {
break;
}
actionSetter = () => {

View File

@ -13,10 +13,7 @@ const { AddonTestUtils } = ChromeUtils.importESModule(
add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.contextualSearch.enabled", true],
["browser.urlbar.secondaryActions.featureGate", true],
],
set: [["browser.urlbar.scotchBonnet.enableOverride", true]],
});
let ext = await SearchTestUtils.installSearchExtension({

View File

@ -22,11 +22,7 @@ let loadURI = async (browser, uri) => {
add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.quickactions.enabled", true],
["browser.urlbar.secondaryActions.featureGate", true],
["browser.urlbar.contextualSearch.enabled", true],
],
set: [["browser.urlbar.scotchBonnet.enableOverride", true]],
});
ActionsProviderQuickActions.addAction("testaction", {