Bug 1125315 - Restricted profiles: Hide setting "Customize > Home". r=ally
authorSebastian Kaspari <s.kaspari@gmail.com>
Thu, 30 Jul 2015 19:52:54 +0200
changeset 287154 01ee85a69d779f261c5485707afc380092da0e87
parent 287153 06f2c8aca1e37821e6a0827c9540a63239dbfdb9
child 287155 8bdfb76f8a081d570dd6cbbb4f3e73bbe38ee204
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersally
bugs1125315
milestone42.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 1125315 - Restricted profiles: Hide setting "Customize > Home". r=ally
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/preferences/GeckoPreferences.java
mobile/android/base/resources/xml-v11/preferences_customize.xml
mobile/android/base/resources/xml-v11/preferences_customize_tablet.xml
mobile/android/base/resources/xml/preferences_customize.xml
mobile/android/base/restrictions/RestrictedProfileConfiguration.java
mobile/android/base/restrictions/Restriction.java
mobile/android/base/strings.xml.in
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -690,8 +690,10 @@ just addresses the organization to follo
 <!ENTITY restriction_disallow_import_settings_title "Disallow importing settings">
 <!ENTITY restriction_disallow_import_settings_description "Do not allow to import settings from other system browsers.">
 <!ENTITY restriction_disallow_addons_title "Disallow add-ons">
 <!ENTITY restriction_disallow_addons_description "Disallow installation of add-ons.">
 <!ENTITY restriction_disallow_apps_title "Disallow apps">
 <!ENTITY restriction_disallow_apps_description "Disallow installing apps from Firefox Marketplace.">
 <!ENTITY restriction_disallow_devtools_title "Disallow developer tools">
 <!ENTITY restriction_disallow_devtools_description "Disallow usage of developer tools.">
+<!ENTITY restriction_disallow_customize_home_title "Disallow customizing home">
+<!ENTITY restriction_disallow_customize_home_description "Disallow customizing home panels.">
--- a/mobile/android/base/preferences/GeckoPreferences.java
+++ b/mobile/android/base/preferences/GeckoPreferences.java
@@ -127,16 +127,17 @@ OnSharedPreferenceChangeListener
     private static final String PREFS_DEVTOOLS_REMOTE_WIFI_ENABLED = "devtools.remote.wifi.enabled";
     private static final String PREFS_DISPLAY_REFLOW_ON_ZOOM = "browser.zoom.reflowOnZoom";
     private static final String PREFS_DISPLAY_TITLEBAR_MODE = "browser.chrome.titlebarMode";
     private static final String PREFS_SYNC = NON_PREF_PREFIX + "sync";
     public static final String PREFS_OPEN_URLS_IN_PRIVATE = NON_PREF_PREFIX + "openExternalURLsPrivately";
     public static final String PREFS_VOICE_INPUT_ENABLED = NON_PREF_PREFIX + "voice_input_enabled";
     public static final String PREFS_QRCODE_ENABLED = NON_PREF_PREFIX + "qrcode_enabled";
     private static final String PREFS_DEVTOOLS = NON_PREF_PREFIX + "devtools.enabled";
+    private static final String PREFS_CUSTOMIZE_HOME = NON_PREF_PREFIX + "customize_home";
 
     private static final String ACTION_STUMBLER_UPLOAD_PREF = AppConstants.ANDROID_PACKAGE_NAME + ".STUMBLER_PREF";
 
 
     // This isn't a Gecko pref, even if it looks like one.
     private static final String PREFS_BROWSER_LOCALE = "locale";
 
     public static final String PREFS_RESTORE_SESSION = NON_PREF_PREFIX + "restoreSession3";
@@ -700,16 +701,24 @@ OnSharedPreferenceChangeListener
                 }
                 if (PREFS_DEVTOOLS.equals(key) &&
                     RestrictedProfiles.isUserRestricted(this)) {
                     preferences.removePreference(pref);
                     i--;
                     continue;
                 }
 
