Created
May 22, 2019 15:05
-
-
Save daleharvey/50d972ef7b903d2bd8f27bac4b1f740d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (AppConstants.platform == "android") { | |
let enginesFromURLs = await this._loadFromChromeURLs(engines, isReload); | |
enginesFromURLs.forEach(this._addEngineToStore, this); | |
} else { | |
for (let [id, locales] of engineLocales) { | |
await this._ensureEngine(id, locales); | |
} | |
} | |
async _ensureEngine(id, locales) { | |
SearchUtils.log("_ensureEngine " + id); | |
try { | |
let policy = WebExtensionPolicy.getByID(id); | |
if (!policy) { | |
SearchUtils.log("_loadEngines: Installing " + id); | |
let path = EXT_SEARCH_PREFIX + id.split("@")[0] + "/"; | |
await AddonManager.installBuiltinAddon(path); | |
// The AddonManager will install the engine asynchronously | |
// We can manually wait on that happening here. | |
await ExtensionParent.apiManager.global.pendingSearchSetupTasks.get(id); | |
policy = WebExtensionPolicy.getByID(id) | |
} | |
await policy.readyPromise; | |
await this._installExtensionEngine(policy.extension, locales); | |
SearchUtils.log("_ensureEngine: " + id + " installed."); | |
} catch (err) { | |
Cu.reportError("Failed to install engine: " + err.message + "\n" + err.stack); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment