Bug 836517 - Lightweight theme support for distributions. r=mfinkle
☠☠ backed out by eefb9fb2af78 ☠ ☠
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Thu, 31 Jan 2013 10:28:42 -0800
changeset 130361 9aadf7e35e705869d01dd38a810361b5105fd934
parent 130360 493805ba1c854a572f36183ca566565961304d32
child 130362 ccdcf297a43fe35a8155b7549c9de2df5578c630
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs836517
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 836517 - Lightweight theme support for distributions. r=mfinkle
mobile/android/chrome/content/browser.js
mobile/android/modules/LightweightThemeConsumer.jsm
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -8200,16 +8200,20 @@ var Distribution = {
           case "string":
           case "undefined":
             defaults.setCharPref(key, value);
             break;
         }
       } 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) {
       try {
         let value = localizeablePrefs[key];
         value = value.replace("%LOCALE%", locale, "g");
         localizedString.data = "data:text/plain," + key + "=" + value;
         defaults.setComplexValue(key, Ci.nsIPrefLocalizedString, localizedString);
--- a/mobile/android/modules/LightweightThemeConsumer.jsm
+++ b/mobile/android/modules/LightweightThemeConsumer.jsm
@@ -7,30 +7,32 @@ let Cc = Components.classes;
 let Ci = Components.interfaces;
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 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;
   },
 
   _update: function (aData) {
     if (!aData)
       aData = { headerURL: "", footerURL: "", textcolor: "", accentcolor: "" };
 
     let active = !!aData.headerURL;