diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-18 08:24:24 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-18 08:24:24 +0200 |
commit | fc61780b35af913801d72086456f493f63197da6 (patch) | |
tree | f85891288a7bd988da9f0f15ae64e5c63f00d493 /browser/components/newtab/NewTabSearchProvider.jsm | |
parent | 69f7f9e5f1475891ce11cc4f431692f965b0cd30 (diff) | |
parent | 50d3e596bbe89c95615f96eb71f6bc5be737a1db (diff) | |
download | UXP-fc61780b35af913801d72086456f493f63197da6.tar UXP-fc61780b35af913801d72086456f493f63197da6.tar.gz UXP-fc61780b35af913801d72086456f493f63197da6.tar.lz UXP-fc61780b35af913801d72086456f493f63197da6.tar.xz UXP-fc61780b35af913801d72086456f493f63197da6.zip |
Merge commit '50d3e596bbe89c95615f96eb71f6bc5be737a1db' into Basilisk-releasev2018.07.18
# Conflicts:
# browser/app/profile/firefox.js
# browser/components/preferences/jar.mn
Diffstat (limited to 'browser/components/newtab/NewTabSearchProvider.jsm')
-rw-r--r-- | browser/components/newtab/NewTabSearchProvider.jsm | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/browser/components/newtab/NewTabSearchProvider.jsm b/browser/components/newtab/NewTabSearchProvider.jsm deleted file mode 100644 index a50d8c706..000000000 --- a/browser/components/newtab/NewTabSearchProvider.jsm +++ /dev/null @@ -1,103 +0,0 @@ -/* global XPCOMUtils, ContentSearch, Task, Services, EventEmitter */ -/* exported NewTabSearchProvider */ - -"use strict"; - -this.EXPORTED_SYMBOLS = ["NewTabSearchProvider"]; - -const {utils: Cu, interfaces: Ci} = Components; -const CURRENT_ENGINE = "browser-search-engine-modified"; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Task.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "ContentSearch", - "resource:///modules/ContentSearch.jsm"); - -XPCOMUtils.defineLazyGetter(this, "EventEmitter", function() { - const {EventEmitter} = Cu.import("resource://devtools/shared/event-emitter.js", {}); - return EventEmitter; -}); - -function SearchProvider() { - EventEmitter.decorate(this); -} - -SearchProvider.prototype = { - - observe(subject, topic, data) { // jshint unused:false - // all other topics are not relevant to content searches and can be - // ignored by NewTabSearchProvider - if (data === "engine-current" && topic === CURRENT_ENGINE) { - Task.spawn(function* () { - try { - let state = yield ContentSearch.currentStateObj(true); - let engine = state.currentEngine; - this.emit(CURRENT_ENGINE, engine); - } catch (e) { - Cu.reportError(e); - } - }.bind(this)); - } - }, - - init() { - try { - Services.obs.addObserver(this, CURRENT_ENGINE, true); - } catch (e) { - Cu.reportError(e); - } - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, - Ci.nsISupportsWeakReference - ]), - - uninit() { - try { - Services.obs.removeObserver(this, CURRENT_ENGINE, true); - } catch (e) { - Cu.reportError(e); - } - }, - - get searchSuggestionUIStrings() { - return ContentSearch.searchSuggestionUIStrings; - }, - - removeFormHistory({browser}, suggestion) { - ContentSearch.removeFormHistoryEntry({target: browser}, suggestion); - }, - - manageEngines(browser) { - const browserWin = browser.ownerGlobal; - browserWin.openPreferences("paneSearch"); - }, - - asyncGetState: Task.async(function*() { - let state = yield ContentSearch.currentStateObj(true); - return state; - }), - - asyncPerformSearch: Task.async(function*({browser}, searchData) { - ContentSearch.performSearch({target: browser}, searchData); - yield ContentSearch.addFormHistoryEntry({target: browser}, searchData.searchString); - }), - - asyncCycleEngine: Task.async(function*(engineName) { - Services.search.currentEngine = Services.search.getEngineByName(engineName); - let state = yield ContentSearch.currentStateObj(true); - let newEngine = state.currentEngine; - this.emit(CURRENT_ENGINE, newEngine); - }), - - asyncGetSuggestions: Task.async(function*(engineName, searchString, target) { - let suggestions = ContentSearch.getSuggestions(engineName, searchString, target.browser); - return suggestions; - }), -}; - -const NewTabSearchProvider = { - search: new SearchProvider(), -}; |