Bug 1867620 - Avoid updating the in-content search bar placeholders / text from multiple locations when in handoff mode. r=Mardak

Differential Revision: https://phabricator.services.mozilla.com/D195167
This commit is contained in:
Mark Banner 2023-12-12 21:15:25 +00:00
Родитель fa98d8f6d9
Коммит cee17a7223
6 изменённых файлов: 5 добавлений и 121 удалений

Просмотреть файл

@ -27,7 +27,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
ChromeUtils.defineESModuleGetters(lazy, {
SpecialMessageActions:
"resource://messaging-system/lib/SpecialMessageActions.sys.mjs",
UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs",
});
// We only show the private search banner once per browser session.
@ -119,16 +118,6 @@ export class AboutPrivateBrowsingParent extends JSWindowActorParent {
urlBar.addEventListener("paste", checkFirstChange);
break;
}
case "ShouldShowSearch": {
let engineName = Services.prefs.getStringPref(
"browser.urlbar.placeholderName.private",
""
);
let shouldHandOffToSearchMode = lazy.UrlbarPrefs.get(
"shouldHandOffToSearchMode"
);
return [engineName, shouldHandOffToSearchMode];
}
case "ShouldShowSearchBanner": {
// If this is a pre-loaded private browsing new tab, then we don't want
// to display the banner - it might never get displayed to the user

Просмотреть файл

@ -114,35 +114,6 @@ export class _Search extends React.PureComponent {
}
}
getDefaultEngineName() {
// _handoffSearchController will manage engine names once it is initialized.
return this.props.Prefs.values["urlbar.placeholderName"];
}
getHandoffInputL10nAttributes() {
let defaultEngineName = this.getDefaultEngineName();
return defaultEngineName
? {
"data-l10n-id": "newtab-search-box-handoff-input",
"data-l10n-args": `{"engine": "${defaultEngineName}"}`,
}
: {
"data-l10n-id": "newtab-search-box-handoff-input-no-engine",
};
}
getHandoffTextL10nAttributes() {
let defaultEngineName = this.getDefaultEngineName();
return defaultEngineName
? {
"data-l10n-id": "newtab-search-box-handoff-text",
"data-l10n-args": `{"engine": "${defaultEngineName}"}`,
}
: {
"data-l10n-id": "newtab-search-box-handoff-text-no-engine",
};
}
onSearchHandoffButtonMount(button) {
// Keep a reference to the button for use during "paste" event handling.
this._searchHandoffButton = button;
@ -191,15 +162,11 @@ export class _Search extends React.PureComponent {
<div className="search-inner-wrapper">
<button
className="search-handoff-button"
{...this.getHandoffInputL10nAttributes()}
ref={this.onSearchHandoffButtonMount}
onClick={this.onSearchHandoffClick}
tabIndex="-1"
>
<div
className="fake-textbox"
{...this.getHandoffTextL10nAttributes()}
/>
<div className="fake-textbox" />
<input
type="search"
className="fake-editable"

Просмотреть файл

@ -10717,8 +10717,6 @@ const NEWTAB_DARK_THEME = {
/* globals ContentSearchUIController, ContentSearchHandoffUIController */
function Search_extends() { Search_extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return Search_extends.apply(this, arguments); }
@ -10829,31 +10827,6 @@ class _Search extends (external_React_default()).PureComponent {
}
}
getDefaultEngineName() {
// _handoffSearchController will manage engine names once it is initialized.
return this.props.Prefs.values["urlbar.placeholderName"];
}
getHandoffInputL10nAttributes() {
let defaultEngineName = this.getDefaultEngineName();
return defaultEngineName ? {
"data-l10n-id": "newtab-search-box-handoff-input",
"data-l10n-args": `{"engine": "${defaultEngineName}"}`
} : {
"data-l10n-id": "newtab-search-box-handoff-input-no-engine"
};
}
getHandoffTextL10nAttributes() {
let defaultEngineName = this.getDefaultEngineName();
return defaultEngineName ? {
"data-l10n-id": "newtab-search-box-handoff-text",
"data-l10n-args": `{"engine": "${defaultEngineName}"}`
} : {
"data-l10n-id": "newtab-search-box-handoff-text-no-engine"
};
}
onSearchHandoffButtonMount(button) {
// Keep a reference to the button for use during "paste" event handling.
this._searchHandoffButton = button;
@ -10890,15 +10863,14 @@ class _Search extends (external_React_default()).PureComponent {
onClick: this.onSearchClick
})), this.props.handoffEnabled && /*#__PURE__*/external_React_default().createElement("div", {
className: "search-inner-wrapper"
}, /*#__PURE__*/external_React_default().createElement("button", Search_extends({
className: "search-handoff-button"
}, this.getHandoffInputL10nAttributes(), {
}, /*#__PURE__*/external_React_default().createElement("button", {
className: "search-handoff-button",
ref: this.onSearchHandoffButtonMount,
onClick: this.onSearchHandoffClick,
tabIndex: "-1"
}), /*#__PURE__*/external_React_default().createElement("div", Search_extends({
}, /*#__PURE__*/external_React_default().createElement("div", {
className: "fake-textbox"
}, this.getHandoffTextL10nAttributes())), /*#__PURE__*/external_React_default().createElement("input", {
}), /*#__PURE__*/external_React_default().createElement("input", {
type: "search",
className: "fake-editable",
tabIndex: "-1",

Просмотреть файл

@ -173,17 +173,6 @@ class PrefsFeed {
value: handoffToAwesomebarPrefValue,
});
// Read the pref for the cached default engine name from firefox.js and
// store it in our internal list of prefs to watch
let placeholderPrefValue = Services.prefs.getStringPref(
"browser.urlbar.placeholderName",
""
);
values["urlbar.placeholderName"] = placeholderPrefValue;
this._prefMap.set("urlbar.placeholderName", {
value: placeholderPrefValue,
});
// Add experiment values and default values
values.featureConfig = lazy.NimbusFeatures.newtab.getAllVariables() || {};
values.pocketConfig =

Просмотреть файл

@ -355,38 +355,6 @@ document.addEventListener("DOMContentLoaded", function () {
// Setup the search hand-off box.
let btn = document.getElementById("search-handoff-button");
RPMSendQuery("ShouldShowSearch", {}).then(
([engineName, shouldHandOffToSearchMode]) => {
let input = document.querySelector(".fake-textbox");
if (shouldHandOffToSearchMode) {
document.l10n.setAttributes(btn, "about-private-browsing-search-btn");
document.l10n.setAttributes(
input,
"about-private-browsing-search-placeholder"
);
} else if (engineName) {
document.l10n.setAttributes(btn, "about-private-browsing-handoff", {
engine: engineName,
});
document.l10n.setAttributes(
input,
"about-private-browsing-handoff-text",
{
engine: engineName,
}
);
} else {
document.l10n.setAttributes(
btn,
"about-private-browsing-handoff-no-engine"
);
document.l10n.setAttributes(
input,
"about-private-browsing-handoff-text-no-engine"
);
}
}
);
let editable = document.getElementById("fake-editable");
let DISABLE_SEARCH_TOPIC = "DisableSearch";

Просмотреть файл

@ -155,7 +155,6 @@ export let RemotePageAccessManager = {
],
RPMSendQuery: [
"IsPromoBlocked",
"ShouldShowSearch",
"ShouldShowSearchBanner",
"ShouldShowPromo",
"SpecialMessageActionDispatch",