+                if (PREFS_CUSTOMIZE_HOME.equals(key)) {
+                    if (!RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_CUSTOMIZE_HOME)) {
+                        preferences.removePreference(pref);
+                        i--;
+                        continue;
+                    }
+                }
+
                 setupPreferences((PreferenceGroup) pref, prefs);
             } else {
                 pref.setOnPreferenceChangeListener(this);
                 if (PREFS_UPDATER_AUTODOWNLOAD.equals(key)) {
                     if (!AppConstants.MOZ_UPDATER) {
                         preferences.removePreference(pref);
                         i--;
                         continue;
--- a/mobile/android/base/resources/xml-v11/preferences_customize.xml
+++ b/mobile/android/base/resources/xml-v11/preferences_customize.xml
@@ -4,17 +4,18 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <!-- Changes should be mirrored to preferences_customize_tablet.xml. -->
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
                   xmlns:gecko="http://schemas.android.com/apk/res-auto"
                   android:enabled="false">
 
-    <PreferenceScreen android:title="@string/pref_category_home"
+    <PreferenceScreen android:key="android.not_a_preference.customize_home"
+                      android:title="@string/pref_category_home"
                       android:summary="@string/pref_category_home_summary"
                       android:fragment="org.mozilla.gecko.preferences.GeckoPreferenceFragment" >
             <extra android:name="resource"
                    android:value="preferences_home" />
     </PreferenceScreen>
 
      <PreferenceScreen android:title="@string/pref_category_search"
                        android:summary="@string/pref_category_search_summary"
--- a/mobile/android/base/resources/xml-v11/preferences_customize_tablet.xml
+++ b/mobile/android/base/resources/xml-v11/preferences_customize_tablet.xml
@@ -11,17 +11,18 @@
                   xmlns:gecko="http://schemas.android.com/apk/res-auto"
                   android:title="@string/pref_category_customize"
                   android:enabled="false">
 
     <org.mozilla.gecko.preferences.SyncPreference android:key="android.not_a_preference.sync"
                                                   android:title="@string/pref_sync"
                                                   android:persistent="false" />
 
-    <PreferenceScreen android:title="@string/pref_category_home"
+    <PreferenceScreen android:key="android.not_a_preference.customize_home"
+                      android:title="@string/pref_category_home"
                       android:summary="@string/pref_category_home_summary"
                       android:fragment="org.mozilla.gecko.preferences.GeckoPreferenceFragment" >
             <extra android:name="resource"
                    android:value="preferences_home" />
     </PreferenceScreen>
 
     <PreferenceScreen android:title="@string/pref_category_search"
                       android:summary="@string/pref_category_search_summary"
--- a/mobile/android/base/resources/xml/preferences_customize.xml
+++ b/mobile/android/base/resources/xml/preferences_customize.xml
@@ -2,17 +2,19 @@
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
                   xmlns:gecko="http://schemas.android.com/apk/res-auto"
                   android:enabled="false">
 
-    <PreferenceScreen android:title="@string/pref_category_home"
+    <PreferenceScreen
+                      android:key="android.not_a_preference.customize_home"
+                      android:title="@string/pref_category_home"
                       android:summary="@string/pref_category_home_summary" >
         <intent android:action="android.intent.action.VIEW"
                 android:targetPackage="@string/android_package_name"
                 android:targetClass="org.mozilla.gecko.preferences.GeckoPreferences" >
             <extra
                 android:name="resource"
                 android:value="preferences_home" />
         </intent>
--- a/mobile/android/base/restrictions/RestrictedProfileConfiguration.java
+++ b/mobile/android/base/restrictions/RestrictedProfileConfiguration.java
@@ -16,17 +16,18 @@ import java.util.List;
 
 public class RestrictedProfileConfiguration implements RestrictionConfiguration {
     static List<Restriction> DEFAULT_RESTRICTIONS = Arrays.asList(
             Restriction.DISALLOW_INSTALL_EXTENSION,
             Restriction.DISALLOW_INSTALL_APPS,
             Restriction.DISALLOW_TOOLS_MENU,
             Restriction.DISALLOW_REPORT_SITE_ISSUE,
             Restriction.DISALLOW_IMPORT_SETTINGS,
-            Restriction.DISALLOW_DEVELOPER_TOOLS
+            Restriction.DISALLOW_DEVELOPER_TOOLS,
+            Restriction.DISALLOW_CUSTOMIZE_HOME
     );
 
     private static final String ABOUT_ADDONS = "about:addons";
 
     private Context context;
 
     public RestrictedProfileConfiguration(Context context) {
         this.context = context.getApplicationContext();
--- a/mobile/android/base/restrictions/Restriction.java
+++ b/mobile/android/base/restrictions/Restriction.java
@@ -65,16 +65,22 @@ public enum Restriction {
             13, "no_report_site_issue",
             R.string.restriction_disallow_report_site_issue_title,
             R.string.restriction_disallow_report_site_issue_description),
 
     DISALLOW_DEVELOPER_TOOLS(
             14, "no_developer_tools",
             R.string.restriction_disallow_devtools_title,
             R.string.restriction_disallow_devtools_description
+    ),
+
+    DISALLOW_CUSTOMIZE_HOME(
+            15, "no_customize_home",
+            R.string.restriction_disallow_customize_home_title,
+            R.string.restriction_disallow_customize_home_description
     );
 
     public final int id;
     public final String name;
     public final int titleResource;
     public final int descriptionResource;
 
     Restriction(final int id, final String name, int titleResource, int descriptionResource) {
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -546,16 +546,18 @@
   <string name="restriction_disallow_import_settings_title">&restriction_disallow_import_settings_title;</string>
   <string name="restriction_disallow_import_settings_description">&restriction_disallow_import_settings_description;</string>
   <string name="restriction_disallow_addons_title">&restriction_disallow_addons_title;</string>
   <string name="restriction_disallow_addons_description">&restriction_disallow_addons_description;</string>
   <string name="restriction_disallow_apps_title">&restriction_disallow_apps_title;</string>
   <string name="restriction_disallow_apps_description">&restriction_disallow_apps_description;</string>
   <string name="restriction_disallow_devtools_title">&restriction_disallow_devtools_title;</string>
   <string name="restriction_disallow_devtools_description">&restriction_disallow_devtools_description;</string>
+  <string name="restriction_disallow_customize_home_title">&restriction_disallow_customize_home_title;</string>
+  <string name="restriction_disallow_customize_home_description">&restriction_disallow_customize_home_description;</string>
 
   <!-- Miscellaneous -->
   <string name="ellipsis">&ellipsis;</string>
 
   <string name="colon">&colon;</string>
 
   <string name="percent">&percent;</string>