diff --git a/browser/base/content/contentSearchHandoffUI.js b/browser/base/content/contentSearchHandoffUI.js deleted file mode 100644 index c1d9537ef706..000000000000 --- a/browser/base/content/contentSearchHandoffUI.js +++ /dev/null @@ -1,79 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -function ContentSearchHandoffUIController() { - this._isPrivateWindow = false; - this._engineIcon = null; - - window.addEventListener("ContentSearchService", this); - this._sendMsg("GetEngine"); -} - -ContentSearchHandoffUIController.prototype = { - handleEvent(event) { - let methodName = "_onMsg" + event.detail.type; - if (methodName in this) { - this[methodName](event.detail.data); - } - }, - - _onMsgEngine({ isPrivateWindow, engine }) { - this._isPrivateWindow = isPrivateWindow; - this._updateEngineIcon(engine); - }, - - _onMsgCurrentEngine(engine) { - if (!this._isPrivateWindow) { - this._updateEngineIcon(engine); - } - }, - - _onMsgCurrentPrivateEngine(engine) { - if (this._isPrivateWindow) { - this._updateEngineIcon(engine); - } - }, - - _updateEngineIcon(engine) { - if (this._engineIcon) { - URL.revokeObjectURL(this._engineIcon); - } - - if (engine.iconData) { - this._engineIcon = this._getFaviconURIFromIconData(engine.iconData); - } else { - this._engineIcon = "chrome://mozapps/skin/places/defaultFavicon.svg"; - } - - document.body.style.setProperty( - "--newtab-search-icon", - "url(" + this._engineIcon + ")" - ); - }, - - // If the favicon is an array buffer, convert it into a Blob URI. - // Otherwise just return the plain URI. - _getFaviconURIFromIconData(data) { - if (typeof data === "string") { - return data; - } - - // If typeof(data) != "string", we assume it's an ArrayBuffer - let blob = new Blob([data]); - return URL.createObjectURL(blob); - }, - - _sendMsg(type, data = null) { - dispatchEvent( - new CustomEvent("ContentSearchClient", { - detail: { - type, - data, - }, - }) - ); - }, -}; diff --git a/browser/base/jar.mn b/browser/base/jar.mn index 9b203f743523..c68a9bd66a3f 100644 --- a/browser/base/jar.mn +++ b/browser/base/jar.mn @@ -94,7 +94,6 @@ browser.jar: content/browser/sanitizeDialog.js (content/sanitizeDialog.js) content/browser/sanitizeDialog.css (content/sanitizeDialog.css) content/browser/contentSearchUI.js (content/contentSearchUI.js) - content/browser/contentSearchHandoffUI.js (content/contentSearchHandoffUI.js) content/browser/contentSearchUI.css (content/contentSearchUI.css) content/browser/tabbrowser.css (content/tabbrowser.css) content/browser/tabbrowser.js (content/tabbrowser.js) diff --git a/browser/components/newtab/bin/render-activity-stream-html.js b/browser/components/newtab/bin/render-activity-stream-html.js index 3fc12f120520..dd00ab6802e6 100644 --- a/browser/components/newtab/bin/render-activity-stream-html.js +++ b/browser/components/newtab/bin/render-activity-stream-html.js @@ -28,7 +28,6 @@ function templateHTML(options) { const debugString = options.debug ? "-dev" : ""; const scripts = [ "chrome://browser/content/contentSearchUI.js", - "chrome://browser/content/contentSearchHandoffUI.js", "chrome://browser/content/contentTheme.js", `${options.baseUrl}vendor/react${debugString}.js`, `${options.baseUrl}vendor/react-dom${debugString}.js`, diff --git a/browser/components/newtab/content-src/components/Search/Search.jsx b/browser/components/newtab/content-src/components/Search/Search.jsx index e608f14a093a..3c42c14b04af 100644 --- a/browser/components/newtab/content-src/components/Search/Search.jsx +++ b/browser/components/newtab/content-src/components/Search/Search.jsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* globals ContentSearchUIController, ContentSearchHandoffUIController */ +/* globals ContentSearchUIController */ "use strict"; import { actionCreators as ac, actionTypes as at } from "common/Actions.jsm"; @@ -18,7 +18,6 @@ export class _Search extends React.PureComponent { this.onSearchHandoffPaste = this.onSearchHandoffPaste.bind(this); this.onSearchHandoffDrop = this.onSearchHandoffDrop.bind(this); this.onInputMount = this.onInputMount.bind(this); - this.onInputMountHandoff = this.onInputMountHandoff.bind(this); this.onSearchHandoffButtonMount = this.onSearchHandoffButtonMount.bind( this ); @@ -104,14 +103,6 @@ export class _Search extends React.PureComponent { } } - onInputMountHandoff(input) { - if (input) { - // 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(); - } - } - onSearchHandoffButtonMount(button) { // Keep a reference to the button for use during "paste" event handling. this._searchHandoffButton = button; @@ -176,10 +167,18 @@ export class _Search extends React.PureComponent { aria-hidden="true" onDrop={this.onSearchHandoffDrop} onPaste={this.onSearchHandoffPaste} - ref={this.onInputMountHandoff} />
+ {/* + This dummy and hidden input below is so we can load ContentSearchUIController. + Why? It sets --newtab-search-icon for us and it isn't trivial to port over. + */} +
)} diff --git a/browser/components/newtab/data/content/activity-stream.bundle.js b/browser/components/newtab/data/content/activity-stream.bundle.js index a74ece890a2c..b9f6b8fc9949 100644 --- a/browser/components/newtab/data/content/activity-stream.bundle.js +++ b/browser/components/newtab/data/content/activity-stream.bundle.js @@ -10286,7 +10286,7 @@ __webpack_require__.r(__webpack_exports__); * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* globals ContentSearchUIController, ContentSearchHandoffUIController */ +/* globals ContentSearchUIController */ @@ -10301,7 +10301,6 @@ class _Search extends react__WEBPACK_IMPORTED_MODULE_3___default.a.PureComponent this.onSearchHandoffPaste = this.onSearchHandoffPaste.bind(this); this.onSearchHandoffDrop = this.onSearchHandoffDrop.bind(this); this.onInputMount = this.onInputMount.bind(this); - this.onInputMountHandoff = this.onInputMountHandoff.bind(this); this.onSearchHandoffButtonMount = this.onSearchHandoffButtonMount.bind(this); } @@ -10391,14 +10390,6 @@ class _Search extends react__WEBPACK_IMPORTED_MODULE_3___default.a.PureComponent } } - onInputMountHandoff(input) { - if (input) { - // 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(); - } - } - onSearchHandoffButtonMount(button) { // Keep a reference to the button for use during "paste" event handling. this._searchHandoffButton = button; @@ -10450,11 +10441,16 @@ class _Search extends react__WEBPACK_IMPORTED_MODULE_3___default.a.PureComponent tabIndex: "-1", "aria-hidden": "true", onDrop: this.onSearchHandoffDrop, - onPaste: this.onSearchHandoffPaste, - ref: this.onInputMountHandoff + onPaste: this.onSearchHandoffPaste }), react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("div", { className: "fake-caret" - })))); + })), react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("input", { + type: "search", + style: { + display: "none" + }, + ref: this.onInputMount + }))); } } diff --git a/browser/components/newtab/prerendered/activity-stream-debug.html b/browser/components/newtab/prerendered/activity-stream-debug.html index 2b77051c47ca..4df92591eebd 100644 --- a/browser/components/newtab/prerendered/activity-stream-debug.html +++ b/browser/components/newtab/prerendered/activity-stream-debug.html @@ -20,7 +20,6 @@
- diff --git a/browser/components/newtab/prerendered/activity-stream.html b/browser/components/newtab/prerendered/activity-stream.html index 9ca635dda1b4..62c26f17c06c 100644 --- a/browser/components/newtab/prerendered/activity-stream.html +++ b/browser/components/newtab/prerendered/activity-stream.html @@ -20,7 +20,6 @@
- diff --git a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js index 8d4661b1bc14..a104ace1b35d 100644 --- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js +++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js @@ -118,5 +118,14 @@ document.addEventListener("DOMContentLoaded", function() { }); // Load contentSearchUI so it sets the search engine icon for us. - new window.ContentSearchHandoffUIController(); + // TODO: FIXME. We should eventually refector contentSearchUI to do only what + // we need and have it do the common search handoff work for + // about:newtab and about:privatebrowsing. + let input = document.getElementById("dummy-input"); + new window.ContentSearchUIController( + input, + input.parentNode, + "aboutprivatebrowsing", + "aboutprivatebrowsing" + ); }); diff --git a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml index ceda47dba44c..20059d1216a0 100644 --- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml +++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml @@ -15,7 +15,7 @@ - + @@ -50,6 +50,7 @@
+

diff --git a/browser/modules/ContentSearch.jsm b/browser/modules/ContentSearch.jsm index ba750ad4523f..20fabcd850b0 100644 --- a/browser/modules/ContentSearch.jsm +++ b/browser/modules/ContentSearch.jsm @@ -453,17 +453,6 @@ var ContentSearch = { }); }, - _onMessageGetEngine(msg, data) { - return this.currentStateObj(msg.target.ownerGlobal).then(state => { - this._reply(msg, "Engine", { - isPrivateWindow: state.isPrivateWindow, - engine: state.isPrivateWindow - ? state.currentPrivateEngine - : state.currentEngine, - }); - }); - }, - _onMessageGetStrings(msg, data) { this._reply(msg, "Strings", this.searchSuggestionUIStrings); }, diff --git a/browser/themes/shared/privatebrowsing/aboutPrivateBrowsing.css b/browser/themes/shared/privatebrowsing/aboutPrivateBrowsing.css index 03183112946a..ffced8b63445 100644 --- a/browser/themes/shared/privatebrowsing/aboutPrivateBrowsing.css +++ b/browser/themes/shared/privatebrowsing/aboutPrivateBrowsing.css @@ -163,6 +163,10 @@ p { width: 1px; } +.dummy-input { + display: none; +} + .search-banner { width: 100%; background-color: var(--in-content-banner-background);