Bug 1234238 - Restore FFB theme. r=sebastian a=sledru
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Mon, 21 Dec 2015 17:09:05 -0500
changeset 310552 0b0ad49b43179dcc416b81be4a08c5a8526977df
parent 310551 bc5b44c0aa5fa7a29ea94fa3bcd743bdc4b5acc5
child 310553 cc557fffc7d60857b7dcff0a989fe38a2a31aaab
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, sledru
bugs1234238
milestone45.0a2
Bug 1234238 - Restore FFB theme. r=sebastian a=sledru
mobile/android/base/java/org/mozilla/gecko/restrictions/GuestProfileConfiguration.java
mobile/android/base/java/org/mozilla/gecko/restrictions/Restrictable.java
mobile/android/base/java/org/mozilla/gecko/restrictions/RestrictedProfileConfiguration.java
mobile/android/chrome/content/browser.js
toolkit/components/parentalcontrols/nsIParentalControlsService.idl
--- a/mobile/android/base/java/org/mozilla/gecko/restrictions/GuestProfileConfiguration.java
+++ b/mobile/android/base/java/org/mozilla/gecko/restrictions/GuestProfileConfiguration.java
@@ -21,17 +21,18 @@ public class GuestProfileConfiguration i
             Restrictable.BROWSE,
             Restrictable.SHARE,
             Restrictable.BOOKMARK,
             Restrictable.ADD_CONTACT,
             Restrictable.SET_IMAGE,
             Restrictable.MODIFY_ACCOUNTS,
             Restrictable.REMOTE_DEBUGGING,
             Restrictable.IMPORT_SETTINGS,
-            Restrictable.DATA_CHOICES
+            Restrictable.DATA_CHOICES,
+            Restrictable.DEFAULT_THEME
     );
 
     @SuppressWarnings("serial")
     private static final List<String> BANNED_SCHEMES = Arrays.asList(
             "file",
             "chrome",
             "resource",
             "jar",
--- a/mobile/android/base/java/org/mozilla/gecko/restrictions/Restrictable.java
+++ b/mobile/android/base/java/org/mozilla/gecko/restrictions/Restrictable.java
@@ -67,17 +67,19 @@ public enum Restrictable {
             R.string.restrictable_feature_camera_microphone_description),
 
     TELEMETRY(19, "telemetry",
             R.string.datareporting_telemetry_title,
             R.string.datareporting_telemetry_summary),
 
     HEALTH_REPORT(20, "health_report",
             R.string.datareporting_fhr_title,
-            R.string.datareporting_fhr_summary2);
+            R.string.datareporting_fhr_summary2),
+
+    DEFAULT_THEME(21, "default_theme", 0, 0);
 
     public final int id;
     public final String name;
 
     @StringRes
     public final int title;
 
     @StringRes
--- a/mobile/android/base/java/org/mozilla/gecko/restrictions/RestrictedProfileConfiguration.java
+++ b/mobile/android/base/java/org/mozilla/gecko/restrictions/RestrictedProfileConfiguration.java
@@ -30,25 +30,27 @@ public class RestrictedProfileConfigurat
         configuration.put(Restrictable.CLEAR_HISTORY, false);
         configuration.put(Restrictable.MASTER_PASSWORD, false);
         configuration.put(Restrictable.GUEST_BROWSING, false);
         configuration.put(Restrictable.ADVANCED_SETTINGS, false);
         configuration.put(Restrictable.CAMERA_MICROPHONE, false);
         configuration.put(Restrictable.DATA_CHOICES, false);
         configuration.put(Restrictable.TELEMETRY, false);
         configuration.put(Restrictable.HEALTH_REPORT, true);
