mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Bug 1525762: Part 3d - Get rid of built-in LWT code. r=aswan
--HG-- extra : rebase_source : 973fe909020cc59e2fef2ba00fb1090052881ead extra : histedit_source : e84e0d06fa61861cfe1f209e52982c75b637b57e
This commit is contained in:
parent
af2e6f146c
commit
6abf9497a0
@ -54,29 +54,12 @@ var LightweightThemeManager = {
|
||||
return _fallbackThemeData;
|
||||
},
|
||||
|
||||
// Themes that can be added for an application. They can't be removed, and
|
||||
// will always show up at the top of the list.
|
||||
_builtInThemes: new Map(),
|
||||
|
||||
isBuiltIn(theme) {
|
||||
return this._builtInThemes.has(theme.id);
|
||||
},
|
||||
|
||||
get selectedThemeID() {
|
||||
return _prefs.getStringPref("selectedThemeID") || DEFAULT_THEME_ID;
|
||||
},
|
||||
|
||||
get defaultDarkThemeID() {
|
||||
return _defaultDarkThemeID;
|
||||
},
|
||||
|
||||
get usedThemes() {
|
||||
let themes = [];
|
||||
try {
|
||||
themes = JSON.parse(_prefs.getStringPref("usedThemes"));
|
||||
} catch (e) { }
|
||||
|
||||
themes.push(...this._builtInThemes.values());
|
||||
return themes;
|
||||
},
|
||||
|
||||
@ -151,7 +134,7 @@ var LightweightThemeManager = {
|
||||
|
||||
forgetUsedTheme(aId) {
|
||||
let theme = this.getUsedTheme(aId);
|
||||
if (!theme || LightweightThemeManager._builtInThemes.has(theme.id))
|
||||
if (!theme)
|
||||
return;
|
||||
|
||||
var currentTheme = this.currentTheme;
|
||||
@ -162,38 +145,6 @@ var LightweightThemeManager = {
|
||||
_updateUsedThemes(_usedThemesExceptId(aId));
|
||||
},
|
||||
|
||||
addBuiltInTheme(theme, { useInDarkMode } = {}) {
|
||||
if (!theme || !theme.id || this.usedThemes.some(t => t.id == theme.id)) {
|
||||
throw new Error("Trying to add invalid builtIn theme");
|
||||
}
|
||||
|
||||
this._builtInThemes.set(theme.id, theme);
|
||||
|
||||
if (_prefs.getStringPref("selectedThemeID", DEFAULT_THEME_ID) == theme.id) {
|
||||
this.currentTheme = theme;
|
||||
}
|
||||
|
||||
if (useInDarkMode) {
|
||||
_defaultDarkThemeID = theme.id;
|
||||
}
|
||||
},
|
||||
|
||||
forgetBuiltInTheme(id) {
|
||||
if (!this._builtInThemes.has(id)) {
|
||||
let currentTheme = this.currentTheme;
|
||||
if (currentTheme && currentTheme.id == id) {
|
||||
this.currentTheme = null;
|
||||
}
|
||||
}
|
||||
return this._builtInThemes.delete(id);
|
||||
},
|
||||
|
||||
clearBuiltInThemes() {
|
||||
for (let id of this._builtInThemes.keys()) {
|
||||
this.forgetBuiltInTheme(id);
|
||||
}
|
||||
},
|
||||
|
||||
parseTheme(aString, aBaseURI) {
|
||||
try {
|
||||
return _sanitizeTheme(JSON.parse(aString), aBaseURI, false);
|
||||
@ -390,9 +341,6 @@ function _makeURI(aURL, aBaseURI) {
|
||||
}
|
||||
|
||||
function _updateUsedThemes(aList) {
|
||||
// Remove app-specific themes before saving them to the usedThemes pref.
|
||||
aList = aList.filter(theme => !LightweightThemeManager._builtInThemes.has(theme.id));
|
||||
|
||||
_prefs.setStringPref("usedThemes", JSON.stringify(aList));
|
||||
|
||||
Services.obs.notifyObservers(null, "lightweight-theme-list-changed");
|
||||
|
Loading…
Reference in New Issue
Block a user