Bug 1401691 - Accept windowId parameter for browser.theme.reset(). r=jaws
MozReview-Commit-ID: G6XGeHAI5uF
--- a/toolkit/components/extensions/ext-theme.js
+++ b/toolkit/components/extensions/ext-theme.js
@@ -237,28 +237,33 @@ class Theme {
break;
}
}
}
}
/**
* Unloads the currently applied theme.
+ * @param {Object} targetWindow The window the theme should be unloaded from
*/
- unload() {
+ unload(targetWindow) {
let lwtStyles = {
headerURL: "",
accentcolor: "",
additionalBackgrounds: "",
backgroundsAlignment: "",
backgroundsTiling: "",
textcolor: "",
icons: {},
};
+ if (targetWindow) {
+ lwtStyles.window = getWinUtils(targetWindow).outerWindowID;
+ }
+
for (let icon of ICONS) {
lwtStyles.icons[`--${icon}--icon`] = "";
}
LightweightThemeManager.fallbackThemeData = null;
Services.obs.notifyObservers(null,
"lightweight-theme-styling-update",
JSON.stringify(lwtStyles));
}
@@ -308,25 +313,30 @@ this.theme = class extends ExtensionAPI
}
let browserWindow;
if (windowId !== null) {
browserWindow = windowTracker.getWindow(windowId, context);
}
this.theme.load(details, browserWindow);
},
- reset: () => {
+ reset: (windowId) => {
if (!gThemesEnabled) {
// Return early if themes are disabled.
return;
}
if (!this.theme) {
// If no theme has been initialized, nothing to do.
return;
}
- this.theme.unload();
+ let browserWindow;
+ if (windowId !== null) {
+ browserWindow = windowTracker.getWindow(windowId, context);
+ }
+
+ this.theme.unload(browserWindow);
},
},
};
}
};
--- a/toolkit/components/extensions/schemas/theme.json
+++ b/toolkit/components/extensions/schemas/theme.json
@@ -477,13 +477,20 @@
}
]
},
{
"name": "reset",
"type": "function",
"async": true,
"description": "Removes the updates made to the theme.",
- "parameters": []
+ "parameters": [
+ {
+ "type": "integer",
+ "name": "windowId",
+ "optional": true,
+ "description": "The id of the window to reset. No id resets all windows."
+ }
+ ]
}
]
}
]