Backed out changeset 48e95d0a923f (bug 1330349)

This commit is contained in:
Sebastian Hengst 2017-03-01 20:07:07 +01:00
Родитель 07d2724b5a
Коммит bf3a895666
3 изменённых файлов: 24 добавлений и 68 удалений

Просмотреть файл

@ -19,7 +19,6 @@ const PREF_LWTHEME_TO_SELECT = "extensions.lwThemeToSelect";
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
const PREF_EM_DSS_ENABLED = "extensions.dss.enabled";
const ADDON_TYPE = "theme";
const ADDON_TYPE_WEBEXT = "webextension-theme";
const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties";
@ -355,7 +354,7 @@ this.LightweightThemeManager = {
* restart
*/
addonChanged(aId, aType, aPendingRestart) {
if (aType != ADDON_TYPE && aType != ADDON_TYPE_WEBEXT)
if (aType != ADDON_TYPE)
return;
let id = _getInternalID(aId);

Просмотреть файл

@ -414,20 +414,6 @@ function isWebExtension(type) {
return type == "webextension" || type == "webextension-theme";
}
var gThemeAliases = null;
/**
* Helper function that determines whether an addon of a certain type is a
* theme.
*
* @param {String} type
* @return {Boolean}
*/
function isTheme(type) {
if (!gThemeAliases)
gThemeAliases = getAllAliasesForTypes(["theme"]);
return gThemeAliases.includes(type);
}
/**
* Sets permissions on a file
*
@ -1062,8 +1048,7 @@ var loadManifestFromWebManifest = Task.async(function*(aUri) {
}];
addon.targetPlatforms = [];
// Themes are disabled by default, except when they're installed from a web page.
addon.userDisabled = theme;
addon.userDisabled = false;
addon.softDisabled = addon.blocklistState == Blocklist.STATE_SOFTBLOCKED;
return addon;
@ -1325,7 +1310,7 @@ let loadManifestFromRDF = Task.async(function*(aUri, aStream) {
// A theme's userDisabled value is true if the theme is not the selected skin
// or if there is an active lightweight theme. We ignore whether softblocking
// is in effect since it would change the active theme.
if (isTheme(addon.type)) {
if (addon.type == "theme") {
addon.userDisabled = !!LightweightThemeManager.currentTheme ||
addon.internalName != XPIProvider.selectedSkin;
} else if (addon.type == "experiment") {
@ -4125,10 +4110,6 @@ this.XPIProvider = {
false);
AddonManagerPrivate.callAddonListeners("onInstalled", addon.wrapper);
// Notify providers that a new theme has been enabled.
if (isTheme(addon.type))
AddonManagerPrivate.notifyAddonChanged(addon.id, addon.type, false);
return addon.wrapper;
}),
@ -4292,7 +4273,7 @@ this.XPIProvider = {
*/
addonChanged(aId, aType, aPendingRestart) {
// We only care about themes in this provider
if (!isTheme(aType))
if (aType != "theme")
return;
if (!aId) {
@ -4305,19 +4286,14 @@ this.XPIProvider = {
// currently selected theme
let previousTheme = null;
let newSkin = this.defaultSkin;
let addons = XPIDatabase.getAddonsByType("theme", "webextension-theme");
let addons = XPIDatabase.getAddonsByType("theme");
for (let theme of addons) {
if (!theme.visible)
return;
let isChangedAddon = (theme.id == aId);
if (isWebExtension(theme.type)) {
if (!isChangedAddon)
this.updateAddonDisabledState(theme, true, undefined, aPendingRestart);
} else if (isChangedAddon) {
if (theme.id == aId)
newSkin = theme.internalName;
} else if (theme.userDisabled == false && !theme.pendingUninstall) {
else if (theme.userDisabled == false && !theme.pendingUninstall)
previousTheme = theme;
}
}
if (aPendingRestart) {
@ -4343,7 +4319,7 @@ this.XPIProvider = {
// Mark the previous theme as disabled. This won't cause recursion since
// only enabled calls notifyAddonChanged.
if (previousTheme)
this.updateAddonDisabledState(previousTheme, true, undefined, aPendingRestart);
this.updateAddonDisabledState(previousTheme, true);
},
/**
@ -4553,13 +4529,7 @@ this.XPIProvider = {
if (aAddon.active)
return false;
if (isTheme(aAddon.type)) {
if (isWebExtension(aAddon.type)) {
// Enabling a WebExtension type theme requires a restart ONLY when the
// theme-to-be-disabled requires a restart.
let theme = XPIDatabase.getVisibleAddonForInternalName(this.currentSkin);
return !theme || this.disableRequiresRestart(theme);
}
if (aAddon.type == "theme") {
// If dynamic theme switching is enabled then switching themes does not
// require a restart
if (Preferences.get(PREF_EM_DSS_ENABLED))
@ -4988,16 +4958,13 @@ this.XPIProvider = {
* @param aSoftDisabled
* Value for the softDisabled property. If undefined the value will
* not change. If true this will force userDisabled to be true
* @param aPendingRestart
* If the addon is updated whilst the disabled state of another non-
* restartless addon is also set, we need to carry that forward.
* @return a tri-state indicating the action taken for the add-on:
* - undefined: The add-on did not change state
* - true: The add-on because disabled
* - false: The add-on became enabled
* @throws if addon is not a DBAddonInternal
*/
updateAddonDisabledState(aAddon, aUserDisabled, aSoftDisabled, aPendingRestart = false) {
updateAddonDisabledState(aAddon, aUserDisabled, aSoftDisabled) {
if (!(aAddon.inDatabase))
throw new Error("Can only update addon states for installed addons.");
if (aUserDisabled !== undefined && aSoftDisabled !== undefined) {
@ -5059,7 +5026,7 @@ this.XPIProvider = {
AddonManagerPrivate.callAddonListeners("onOperationCancelled", wrapper);
} else {
if (isDisabled) {
var needsRestart = aPendingRestart || this.disableRequiresRestart(aAddon);
var needsRestart = this.disableRequiresRestart(aAddon);
AddonManagerPrivate.callAddonListeners("onDisabling", wrapper,
needsRestart);
} else {
@ -5116,7 +5083,7 @@ this.XPIProvider = {
}
// Notify any other providers that a new theme has been enabled
if (isTheme(aAddon.type) && !isDisabled)
if (aAddon.type == "theme" && !isDisabled)
AddonManagerPrivate.notifyAddonChanged(aAddon.id, aAddon.type, needsRestart);
return isDisabled;
@ -5264,7 +5231,7 @@ this.XPIProvider = {
}
// Notify any other providers that a new theme has been enabled
if (isTheme(aAddon.type) && aAddon.active)
if (aAddon.type == "theme" && aAddon.active)
AddonManagerPrivate.notifyAddonChanged(null, aAddon.type, requiresRestart);
},
@ -5303,7 +5270,7 @@ this.XPIProvider = {
}
// Notify any other providers that this theme is now enabled again.
if (isTheme(aAddon.type) && aAddon.active)
if (aAddon.type == "theme" && aAddon.active)
AddonManagerPrivate.notifyAddonChanged(aAddon.id, aAddon.type, false);
}
};
@ -5869,10 +5836,6 @@ class AddonInstall {
}
XPIProvider.setTelemetry(this.addon.id, "unpacked", installedUnpacked);
recordAddonTelemetry(this.addon);
// Notify providers that a new theme has been enabled.
if (isTheme(this.addon.type) && this.addon.active)
AddonManagerPrivate.notifyAddonChanged(this.addon.id, this.addon.type, requiresRestart);
}
}).bind(this)).then(null, (e) => {
logger.warn(`Failed to install ${this.file.path} from ${this.sourceURI.spec} to ${stagedAddon.path}`, e);
@ -7388,7 +7351,7 @@ AddonWrapper.prototype = {
return repositoryScreenshots;
}
if (isTheme(addon.type) && this.hasResource("preview.png")) {
if (addon.type == "theme" && this.hasResource("preview.png")) {
let url = this.getResourceURI("preview.png").spec;
return [new AddonManagerPrivate.AddonScreenshot(url)];
}
@ -7528,13 +7491,11 @@ AddonWrapper.prototype = {
}
if (addon.inDatabase) {
let theme = isTheme(addon.type)
if (theme && val) {
if (addon.type == "theme" && val) {
if (addon.internalName == XPIProvider.defaultSkin)
throw new Error("Cannot disable the default theme");
XPIProvider.enableDefaultTheme();
}
if (!(theme && val) || isWebExtension(addon.type)) {
} else {
// hidden and system add-ons should not be user disasbled,
// as there is no UI to re-enable them.
if (this.hidden) {
@ -7559,12 +7520,10 @@ AddonWrapper.prototype = {
if (addon.inDatabase) {
// When softDisabling a theme just enable the active theme
if (isTheme(addon.type) && val && !addon.userDisabled) {
if (addon.type == "theme" && val && !addon.userDisabled) {
if (addon.internalName == XPIProvider.defaultSkin)
throw new Error("Cannot disable the default theme");
XPIProvider.enableDefaultTheme();
if (isWebExtension(addon.type))
XPIProvider.updateAddonDisabledState(addon, undefined, val);
} else {
XPIProvider.updateAddonDisabledState(addon, undefined, val);
}

Просмотреть файл

@ -1133,24 +1133,22 @@ this.XPIDatabase = {
},
/**
* Synchronously gets all add-ons of a particular type(s).
* Synchronously gets all add-ons of a particular type.
*
* @param aType, aType2, ...
* The type(s) of add-on to retrieve
* @param aType
* The type of add-on to retrieve
* @return an array of DBAddonInternals
*/
getAddonsByType(...aTypes) {
getAddonsByType(aType) {
if (!this.addonDB) {
// jank-tastic! Must synchronously load DB if the theme switches from
// an XPI theme to a lightweight theme before the DB has loaded,
// because we're called from sync XPIProvider.addonChanged
logger.warn("Synchronous load of XPI database due to getAddonsByType([" +
aTypes.join(", ") + "])");
logger.warn("Synchronous load of XPI database due to getAddonsByType(" + aType + ")");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_lateOpen_byType", XPIProvider.runPhase);
this.syncLoadDB(true);
}
return _filterDB(this.addonDB, aAddon => aTypes.includes(aAddon.type));
return _filterDB(this.addonDB, aAddon => (aAddon.type == aType));
},
/**