diff --git a/mobile/android/base/RestrictedProfiles.java b/mobile/android/base/RestrictedProfiles.java index 9ab6692076d..f1bdd28fbfb 100644 --- a/mobile/android/base/RestrictedProfiles.java +++ b/mobile/android/base/RestrictedProfiles.java @@ -62,7 +62,9 @@ public class RestrictedProfiles { DISALLOW_BOOKMARK(6, "no_bookmark"), DISALLOW_ADD_CONTACTS(7, "no_add_contacts"), DISALLOW_SET_IMAGE(8, "no_set_image"), - DISALLOW_MODIFY_ACCOUNTS(9, "no_modify_accounts"); // UserManager.DISALLOW_MODIFY_ACCOUNTS + DISALLOW_MODIFY_ACCOUNTS(9, "no_modify_accounts"), // UserManager.DISALLOW_MODIFY_ACCOUNTS + DISALLOW_REMOTE_DEBUGGING(10, "no_remote_debugging"), + DISALLOW_IMPORT_SETTINGS(11, "no_import_settings"); public final int id; public final String name; diff --git a/mobile/android/base/preferences/AndroidImportPreference.java b/mobile/android/base/preferences/AndroidImportPreference.java index 1cdb9fb1271..57cc13961cb 100644 --- a/mobile/android/base/preferences/AndroidImportPreference.java +++ b/mobile/android/base/preferences/AndroidImportPreference.java @@ -7,19 +7,31 @@ package org.mozilla.gecko.preferences; import org.mozilla.gecko.R; import org.mozilla.gecko.util.ThreadUtils; +import org.mozilla.gecko.RestrictedProfiles; +import org.mozilla.gecko.RestrictedProfiles.Restriction; import java.util.Set; import android.app.ProgressDialog; import android.content.Context; +import android.preference.Preference; import android.util.AttributeSet; import android.util.Log; class AndroidImportPreference extends MultiPrefMultiChoicePreference { private static final String LOGTAG = "AndroidImport"; + public static final String PREF_KEY = "android.not_a_preference.import_android"; private static final String PREF_KEY_PREFIX = "import_android.data."; private final Context mContext; + public static class Handler implements GeckoPreferences.PrefHandler { + public boolean setupPref(Context context, Preference pref) { + return RestrictedProfiles.isAllowed(Restriction.DISALLOW_IMPORT_SETTINGS); + } + + public void onChange(Context context, Preference pref, Object newValue) { } + } + public AndroidImportPreference(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; diff --git a/mobile/android/base/preferences/ClearOnShutdownPref.java b/mobile/android/base/preferences/ClearOnShutdownPref.java index 2fc09db54b5..5218cd06db9 100644 --- a/mobile/android/base/preferences/ClearOnShutdownPref.java +++ b/mobile/android/base/preferences/ClearOnShutdownPref.java @@ -19,12 +19,13 @@ public class ClearOnShutdownPref implements GeckoPreferences.PrefHandler { public static final String PREF = GeckoPreferences.NON_PREF_PREFIX + "history.clear_on_exit"; @Override - public void setupPref(Context context, Preference pref) { + public boolean setupPref(Context context, Preference pref) { // The pref is initialized asynchronously. Read the pref explicitly // here to make sure we have the data. final SharedPreferences prefs = GeckoSharedPrefs.forProfile(context); final Set clearItems = PrefUtils.getStringSet(prefs, PREF, new HashSet()); ((ListCheckboxPreference) pref).setChecked(clearItems.size() > 0); + return true; } @Override diff --git a/mobile/android/base/preferences/GeckoPreferences.java b/mobile/android/base/preferences/GeckoPreferences.java index fdc6f377f48..5a09e6ef557 100644 --- a/mobile/android/base/preferences/GeckoPreferences.java +++ b/mobile/android/base/preferences/GeckoPreferences.java @@ -700,6 +700,12 @@ OnSharedPreferenceChangeListener i--; continue; } else if (PREFS_DEVTOOLS_REMOTE_ENABLED.equals(key)) { + if (!RestrictedProfiles.isAllowed(RestrictedProfiles.Restriction.DISALLOW_REMOTE_DEBUGGING)) { + preferences.removePreference(pref); + i--; + continue; + } + final Context thisContext = this; pref.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override @@ -744,7 +750,11 @@ OnSharedPreferenceChangeListener continue; } else if (handlers.containsKey(key)) { PrefHandler handler = handlers.get(key); - handler.setupPref(this, pref); + if (!handler.setupPref(this, pref)) { + preferences.removePreference(pref); + i--; + continue; + } } // Some Preference UI elements are not actually preferences, @@ -1026,13 +1036,16 @@ OnSharedPreferenceChangeListener } public interface PrefHandler { - public void setupPref(Context context, Preference pref); + // Allows the pref to do any initialization it needs. Return false to have the pref removed + // from the prefs screen entirely. + public boolean setupPref(Context context, Preference pref); public void onChange(Context context, Preference pref, Object newValue); } @SuppressWarnings("serial") private final Map handlers = new HashMap() {{ put(ClearOnShutdownPref.PREF, new ClearOnShutdownPref()); + put(AndroidImportPreference.PREF_KEY, new AndroidImportPreference.Handler()); }}; @Override diff --git a/toolkit/components/parentalcontrols/nsIParentalControlsService.idl b/toolkit/components/parentalcontrols/nsIParentalControlsService.idl index e8a4c127794..90ec53fac88 100644 --- a/toolkit/components/parentalcontrols/nsIParentalControlsService.idl +++ b/toolkit/components/parentalcontrols/nsIParentalControlsService.idl @@ -11,7 +11,7 @@ interface nsIFile; interface nsIInterfaceRequestor; interface nsIArray; -[scriptable, uuid(4bde6754-406a-45d1-b18e-dc685adc1db4)] +[scriptable, uuid(e7bcc22c-e9fc-4e7d-88b9-7482399b322d)] interface nsIParentalControlsService : nsISupports { /** @@ -26,6 +26,8 @@ interface nsIParentalControlsService : nsISupports const short ADD_CONTACT = 7; // Add contacts to the system database const short SET_IMAGE = 8; // Setting images as wall paper const short MODIFY_ACCOUNTS = 9; // Modifying system accounts + const short REMOTE_DEBUGGING = 10; // Remote debugging + const short IMPORT_SETTINGS = 11; // Importing settings from other apps /** * @returns true if the current user account has parental controls