зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1647267 - Avoid calling getAddonByID during startup r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D80695
This commit is contained in:
Родитель
c9e1d68234
Коммит
06e65c95f0
|
@ -1294,6 +1294,12 @@ class ExtensionData {
|
|||
return null;
|
||||
}
|
||||
|
||||
// Returns true if an addon is builtin to Firefox or
|
||||
// distributed via Normandy into a system location.
|
||||
get isAppProvided() {
|
||||
return this.addonData.builtIn || this.addonData.isSystem;
|
||||
}
|
||||
|
||||
// Normalizes a Chrome-compatible locale code to the appropriate
|
||||
// Gecko-compatible variant. Currently, this means simply
|
||||
// replacing underscores with hyphens.
|
||||
|
|
|
@ -2340,8 +2340,7 @@ SearchService.prototype = {
|
|||
return this._upgradeExtensionEngine(extension);
|
||||
}
|
||||
|
||||
let addon = await AddonManager.getAddonByID(extension.id);
|
||||
if (addon.isBuiltin || addon.isSystem) {
|
||||
if (extension.isAppProvided) {
|
||||
let inConfig = this._searchOrder.filter(el => el.id == extension.id);
|
||||
if (gInitialized && inConfig.length) {
|
||||
return this._installExtensionEngine(
|
||||
|
@ -2377,7 +2376,7 @@ SearchService.prototype = {
|
|||
if (locale != SearchUtils.DEFAULT_TAG) {
|
||||
manifest = await extension.getLocalizedManifest(locale);
|
||||
}
|
||||
let params = await this.getEngineParams(extension, manifest, locale);
|
||||
let params = this.getEngineParams(extension, manifest, locale);
|
||||
engine._updateFromMetadata(params);
|
||||
}
|
||||
return engines;
|
||||
|
@ -2441,7 +2440,7 @@ SearchService.prototype = {
|
|||
manifest = await policy.extension.getLocalizedManifest(locale);
|
||||
}
|
||||
|
||||
let engineParams = await this.getEngineParams(
|
||||
let engineParams = this.getEngineParams(
|
||||
policy.extension,
|
||||
manifest,
|
||||
locale,
|
||||
|
@ -2518,13 +2517,13 @@ SearchService.prototype = {
|
|||
return engine;
|
||||
}
|
||||
}
|
||||
let params = await this.getEngineParams(extension, manifest, locale, {
|
||||
let params = this.getEngineParams(extension, manifest, locale, {
|
||||
initEngine,
|
||||
});
|
||||
return this.addEngineWithDetails(params.name, params, isReload);
|
||||
},
|
||||
|
||||
async getEngineParams(extension, manifest, locale, engineParams = {}) {
|
||||
getEngineParams(extension, manifest, locale, engineParams = {}) {
|
||||
let { IconDetails } = ExtensionParent;
|
||||
|
||||
// General set of icons for an engine.
|
||||
|
@ -2582,8 +2581,6 @@ SearchService.prototype = {
|
|||
"";
|
||||
let mozParams = engineParams.extraParams || searchProvider.params || [];
|
||||
|
||||
let addon = await AddonManager.getAddonByID(extension.id);
|
||||
let isAppProvided = addon.isBuiltin || addon.isSystem;
|
||||
let params = {
|
||||
name: searchProvider.name.trim(),
|
||||
shortName,
|
||||
|
@ -2599,7 +2596,7 @@ SearchService.prototype = {
|
|||
alias: searchProvider.keyword,
|
||||
extensionID: extension.id,
|
||||
locale,
|
||||
isAppProvided,
|
||||
isAppProvided: extension.isAppProvided,
|
||||
orderHint: engineParams.orderHint,
|
||||
// suggest_url doesn't currently get encoded.
|
||||
suggestURL: searchProvider.suggest_url,
|
||||
|
|
|
@ -1795,6 +1795,7 @@ class BootstrapScope {
|
|||
signedState: addon.signedState,
|
||||
temporarilyInstalled: addon.location.isTemporary,
|
||||
builtIn: addon.location.isBuiltin,
|
||||
isSystem: addon.location.isSystem,
|
||||
};
|
||||
|
||||
if (aMethod == "startup" && addon.startupData) {
|
||||
|
|
|
@ -39,6 +39,7 @@ add_task(async function test_builtin_location() {
|
|||
notEqual(addon, null, "Addon is installed");
|
||||
ok(addon.isActive, "Addon is active");
|
||||
ok(addon.isPrivileged, "Addon is privileged");
|
||||
ok(wrapper.extension.isAppProvided, "Addon is app provided");
|
||||
ok(!addon.hidden, "Addon is not hidden");
|
||||
|
||||
// Built-in extensions are not checked against the blocklist,
|
||||
|
@ -95,6 +96,7 @@ add_task(async function test_builtin_location_hidden() {
|
|||
notEqual(addon, null, "Addon is installed");
|
||||
ok(addon.isActive, "Addon is active");
|
||||
ok(addon.isPrivileged, "Addon is privileged");
|
||||
ok(wrapper.extension.isAppProvided, "Addon is app provided");
|
||||
ok(addon.hidden, "Addon is hidden");
|
||||
|
||||
await wrapper.unload();
|
||||
|
|
|
@ -57,6 +57,7 @@ add_task(async function test_system_profile_location() {
|
|||
notEqual(addon, null, "Addon is installed");
|
||||
ok(addon.isActive, "Addon is active");
|
||||
ok(addon.isPrivileged, "Addon is privileged");
|
||||
ok(wrapper.extension.isAppProvided, "Addon is app provided");
|
||||
ok(!addon.hidden, "Addon is not hidden");
|
||||
equal(
|
||||
addon.signedState,
|
||||
|
|
Загрузка…
Ссылка в новой задаче