Bug 1125288 - Restricted profiles: Hide all developer tools and related UI. r=margaret
authorSebastian Kaspari <s.kaspari@gmail.com>
Thu, 30 Jul 2015 19:48:38 +0200
changeset 287153 06f2c8aca1e37821e6a0827c9540a63239dbfdb9
parent 287152 8fd046b77ea3777e01afc2e4f1de9f9cb54a86bc
child 287154 01ee85a69d779f261c5485707afc380092da0e87
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)
reviewersmargaret
bugs1125288
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 1125288 - Restricted profiles: Hide all developer tools and related UI. r=margaret
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/preferences/GeckoPreferences.java
mobile/android/base/resources/xml-v11/preference_headers.xml
mobile/android/base/resources/xml/preference_headers.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
@@ -688,9 +688,10 @@ just addresses the organization to follo
 <!ENTITY restriction_disallow_report_site_issue_title "Disallow \'Report site issue\'">
 <!ENTITY restriction_disallow_report_site_issue_description "Hide \'Report site issue\' menu item.">
 <!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.">
--- a/mobile/android/base/preferences/GeckoPreferences.java
+++ b/mobile/android/base/preferences/GeckoPreferences.java
@@ -2,16 +2,17 @@
  * 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/. */
 
 package org.mozilla.gecko.preferences;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
 import android.os.Build;
 
 import org.json.JSONObject;
 import org.mozilla.gecko.AppConstants;
@@ -470,25 +471,28 @@ OnSharedPreferenceChangeListener
         return GeckoPreferenceFragment.class.getName().equals(fragmentName);
     }
 
     @Override
     public void onBuildHeaders(List<Header> target) {
         if (onIsMultiPane()) {
             loadHeadersFromResource(R.xml.preference_headers, target);
 
-            // If locale switching is disabled, remove the section
-            // entirely. This logic will need to be extended when
-            // content language selection (Bug 881510) is implemented.
-            if (!localeSwitchingIsEnabled) {
-                for (Header header : target) {
-                    if (header.id == R.id.pref_header_language) {
-                        target.remove(header);
-                        break;
-                    }
+            Iterator<Header> iterator = target.iterator();
+
+            while (iterator.hasNext()) {
+                Header header = iterator.next();
+
+                if (header.id == R.id.pref_header_language && !localeSwitchingIsEnabled) {
+                    // If locale switching is disabled, remove the section
+                    // entirely. This logic will need to be extended when
+                    // content language selection (Bug 881510) is implemented.
+                    iterator.remove();
+                } else if (header.id == R.id.pref_header_devtools && !RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_DEVELOPER_TOOLS)) {
+                    iterator.remove();
                 }
             }
         }
     }
 
     @Override
     public void onWindowFocusChanged(boolean hasFocus) {
         if (!hasFocus || mInitialized)
--- a/mobile/android/base/resources/xml-v11/preference_headers.xml
+++ b/mobile/android/base/resources/xml-v11/preference_headers.xml
@@ -36,14 +36,15 @@
 
     <header android:fragment="org.mozilla.gecko.preferences.GeckoPreferenceFragment"
             android:title="@string/pref_header_vendor">
         <extra android:name="resource"
                android:value="preferences_vendor"/>
     </header>
 
     <header android:fragment="org.mozilla.gecko.preferences.GeckoPreferenceFragment"
-            android:title="@string/pref_header_devtools">
+            android:title="@string/pref_header_devtools"
+            android:id="@+id/pref_header_devtools">
         <extra android:name="resource"
                android:value="preferences_devtools"/>
     </header>
 
 </preference-headers>
--- a/mobile/android/base/resources/xml/preference_headers.xml
+++ b/mobile/android/base/resources/xml/preference_headers.xml
@@ -5,9 +5,12 @@
 
 <!-- This file is a stub to allow IDs to be used in code
      even for a version-limited build. -->
 
 <preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
     <header android:fragment="org.mozilla.gecko.preferences.GeckoPreferenceFragment"
             android:id="@+id/pref_header_language">
     </header>
+    <header android:fragment="org.mozilla.gecko.preferences.GeckoPreferenceFragment"
+            android:id="@+id/pref_header_devtools">
+    </header>
 </preference-headers>
--- a/mobile/android/base/restrictions/RestrictedProfileConfiguration.java
+++ b/mobile/android/base/restrictions/RestrictedProfileConfiguration.java
@@ -15,17 +15,18 @@ import java.util.Arrays;
 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_IMPORT_SETTINGS,
+            Restriction.DISALLOW_DEVELOPER_TOOLS
     );
 
     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
@@ -59,18 +59,23 @@ public enum Restriction {
     DISALLOW_TOOLS_MENU(
             12, "no_tools_menu",
             R.string.restriction_disallow_tools_menu_title,
             R.string.restriction_disallow_tools_menu_description),
 
     DISALLOW_REPORT_SITE_ISSUE(
             13, "no_report_site_issue",
             R.string.restriction_disallow_report_site_issue_title,
-            R.string.restriction_disallow_report_site_issue_description);
+            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
+    );
 
     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) {
         this.id = id;
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -544,16 +544,18 @@
   <string name="restriction_disallow_report_site_issue_title">&restriction_disallow_report_site_issue_title;</string>
   <string name="restriction_disallow_report_site_issue_description">&restriction_disallow_report_site_issue_description;</string>
   <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>
 
   <!-- Miscellaneous -->
   <string name="ellipsis">&ellipsis;</string>
 
   <string name="colon">&colon;</string>
 
   <string name="percent">&percent;</string>