Bug 1448221: Part 2 - Remove support for non-default legacy themes. r=aswan

MozReview-Commit-ID: 1v0aGG3mv3U

--HG--
extra : rebase_source : 59deb737dbb812037f4a015404bec0af6a19f9c9
This commit is contained in:
Kris Maglione 2018-03-26 16:19:04 -07:00
Родитель 68918bd958
Коммит 99ebf2e65e
9 изменённых файлов: 41 добавлений и 210 удалений

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

@ -190,9 +190,6 @@ pref("extensions.update.url", "https://versioncheck.addons.mozilla.org/update/Ve
pref("extensions.update.background.url", "https://versioncheck-bg.addons.mozilla.org/update/VersionCheck.php?reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxAppVersion=%ITEM_MAXAPPVERSION%&status=%ITEM_STATUS%&appID=%APP_ID%&appVersion=%APP_VERSION%&appOS=%APP_OS%&appABI=%APP_ABI%&locale=%APP_LOCALE%&currentAppVersion=%CURRENT_APP_VERSION%&updateType=%UPDATE_TYPE%&compatMode=%COMPATIBILITY_MODE%");
pref("extensions.update.interval", 86400); // Check for updates to Extensions and
// Themes every day
// Non-symmetric (not shared by extensions) extension-specific [update] preferences
pref("extensions.dss.switchPending", false); // Non-dynamic switch pending after next
// restart.
pref("extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.name", "chrome://browser/locale/browser.properties");
pref("extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.description", "chrome://browser/locale/browser.properties");
@ -222,8 +219,6 @@ pref("browser.uitour.surveyDuration", 7200);
pref("keyword.enabled", true);
pref("browser.fixup.domainwhitelist.localhost", true);
pref("general.skins.selectedSkin", "classic/1.0");
pref("general.smoothScroll", true);
#ifdef UNIX_BUT_NOT_MAC
pref("general.autoScroll", false);

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

@ -104,10 +104,6 @@ function CustomizeMode(aWindow) {
// to the user when in customizing mode.
this.visiblePalette = this.document.getElementById(kPaletteId);
this.pongArena = this.document.getElementById("customization-pong-arena");
if (Services.prefs.getCharPref("general.skins.selectedSkin") != "classic/1.0") {
let lwthemeButton = this.document.getElementById("customization-lwtheme-button");
lwthemeButton.setAttribute("hidden", "true");
}
if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
this._updateTitlebarCheckbox();
this._updateDragSpaceCheckbox();

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

@ -196,7 +196,6 @@ pref("extensions.autoupdate.interval", 86400);
pref("extensions.update.enabled", true);
pref("extensions.update.interval", 86400);
pref("extensions.dss.enabled", false);
pref("extensions.dss.switchPending", false);
pref("extensions.ignoreMTimeChanges", false);
pref("extensions.logging.enabled", false);
pref("extensions.hideInstallButton", true);

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

@ -13,8 +13,6 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
const ID_SUFFIX = "@personas.mozilla.org";
const PREF_LWTHEME_TO_SELECT = "extensions.lwThemeToSelect";
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
const PREF_SKIN_TO_SELECT = "extensions.lastSelectedSkin";
const ADDON_TYPE = "theme";
const ADDON_TYPE_WEBEXT = "webextension-theme";
@ -514,10 +512,6 @@ AddonWrapper.prototype = {
},
get operationsRequiringRestart() {
// If a non-default theme is in use then a restart will be required to
// enable lightweight themes unless dynamic theme switching is enabled
if (Services.prefs.prefHasUserValue(PREF_GENERAL_SKINS_SELECTEDSKIN))
return AddonManager.OP_NEEDS_RESTART_ENABLE;
return AddonManager.OP_NEEDS_RESTART_NONE;
},
@ -660,9 +654,6 @@ function _getInternalID(id) {
function _setCurrentTheme(aData, aLocal) {
aData = _sanitizeTheme(aData, null, aLocal);
let needsRestart = (ADDON_TYPE == "theme") &&
Services.prefs.prefHasUserValue(PREF_GENERAL_SKINS_SELECTEDSKIN);
let cancel = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
cancel.data = false;
Services.obs.notifyObservers(cancel, "lightweight-theme-change-requested",
@ -692,8 +683,7 @@ function _setCurrentTheme(aData, aLocal) {
if (current && current.id != aData.id) {
usedThemes.splice(1, 0, aData);
} else {
if (current && current.id == aData.id && !needsRestart &&
!Services.prefs.prefHasUserValue(PREF_SKIN_TO_SELECT)) {
if (current && current.id == aData.id) {
notify = false;
}
usedThemes.unshift(aData);
@ -709,7 +699,7 @@ function _setCurrentTheme(aData, aLocal) {
if (notify) {
AddonManagerPrivate.notifyAddonChanged(aData ? aData.id + ID_SUFFIX : null,
ADDON_TYPE, needsRestart);
ADDON_TYPE, false);
}
return LightweightThemeManager.currentTheme;

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

@ -62,6 +62,8 @@ ChromeUtils.defineModuleGetter(this, "XPIProvider",
const PREF_ALLOW_NON_RESTARTLESS = "extensions.legacy.non-restartless.enabled";
const DEFAULT_SKIN = "classic/1.0";
/* globals AddonInternal, BOOTSTRAP_REASONS, KEY_APP_SYSTEM_ADDONS, KEY_APP_SYSTEM_DEFAULTS, KEY_APP_TEMPORARY, TEMPORARY_ADDON_SUFFIX, SIGNED_TYPES, TOOLKIT_ID, XPIDatabase, XPIStates, getExternalType, isTheme, isUsableAddon, isWebExtension, mustSign, recordAddonTelemetry */
const XPI_INTERNAL_SYMBOLS = [
"AddonInternal",
@ -665,7 +667,7 @@ async function loadManifestFromRDF(aUri, aStream) {
// is in effect since it would change the active theme.
if (isTheme(addon.type)) {
addon.userDisabled = !!LightweightThemeManager.currentTheme ||
addon.internalName != XPIProvider.selectedSkin;
addon.internalName != DEFAULT_SKIN;
} else if (addon.type == "experiment") {
// Experiments are disabled by default. It is up to the Experiments Manager
// to enable them (it drives installation).

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

@ -62,9 +62,6 @@ const PREF_XPI_STATE = "extensions.xpiState";
const PREF_BLOCKLIST_ITEM_URL = "extensions.blocklist.itemURL";
const PREF_BOOTSTRAP_ADDONS = "extensions.bootstrappedAddons";
const PREF_PENDING_OPERATIONS = "extensions.pendingOperations";
const PREF_SKIN_SWITCHPENDING = "extensions.dss.switchPending";
const PREF_SKIN_TO_SELECT = "extensions.lastSelectedSkin";
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
const PREF_EM_EXTENSION_FORMAT = "extensions.";
const PREF_EM_ENABLED_SCOPES = "extensions.enabledScopes";
const PREF_EM_STARTUP_SCAN_SCOPES = "extensions.startupScanScopes";
@ -91,6 +88,8 @@ const PREF_EM_MIN_COMPAT_PLATFORM_VERSION = "extensions.minCompatiblePlatformVer
const PREF_EM_LAST_APP_BUILD_ID = "extensions.lastAppBuildId";
const DEFAULT_SKIN = "classic/1.0";
// Specify a list of valid built-in add-ons to load.
const BUILT_IN_ADDONS_URI = "chrome://browser/content/built_in_addons.json";
@ -110,7 +109,6 @@ const DIR_TRASH = "trash";
const FILE_XPI_STATES = "addonStartup.json.lz4";
const FILE_DATABASE = "extensions.json";
const FILE_OLD_CACHE = "extensions.cache";
const FILE_RDF_MANIFEST = "install.rdf";
const FILE_WEB_MANIFEST = "manifest.json";
const FILE_XPI_ADDONS_LIST = "extensions.ini";
@ -301,6 +299,7 @@ function loadLazyObjects() {
SIGNED_TYPES,
BOOTSTRAP_REASONS,
DB_SCHEMA,
DEFAULT_SKIN,
AddonInternal,
XPIProvider,
XPIStates,
@ -800,9 +799,8 @@ function isDisabledLegacy(addon) {
* @return true if the add-on should not be appDisabled
*/
function isUsableAddon(aAddon) {
// Hack to ensure the default theme is always usable
if (aAddon.type == "theme" && aAddon.internalName == XPIProvider.defaultSkin)
return true;
if (aAddon.type == "theme")
return aAddon.internalName == DEFAULT_SKIN;
if (mustSign(aAddon.type) && !aAddon.isCorrectlySigned) {
logger.warn(`Add-on ${aAddon.id} is not correctly signed.`);
@ -1291,7 +1289,7 @@ class XPIState {
// themes require the default theme's chrome to be registered even
// though we report it as disabled for UI purposes.
if (aDBAddon.type == "theme") {
this.enabled = aDBAddon.internalName == XPIProvider.selectedSkin;
this.enabled = aDBAddon.internalName == DEFAULT_SKIN;
} else {
this.enabled = aDBAddon.visible && !aDBAddon.disabled;
}
@ -1778,14 +1776,6 @@ var XPIProvider = {
installLocationsByName: null,
// An array of currently active AddonInstalls
installs: null,
// The default skin for the application
defaultSkin: "classic/1.0",
// The current skin used by the application
currentSkin: null,
// The selected skin to be used by the application when it is restarted. This
// will be the same as currentSkin when it is the skin to be used when the
// application is restarted
selectedSkin: null,
// The value of the minCompatibleAppVersion preference
minCompatibleAppVersion: null,
// The value of the minCompatiblePlatformVersion preference
@ -2064,14 +2054,6 @@ var XPIProvider = {
}
}
let defaultPrefs = Services.prefs.getDefaultBranch("");
this.defaultSkin = defaultPrefs.getStringPref(PREF_GENERAL_SKINS_SELECTEDSKIN,
"classic/1.0");
this.currentSkin = Services.prefs.getStringPref(PREF_GENERAL_SKINS_SELECTEDSKIN,
this.defaultSkin);
this.selectedSkin = this.currentSkin;
this.applyThemeChange();
this.minCompatibleAppVersion = Services.prefs.getStringPref(PREF_EM_MIN_COMPAT_APP_VERSION,
null);
this.minCompatiblePlatformVersion = Services.prefs.getStringPref(PREF_EM_MIN_COMPAT_PLATFORM_VERSION,
@ -2090,9 +2072,6 @@ var XPIProvider = {
let flushCaches = this.checkForChanges(aAppChanged, aOldAppVersion,
aOldPlatformVersion);
// Changes to installed extensions may have changed which theme is selected
this.applyThemeChange();
AddonManagerPrivate.markProviderSafe(this);
if (aAppChanged && !this.allAppGlobal &&
@ -2118,7 +2097,7 @@ var XPIProvider = {
if (AppConstants.MOZ_CRASHREPORTER) {
// Annotate the crash report with relevant add-on information.
try {
Services.appinfo.annotateCrashReport("Theme", this.currentSkin);
Services.appinfo.annotateCrashReport("Theme", DEFAULT_SKIN);
} catch (e) { }
try {
Services.appinfo.annotateCrashReport("EMCheckCompatibility",
@ -2335,27 +2314,6 @@ var XPIProvider = {
}
},
/**
* Applies any pending theme change to the preferences.
*/
applyThemeChange() {
if (!Services.prefs.getBoolPref(PREF_SKIN_SWITCHPENDING, false))
return;
// Tell the Chrome Registry which Skin to select
try {
this.selectedSkin = Services.prefs.getCharPref(PREF_SKIN_TO_SELECT);
Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN,
this.selectedSkin);
Services.prefs.clearUserPref(PREF_SKIN_TO_SELECT);
logger.debug("Changed skin to " + this.selectedSkin);
this.currentSkin = this.selectedSkin;
} catch (e) {
logger.error("Error applying theme change", e);
}
Services.prefs.clearUserPref(PREF_SKIN_SWITCHPENDING);
},
/**
* If the application has been upgraded and there are add-ons outside the
* application directory then we may need to synchronize compatibility
@ -3197,26 +3155,6 @@ var XPIProvider = {
}
}
if (aAppChanged) {
// When upgrading the app and using a custom skin make sure it is still
// compatible otherwise switch back the default
if (this.currentSkin != this.defaultSkin) {
let oldSkin = XPIDatabase.getVisibleAddonForInternalName(this.currentSkin);
if (!oldSkin || oldSkin.disabled)
this.enableDefaultTheme();
}
// When upgrading remove the old extensions cache to force older
// versions to rescan the entire list of extensions
let oldCache = FileUtils.getFile(KEY_PROFILEDIR, [FILE_OLD_CACHE], true);
try {
if (oldCache.exists())
oldCache.remove(true);
} catch (e) {
logger.warn("Unable to remove old extension cache " + oldCache.path, e);
}
}
if (Services.appinfo.inSafeMode) {
aomStartup.initializeExtensions(this.getSafeModeExtensions());
logger.debug("Initialized safe mode add-ons");
@ -3762,45 +3700,14 @@ var XPIProvider = {
if (!isTheme(aType))
return;
if (!aId) {
// Fallback to the default theme when no theme was enabled
this.enableDefaultTheme();
return;
}
// Look for the previously enabled theme and find the internalName of the
// currently selected theme
let previousTheme = null;
let newSkin = this.defaultSkin;
let addons = XPIDatabase.getAddonsByType("theme", "webextension-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);
} else if (isChangedAddon) {
newSkin = theme.internalName;
} else if (!theme.userDisabled && !theme.pendingUninstall) {
previousTheme = theme;
}
if (isWebExtension(theme.type) && theme.visible && theme.id != aId)
this.updateAddonDisabledState(theme, true, undefined);
}
if (newSkin != this.currentSkin) {
Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, newSkin);
this.currentSkin = newSkin;
}
this.selectedSkin = newSkin;
// Flush the preferences to disk so they don't get out of sync with the
// database
Services.prefs.savePrefFile(null);
// Mark the previous theme as disabled. This won't cause recursion since
// only enabled calls notifyAddonChanged.
if (previousTheme)
this.updateAddonDisabledState(previousTheme, true, undefined);
let defaultTheme = XPIDatabase.getVisibleAddonForInternalName(DEFAULT_SKIN);
this.updateAddonDisabledState(defaultTheme, aId && aId != defaultTheme.id);
},
/**
@ -3847,33 +3754,6 @@ var XPIProvider = {
});
},
/**
* When the previously selected theme is removed this method will be called
* to enable the default theme.
*/
enableDefaultTheme() {
logger.debug("Activating default theme");
let addon = XPIDatabase.getVisibleAddonForInternalName(this.defaultSkin);
if (addon) {
if (addon.userDisabled) {
this.updateAddonDisabledState(addon, false);
} else if (!this.extensionsActive) {
// During startup we may end up trying to enable the default theme when
// the database thinks it is already enabled (see f.e. bug 638847). In
// this case just force the theme preferences to be correct
Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN,
addon.internalName);
this.currentSkin = this.selectedSkin = addon.internalName;
Services.prefs.clearUserPref(PREF_SKIN_TO_SELECT);
Services.prefs.clearUserPref(PREF_SKIN_SWITCHPENDING);
} else {
logger.warn("Attempting to activate an already active default theme");
}
} else {
logger.warn("Unable to activate the default theme");
}
},
onDebugConnectionChange({what, connection}) {
if (what != "opened")
return;
@ -5039,7 +4919,7 @@ AddonWrapper.prototype = {
}
let canUseIconURLs = this.isActive ||
(addon.type == "theme" && addon.internalName == XPIProvider.defaultSkin);
(addon.type == "theme" && addon.internalName == DEFAULT_SKIN);
if (canUseIconURLs && addon.iconURL) {
icons[32] = addon.iconURL;
icons[48] = addon.iconURL;
@ -5208,9 +5088,11 @@ AddonWrapper.prototype = {
if (addon.inDatabase) {
let theme = isTheme(addon.type);
if (theme && val) {
if (addon.internalName == XPIProvider.defaultSkin)
if (addon.internalName == DEFAULT_SKIN)
throw new Error("Cannot disable the default theme");
XPIProvider.enableDefaultTheme();
let defaultTheme = XPIDatabase.getVisibleAddonForInternalName(DEFAULT_SKIN);
XPIProvider.updateAddonDisabledState(defaultTheme, false);
}
if (!(theme && val) || isWebExtension(addon.type)) {
// hidden and system add-ons should not be user disasbled,
@ -5238,9 +5120,8 @@ AddonWrapper.prototype = {
if (addon.inDatabase) {
// When softDisabling a theme just enable the active theme
if (isTheme(addon.type) && val && !addon.userDisabled) {
if (addon.internalName == XPIProvider.defaultSkin)
if (addon.internalName == DEFAULT_SKIN)
throw new Error("Cannot disable the default theme");
XPIProvider.enableDefaultTheme();
if (isWebExtension(addon.type))
XPIProvider.updateAddonDisabledState(addon, undefined, val);
} else {

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

@ -8,7 +8,7 @@
/* globals ADDON_SIGNING, SIGNED_TYPES, BOOTSTRAP_REASONS, DB_SCHEMA,
AddonInternal, XPIProvider, XPIStates, syncLoadManifestFromFile,
isUsableAddon, recordAddonTelemetry,
flushChromeCaches, descriptorToPath */
flushChromeCaches, descriptorToPath, DEFAULT_SKIN */
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
@ -1178,7 +1178,7 @@ this.XPIDatabaseReconcile = {
aNewAddon.appDisabled = !isUsableAddon(aNewAddon);
// The default theme is never a foreign install
if (aNewAddon.type == "theme" && aNewAddon.internalName == XPIProvider.defaultSkin)
if (aNewAddon.type == "theme" && aNewAddon.internalName == DEFAULT_SKIN)
aNewAddon.foreignInstall = false;
if (isDetectedInstall && aNewAddon.foreignInstall) {
@ -1524,7 +1524,6 @@ this.XPIDatabaseReconcile = {
let previousVisible = this.getVisibleAddons(previousAddons);
let currentVisible = this.flattenByID(currentAddons, hideLocation);
let sawActiveTheme = false;
// Pass over the new set of visible add-ons, record any changes that occured
// during startup and call bootstrap install/uninstall scripts as necessary
@ -1548,10 +1547,13 @@ this.XPIDatabaseReconcile = {
if (!wasStaged && XPIDatabase.activeBundles) {
// For themes we know which is active by the current skin setting
if (currentAddon.type == "theme")
isActive = currentAddon.internalName == XPIProvider.currentSkin;
isActive = currentAddon.internalName == DEFAULT_SKIN;
else
isActive = XPIDatabase.activeBundles.includes(currentAddon.path);
if (currentAddon.type == "webextension-theme")
currentAddon.userDisabled = !isActive;
// If the add-on wasn't active and it isn't already disabled in some way
// then it was probably either softDisabled or userDisabled
if (!isActive && !currentAddon.disabled) {
@ -1620,9 +1622,6 @@ this.XPIDatabaseReconcile = {
XPIDatabase.makeAddonVisible(currentAddon);
currentAddon.active = isActive;
if (currentAddon.active && currentAddon.internalName == XPIProvider.selectedSkin)
sawActiveTheme = true;
}
// Pass over the set of previously visible add-ons that have now gone away
@ -1656,13 +1655,6 @@ this.XPIDatabaseReconcile = {
}
}
// If a custom theme is selected and it wasn't seen in the new list of
// active add-ons then enable the default theme
if (XPIProvider.selectedSkin != XPIProvider.defaultSkin && !sawActiveTheme) {
logger.info("Didn't see selected skin " + XPIProvider.selectedSkin);
XPIProvider.enableDefaultTheme();
}
// Finally update XPIStates to match everything
for (let [locationName, locationAddonMap] of currentAddons) {
for (let [id, addon] of locationAddonMap) {

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

@ -150,16 +150,16 @@ const ADDONS = {
// The default theme
"theme1@tests.mozilla.org": {
"install.rdf": {
id: "theme1@tests.mozilla.org",
version: "1.0",
manifest: {
manifest_version: 2,
name: "Theme 1",
internalName: "classic/1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
version: "1.0",
theme: { images: { headerURL: "example.png" } },
applications: {
gecko: {
id: "theme1@tests.mozilla.org",
},
},
},
desiredState: {
isActive: false,
@ -167,16 +167,8 @@ const ADDONS = {
appDisabled: false,
pendingOperations: 0,
},
// Not correctly recovered, due to WebExtension themes disabling
// themselves on creation.
afterCorruption: {
isActive: true,
userDisabled: false,
},
afterSecondRestart: {
isActive: true,
userDisabled: false,
},
afterCorruption: {},
afterSecondRestart: {},
},
"theme2@tests.mozilla.org": {
@ -200,17 +192,8 @@ const ADDONS = {
appDisabled: false,
pendingOperations: 0,
},
// Not correctly recovered, due to WebExtension themes disabling
// themselves on creation.
afterCorruption: {
isActive: true,
userDisabled: true,
pendingOperations: 2,
},
afterSecondRestart: {
isActive: false,
userDisabled: true,
},
afterCorruption: {},
afterSecondRestart: {},
},
};

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

@ -18,13 +18,6 @@ add_task(async function test_disable() {
version: "1.0",
type: 256,
},
{
id: "theme@tests.mozilla.org",
name: "Theme",
version: "1.0",
type: 4,
internalName: "mytheme/1.0",
},
];
let nonLegacy = [