diff --git a/browser/actors/AboutPrivateBrowsingParent.jsm b/browser/actors/AboutPrivateBrowsingParent.jsm
index 9639f5ecdf4a..b64655462bf7 100644
--- a/browser/actors/AboutPrivateBrowsingParent.jsm
+++ b/browser/actors/AboutPrivateBrowsingParent.jsm
@@ -57,14 +57,23 @@ class AboutPrivateBrowsingParent extends JSWindowActorParent {
break;
}
case "SearchHandoff": {
+ let searchAlias = "";
+ let searchEngine = Services.search.defaultPrivateEngine;
+ let searchAliases = searchEngine.aliases;
+ if (searchAliases && searchAliases.length) {
+ searchAlias = `${searchAliases[0]} `;
+ }
let urlBar = win.gURLBar;
let isFirstChange = true;
if (!aMessage.data || !aMessage.data.text) {
urlBar.setHiddenFocus();
} else {
- // Pass the provided text to the awesomebar
- urlBar.search(aMessage.data.text);
+ // Pass the provided text to the awesomebar. Prepend the @engine shortcut.
+ urlBar.search(`${searchAlias}${aMessage.data.text}`, {
+ searchEngine,
+ searchModeEntry: "handoff",
+ });
isFirstChange = false;
}
@@ -75,8 +84,11 @@ class AboutPrivateBrowsingParent extends JSWindowActorParent {
if (isFirstChange) {
isFirstChange = false;
urlBar.removeHiddenFocus();
- urlBar.search("");
- this.sendAsyncMessage("DisableSearch");
+ urlBar.search(searchAlias, {
+ searchEngine,
+ searchModeEntry: "handoff",
+ });
+ this.sendAsyncMessage("HideSearch");
urlBar.removeEventListener("compositionstart", checkFirstChange);
urlBar.removeEventListener("paste", checkFirstChange);
}
@@ -112,13 +124,6 @@ class AboutPrivateBrowsingParent extends JSWindowActorParent {
urlBar.addEventListener("paste", checkFirstChange);
break;
}
- case "ShouldShowSearch": {
- return new Promise(resolve => {
- Services.search.getDefaultPrivate().then(engine => {
- resolve(engine.isAppProvided ? engine.name : null);
- });
- });
- }
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
diff --git a/browser/components/newtab/common/Actions.jsm b/browser/components/newtab/common/Actions.jsm
index c7386fb91f20..558ad06a4197 100644
--- a/browser/components/newtab/common/Actions.jsm
+++ b/browser/components/newtab/common/Actions.jsm
@@ -43,7 +43,6 @@ for (const type of [
"DELETE_HISTORY_URL",
"DIALOG_CANCEL",
"DIALOG_OPEN",
- "DISABLE_SEARCH",
"DISCOVERY_STREAM_COLLECTION_DISMISSIBLE_TOGGLE",
"DISCOVERY_STREAM_CONFIG_CHANGE",
"DISCOVERY_STREAM_CONFIG_RESET",
@@ -77,6 +76,7 @@ for (const type of [
"FILL_SEARCH_TERM",
"HANDOFF_SEARCH_TO_AWESOMEBAR",
"HIDE_PRIVACY_INFO",
+ "HIDE_SEARCH",
"INIT",
"NEW_TAB_INIT",
"NEW_TAB_INITIAL_STATE",
diff --git a/browser/components/newtab/common/Reducers.jsm b/browser/components/newtab/common/Reducers.jsm
index f631c714f16f..cfb96a33c2aa 100644
--- a/browser/components/newtab/common/Reducers.jsm
+++ b/browser/components/newtab/common/Reducers.jsm
@@ -808,12 +808,12 @@ function DiscoveryStream(prevState = INITIAL_STATE.DiscoveryStream, action) {
function Search(prevState = INITIAL_STATE.Search, action) {
switch (action.type) {
- case at.DISABLE_SEARCH:
- return Object.assign({ ...prevState, disable: true });
+ case at.HIDE_SEARCH:
+ return Object.assign({ ...prevState, hide: true });
case at.FAKE_FOCUS_SEARCH:
return Object.assign({ ...prevState, fakeFocus: true });
case at.SHOW_SEARCH:
- return Object.assign({ ...prevState, disable: false, fakeFocus: false });
+ return Object.assign({ ...prevState, hide: false, fakeFocus: false });
default:
return prevState;
}
diff --git a/browser/components/newtab/content-src/components/Search/Search.jsx b/browser/components/newtab/content-src/components/Search/Search.jsx
index 26758857d925..6274280b880d 100644
--- a/browser/components/newtab/content-src/components/Search/Search.jsx
+++ b/browser/components/newtab/content-src/components/Search/Search.jsx
@@ -42,7 +42,7 @@ export class _Search extends React.PureComponent {
this.props.dispatch({ type: at.FAKE_FOCUS_SEARCH });
this.props.dispatch(ac.UserEvent({ event: "SEARCH_HANDOFF" }));
if (text) {
- this.props.dispatch({ type: at.DISABLE_SEARCH });
+ this.props.dispatch({ type: at.HIDE_SEARCH });
}
}
@@ -106,41 +106,12 @@ export class _Search extends React.PureComponent {
onInputMountHandoff(input) {
if (input) {
- // The handoff UI controller helps us set the search icon and reacts to
+ // The handoff UI controller helps usset the search icon and reacts to
// changes to default engine to keep everything in sync.
this._handoffSearchController = new ContentSearchHandoffUIController();
}
}
- 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;
@@ -154,7 +125,7 @@ export class _Search extends React.PureComponent {
render() {
const wrapperClassName = [
"search-wrapper",
- this.props.disable && "search-disabled",
+ this.props.hide && "search-hidden",
this.props.fakeFocus && "fake-focus",
]
.filter(v => v)
@@ -196,14 +167,22 @@ export class _Search extends React.PureComponent {
-