+        configuration.put(Restrictable.DEFAULT_THEME, true);
     }
 
     /**
      * These restrictions are hidden from the admin configuration UI.
      */
     private static List<Restrictable> hiddenRestrictions = Arrays.asList(
             Restrictable.MASTER_PASSWORD,
             Restrictable.GUEST_BROWSING,
-            Restrictable.DATA_CHOICES
+            Restrictable.DATA_CHOICES,
+            Restrictable.DEFAULT_THEME
     );
 
     /* package-private */ static boolean shouldHide(Restrictable restrictable) {
         return hiddenRestrictions.contains(restrictable);
     }
 
     /* package-private */ static Map<Restrictable, Boolean> getConfiguration() {
         return configuration;
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3134,16 +3134,23 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 var LightWeightThemeWebInstaller = {
   init: function sh_init() {
     let temp = {};
     Cu.import("resource://gre/modules/LightweightThemeConsumer.jsm", temp);
     let theme = new temp.LightweightThemeConsumer(document);
     BrowserApp.deck.addEventListener("InstallBrowserTheme", this, false, true);
     BrowserApp.deck.addEventListener("PreviewBrowserTheme", this, false, true);
     BrowserApp.deck.addEventListener("ResetBrowserThemePreview", this, false, true);
+
+    if (ParentalControls.parentalControlsEnabled &&
+        !this._manager.currentTheme &&
+        ParentalControls.isAllowed(ParentalControls.DEFAULT_THEME)) {
+      // We are using the DEFAULT_THEME restriction to differentiate between restricted profiles & guest mode - Bug 1199596
+      this._installParentalControlsTheme();
+    }
   },
 
   handleEvent: function (event) {
     switch (event.type) {
       case "InstallBrowserTheme":
       case "PreviewBrowserTheme":
       case "ResetBrowserThemePreview":
         // ignore requests from background tabs
@@ -3170,16 +3177,28 @@ var LightWeightThemeWebInstaller = {
 
   get _manager () {
     let temp = {};
     Cu.import("resource://gre/modules/LightweightThemeManager.jsm", temp);
     delete this._manager;
     return this._manager = temp.LightweightThemeManager;
   },
 
+  _installParentalControlsTheme: function() {
+    let mgr = this._manager;
+    let parentalControlsTheme = {
+      "headerURL": "resource://android/assets/parental_controls_theme.png",
+      "name": "Parental Controls Theme",
+      "id": "parental-controls-theme@mozilla.org"
+    };
+
+    mgr.addBuiltInTheme(parentalControlsTheme);
+    mgr.themeChanged(parentalControlsTheme);
+  },
+
   _installRequest: function (event) {
     let node = event.target;
     let data = this._getThemeFromNode(node);
     if (!data)
       return;
 
     if (this._isAllowed(node)) {
       this._install(data);
--- a/toolkit/components/parentalcontrols/nsIParentalControlsService.idl
+++ b/toolkit/components/parentalcontrols/nsIParentalControlsService.idl
@@ -6,17 +6,17 @@
 
 #include "nsISupports.idl"
 
 interface nsIURI;
 interface nsIFile;
 interface nsIInterfaceRequestor;
 interface nsIArray;
 
-[scriptable, uuid(3dc75deb-14cc-4bc3-9369-5002b5275c58)]
+[scriptable, uuid(2e97e5dd-467b-4aea-a1bb-6773c0f2beb0)]
 interface nsIParentalControlsService : nsISupports
 {
   /**
    * Action types that can be blocked for users.
    */
   const short DOWNLOAD = 1; // Downloading files
   const short INSTALL_EXTENSION = 2; // Installing extensions
   const short INSTALL_APP = 3; // Installing webapps
@@ -32,16 +32,17 @@ interface nsIParentalControlsService : n
   const short DATA_CHOICES = 13; // Choose whether or not to send usage information
   const short CLEAR_HISTORY = 14; // Clear browsing history
   const short MASTER_PASSWORD = 15; // Setting master password for logins
   const short GUEST_BROWSING = 16; // Disallow usage of guest browsing
   const short ADVANCED_SETTINGS = 17; // Advanced settings
   const short CAMERA_MICROPHONE = 18; // Camera and microphone (WebRTC)
   const short TELEMETRY = 19; // Submit telemetry data
   const short HEALTH_REPORT = 20; // Submit FHR data
+  const short DEFAULT_THEME = 21; // Use default theme or a special parental controls theme
 
   /**
    * @returns true if the current user account has parental controls
    * restrictions enabled.
    */
   readonly attribute boolean parentalControlsEnabled;
 
   /**