зеркало из 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) {
|
set currentTheme(aData) {
|
||||||
|
_setCurrentTheme(aData, false);
|
||||||
|
},
|
||||||
|
|
||||||
|
setCurrentTheme(aData) {
|
||||||
return _setCurrentTheme(aData, false);
|
return _setCurrentTheme(aData, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -646,22 +650,21 @@ AddonWrapper.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
set userDisabled(val) {
|
set userDisabled(val) {
|
||||||
|
this.setUserDisabled(val);
|
||||||
|
},
|
||||||
|
|
||||||
|
async setUserDisabled(val) {
|
||||||
if (val == this.userDisabled)
|
if (val == this.userDisabled)
|
||||||
return val;
|
return;
|
||||||
|
|
||||||
if (val)
|
await LightweightThemeManager.setCurrentTheme(val ? null : themeFor(this));
|
||||||
LightweightThemeManager.currentTheme = null;
|
|
||||||
else
|
|
||||||
LightweightThemeManager.currentTheme = themeFor(this);
|
|
||||||
|
|
||||||
return val;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async enable() {
|
enable() {
|
||||||
this.userDisabled = false;
|
return this.setUserDisabled(false);
|
||||||
},
|
},
|
||||||
async disable() {
|
disable() {
|
||||||
this.userDisabled = true;
|
return this.setUserDisabled(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Lightweight themes are never disabled by the application
|
// Lightweight themes are never disabled by the application
|
||||||
|
@ -772,55 +775,57 @@ function _getExternalID(id) {
|
||||||
function _setCurrentTheme(aData, aLocal) {
|
function _setCurrentTheme(aData, aLocal) {
|
||||||
aData = _sanitizeTheme(aData, null, aLocal);
|
aData = _sanitizeTheme(aData, null, aLocal);
|
||||||
|
|
||||||
let cancel = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
|
return (async () => {
|
||||||
cancel.data = false;
|
let cancel = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
|
||||||
Services.obs.notifyObservers(cancel, "lightweight-theme-change-requested",
|
cancel.data = false;
|
||||||
JSON.stringify(aData));
|
Services.obs.notifyObservers(cancel, "lightweight-theme-change-requested",
|
||||||
|
JSON.stringify(aData));
|
||||||
|
|
||||||
let notify = true;
|
let notify = true;
|
||||||
|
|
||||||
if (aData) {
|
if (aData) {
|
||||||
let theme = LightweightThemeManager.getUsedTheme(aData.id);
|
let theme = LightweightThemeManager.getUsedTheme(aData.id);
|
||||||
let isInstall = !theme || theme.version != aData.version;
|
let isInstall = !theme || theme.version != aData.version;
|
||||||
if (isInstall) {
|
if (isInstall) {
|
||||||
aData.updateDate = Date.now();
|
aData.updateDate = Date.now();
|
||||||
if (theme && "installDate" in theme)
|
if (theme && "installDate" in theme)
|
||||||
aData.installDate = theme.installDate;
|
aData.installDate = theme.installDate;
|
||||||
else
|
else
|
||||||
aData.installDate = aData.updateDate;
|
aData.installDate = aData.updateDate;
|
||||||
|
|
||||||
var oldWrapper = theme ? new AddonWrapper(theme) : null;
|
var oldWrapper = theme ? new AddonWrapper(theme) : null;
|
||||||
var wrapper = new AddonWrapper(aData);
|
var wrapper = new AddonWrapper(aData);
|
||||||
AddonManagerPrivate.callInstallListeners("onExternalInstall", null,
|
AddonManagerPrivate.callInstallListeners("onExternalInstall", null,
|
||||||
wrapper, oldWrapper, false);
|
wrapper, oldWrapper, false);
|
||||||
AddonManagerPrivate.callAddonListeners("onInstalling", wrapper, 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;
|
|
||||||
}
|
}
|
||||||
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)
|
if (cancel.data)
|
||||||
AddonManagerPrivate.callAddonListeners("onInstalled", wrapper);
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
if (cancel.data)
|
if (notify) {
|
||||||
return null;
|
await AddonManagerPrivate.notifyAddonChanged(aData ? _getExternalID(aData.id) : null,
|
||||||
|
ADDON_TYPE, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (notify) {
|
return LightweightThemeManager.currentTheme;
|
||||||
AddonManagerPrivate.notifyAddonChanged(aData ? _getExternalID(aData.id) : null,
|
})();
|
||||||
ADDON_TYPE, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return LightweightThemeManager.currentTheme;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _sanitizeTheme(aData, aBaseURI, aLocal) {
|
function _sanitizeTheme(aData, aBaseURI, aLocal) {
|
||||||
|
@ -864,7 +869,7 @@ function _sanitizeTheme(aData, aBaseURI, aLocal) {
|
||||||
for (let mandatoryProperty of MANDATORY) {
|
for (let mandatoryProperty of MANDATORY) {
|
||||||
let val = sanitizeProperty(mandatoryProperty);
|
let val = sanitizeProperty(mandatoryProperty);
|
||||||
if (!val)
|
if (!val)
|
||||||
throw Cr.NS_ERROR_INVALID_ARG;
|
throw Components.Exception("Invalid argument", Cr.NS_ERROR_INVALID_ARG);
|
||||||
result[mandatoryProperty] = val;
|
result[mandatoryProperty] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1311,10 +1311,10 @@
|
||||||
|
|
||||||
// We must set userDisabled to true first, this will call
|
// We must set userDisabled to true first, this will call
|
||||||
// _updateState which will clear any pending attribute set.
|
// _updateState which will clear any pending attribute set.
|
||||||
this.mAddon.disable();
|
this.mAddon.disable().then(() => {
|
||||||
|
// This won't update any other add-on manager views (bug 582002)
|
||||||
// This won't update any other add-on manager views (bug 582002)
|
this.setAttribute("pending", "uninstall");
|
||||||
this.setAttribute("pending", "uninstall");
|
});
|
||||||
}
|
}
|
||||||
]]></body>
|
]]></body>
|
||||||
</method>
|
</method>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче