зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1487525: Don't reset pending uninstall attribute when disabling theme. r=aswan
Differential Revision: https://phabricator.services.mozilla.com/D5218 --HG-- extra : rebase_source : 028ead3610377c920e29e964fcf29f4d4209ee5d extra : source : a4e3bfaefca5764612e436d1e900ca9fa0620bf8
This commit is contained in:
Родитель
e829874703
Коммит
8f0efbd799
|
@ -170,6 +170,10 @@ var LightweightThemeManager = {
|
|||
},
|
||||
|
||||
set currentTheme(aData) {
|
||||
_setCurrentTheme(aData, false);
|
||||
},
|
||||
|
||||
setCurrentTheme(aData) {
|
||||
return _setCurrentTheme(aData, false);
|
||||
},
|
||||
|
||||
|
@ -646,22 +650,21 @@ AddonWrapper.prototype = {
|
|||
},
|
||||
|
||||
set userDisabled(val) {
|
||||
this.setUserDisabled(val);
|
||||
},
|
||||
|
||||
async setUserDisabled(val) {
|
||||
if (val == this.userDisabled)
|
||||
return val;
|
||||
return;
|
||||
|
||||
if (val)
|
||||
LightweightThemeManager.currentTheme = null;
|
||||
else
|
||||
LightweightThemeManager.currentTheme = themeFor(this);
|
||||
|
||||
return val;
|
||||
await LightweightThemeManager.setCurrentTheme(val ? null : themeFor(this));
|
||||
},
|
||||
|
||||
async enable() {
|
||||
this.userDisabled = false;
|
||||
enable() {
|
||||
return this.setUserDisabled(false);
|
||||
},
|
||||
async disable() {
|
||||
this.userDisabled = true;
|
||||
disable() {
|
||||
return this.setUserDisabled(true);
|
||||
},
|
||||
|
||||
// Lightweight themes are never disabled by the application
|
||||
|
@ -772,55 +775,57 @@ function _getExternalID(id) {
|
|||
function _setCurrentTheme(aData, aLocal) {
|
||||
aData = _sanitizeTheme(aData, null, aLocal);
|
||||
|
||||
let cancel = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
|
||||
cancel.data = false;
|
||||
Services.obs.notifyObservers(cancel, "lightweight-theme-change-requested",
|
||||
JSON.stringify(aData));
|
||||
return (async () => {
|
||||
let cancel = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
|
||||
cancel.data = false;
|
||||
Services.obs.notifyObservers(cancel, "lightweight-theme-change-requested",
|
||||
JSON.stringify(aData));
|
||||
|
||||
let notify = true;
|
||||
let notify = true;
|
||||
|
||||
if (aData) {
|
||||
let theme = LightweightThemeManager.getUsedTheme(aData.id);
|
||||
let isInstall = !theme || theme.version != aData.version;
|
||||
if (isInstall) {
|
||||
aData.updateDate = Date.now();
|
||||
if (theme && "installDate" in theme)
|
||||
aData.installDate = theme.installDate;
|
||||
else
|
||||
aData.installDate = aData.updateDate;
|
||||
if (aData) {
|
||||
let theme = LightweightThemeManager.getUsedTheme(aData.id);
|
||||
let isInstall = !theme || theme.version != aData.version;
|
||||
if (isInstall) {
|
||||
aData.updateDate = Date.now();
|
||||
if (theme && "installDate" in theme)
|
||||
aData.installDate = theme.installDate;
|
||||
else
|
||||
aData.installDate = aData.updateDate;
|
||||
|
||||
var oldWrapper = theme ? new AddonWrapper(theme) : null;
|
||||
var wrapper = new AddonWrapper(aData);
|
||||
AddonManagerPrivate.callInstallListeners("onExternalInstall", null,
|
||||
wrapper, oldWrapper, false);
|
||||
AddonManagerPrivate.callAddonListeners("onInstalling", wrapper, false);
|
||||
}
|
||||
|
||||
let current = LightweightThemeManager.currentTheme;
|
||||
let usedThemes = _usedThemesExceptId(aData.id);
|
||||
if (current && current.id != aData.id) {
|
||||
usedThemes.splice(1, 0, aData);
|
||||
} else {
|
||||
if (current && current.id == aData.id) {
|
||||
notify = false;
|
||||
var oldWrapper = theme ? new AddonWrapper(theme) : null;
|
||||
var wrapper = new AddonWrapper(aData);
|
||||
AddonManagerPrivate.callInstallListeners("onExternalInstall", null,
|
||||
wrapper, oldWrapper, false);
|
||||
AddonManagerPrivate.callAddonListeners("onInstalling", wrapper, false);
|
||||
}
|
||||
usedThemes.unshift(aData);
|
||||
|
||||
let current = LightweightThemeManager.currentTheme;
|
||||
let usedThemes = _usedThemesExceptId(aData.id);
|
||||
if (current && current.id != aData.id) {
|
||||
usedThemes.splice(1, 0, aData);
|
||||
} else {
|
||||
if (current && current.id == aData.id) {
|
||||
notify = false;
|
||||
}
|
||||
usedThemes.unshift(aData);
|
||||
}
|
||||
_updateUsedThemes(usedThemes);
|
||||
|
||||
if (isInstall)
|
||||
AddonManagerPrivate.callAddonListeners("onInstalled", wrapper);
|
||||
}
|
||||
_updateUsedThemes(usedThemes);
|
||||
|
||||
if (isInstall)
|
||||
AddonManagerPrivate.callAddonListeners("onInstalled", wrapper);
|
||||
}
|
||||
if (cancel.data)
|
||||
return null;
|
||||
|
||||
if (cancel.data)
|
||||
return null;
|
||||
if (notify) {
|
||||
await AddonManagerPrivate.notifyAddonChanged(aData ? _getExternalID(aData.id) : null,
|
||||
ADDON_TYPE, false);
|
||||
}
|
||||
|
||||
if (notify) {
|
||||
AddonManagerPrivate.notifyAddonChanged(aData ? _getExternalID(aData.id) : null,
|
||||
ADDON_TYPE, false);
|
||||
}
|
||||
|
||||
return LightweightThemeManager.currentTheme;
|
||||
return LightweightThemeManager.currentTheme;
|
||||
})();
|
||||
}
|
||||
|
||||
function _sanitizeTheme(aData, aBaseURI, aLocal) {
|
||||
|
@ -864,7 +869,7 @@ function _sanitizeTheme(aData, aBaseURI, aLocal) {
|
|||
for (let mandatoryProperty of MANDATORY) {
|
||||
let val = sanitizeProperty(mandatoryProperty);
|
||||
if (!val)
|
||||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
throw Components.Exception("Invalid argument", Cr.NS_ERROR_INVALID_ARG);
|
||||
result[mandatoryProperty] = val;
|
||||
}
|
||||
|
||||
|
|
|
@ -1311,10 +1311,10 @@
|
|||
|
||||
// We must set userDisabled to true first, this will call
|
||||
// _updateState which will clear any pending attribute set.
|
||||
this.mAddon.disable();
|
||||
|
||||
// This won't update any other add-on manager views (bug 582002)
|
||||
this.setAttribute("pending", "uninstall");
|
||||
this.mAddon.disable().then(() => {
|
||||
// This won't update any other add-on manager views (bug 582002)
|
||||
this.setAttribute("pending", "uninstall");
|
||||
});
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
|
Загрузка…
Ссылка в новой задаче