diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-06-20 16:27:18 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-06-20 16:27:18 +0200 |
commit | 56ddb90de1000c4ed8e95019805fa93d38b94231 (patch) | |
tree | d9110248a2c1c83506108309d528f47d7c07e476 /application/palemoon/base/content/browser.js | |
parent | 856d0c991c097eff35ed098a1e30992c0f57165a (diff) | |
download | UXP-56ddb90de1000c4ed8e95019805fa93d38b94231.tar UXP-56ddb90de1000c4ed8e95019805fa93d38b94231.tar.gz UXP-56ddb90de1000c4ed8e95019805fa93d38b94231.tar.lz UXP-56ddb90de1000c4ed8e95019805fa93d38b94231.tar.xz UXP-56ddb90de1000c4ed8e95019805fa93d38b94231.zip |
Issue #517 Part 1: Fix newtab Search
Diffstat (limited to 'application/palemoon/base/content/browser.js')
-rw-r--r-- | application/palemoon/base/content/browser.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/application/palemoon/base/content/browser.js b/application/palemoon/base/content/browser.js index 6df6488b1..386bd418b 100644 --- a/application/palemoon/base/content/browser.js +++ b/application/palemoon/base/content/browser.js @@ -2400,6 +2400,9 @@ function PageProxyClickHandler(aEvent) * to the DOM for unprivileged pages. */ function BrowserOnAboutPageLoad(doc) { + + /* === about:home === */ + if (doc.documentURI.toLowerCase() == "about:home") { let ss = Components.classes["@mozilla.org/browser/sessionstore;1"]. getService(Components.interfaces.nsISessionStore); @@ -2438,6 +2441,32 @@ function BrowserOnAboutPageLoad(doc) { Services.obs.removeObserver(updateSearchEngine, "browser-search-engine-modified"); }, false); } + + /* === about:newtab === */ + + if (doc.documentURI.toLowerCase() == "about:newtab") { + + let docElt = doc.documentElement; + + function updateSearchEngine() { + let engine = AboutHomeUtils.defaultSearchEngine; + docElt.setAttribute("searchEngineName", engine.name); + docElt.setAttribute("searchEnginePostData", engine.postDataString || ""); + docElt.setAttribute("searchEngineURL", engine.searchURL); + } + updateSearchEngine(); + + // Listen for the event that's triggered when the user changes search engine. + // At this point we simply reload about:newtab to reflect the change. + Services.obs.addObserver(updateSearchEngine, "browser-search-engine-modified", false); + + // Remove the observer when the page is reloaded or closed. + doc.defaultView.addEventListener("pagehide", function removeObserver() { + doc.defaultView.removeEventListener("pagehide", removeObserver); + Services.obs.removeObserver(updateSearchEngine, "browser-search-engine-modified"); + }, false); + } + } /** |