From 792957b808abe273a0bd0a445527866126185058 Mon Sep 17 00:00:00 2001 From: Margaret Leibovic Date: Fri, 1 Feb 2013 15:45:33 -0800 Subject: [PATCH] Bug 836517 - Lightweight theme support for distributions. r=mfinkle --- mobile/android/chrome/content/browser.js | 4 ++++ mobile/android/modules/LightweightThemeConsumer.jsm | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index c362db7b9d50..fcc73fedebda 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -8232,6 +8232,10 @@ var Distribution = { } catch (e) { /* ignore bad prefs and move on */ } } + // Apply a lightweight theme if necessary + if (prefs["lightweightThemes.isThemeSelected"]) + Services.obs.notifyObservers(null, "lightweight-theme-apply", ""); + let localizedString = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(Ci.nsIPrefLocalizedString); let localizeablePrefs = aData["LocalizablePreferences"]; for (let key in localizeablePrefs) { diff --git a/mobile/android/modules/LightweightThemeConsumer.jsm b/mobile/android/modules/LightweightThemeConsumer.jsm index 7ba4dce825ee..f984f605c069 100644 --- a/mobile/android/modules/LightweightThemeConsumer.jsm +++ b/mobile/android/modules/LightweightThemeConsumer.jsm @@ -12,20 +12,22 @@ Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm"); function LightweightThemeConsumer(aDocument) { this._doc = aDocument; Services.obs.addObserver(this, "lightweight-theme-styling-update", false); + Services.obs.addObserver(this, "lightweight-theme-apply", false); this._update(LightweightThemeManager.currentThemeForDisplay); } LightweightThemeConsumer.prototype = { observe: function (aSubject, aTopic, aData) { - if (aTopic != "lightweight-theme-styling-update") - return; - - this._update(JSON.parse(aData)); + if (aTopic == "lightweight-theme-styling-update") + this._update(JSON.parse(aData)); + else if (aTopic == "lightweight-theme-apply") + this._update(LightweightThemeManager.currentThemeForDisplay); }, destroy: function () { Services.obs.removeObserver(this, "lightweight-theme-styling-update"); + Services.obs.removeObserver(this, "lightweight-theme-apply"); this._doc = null; },