mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1074496 - "Disable import from Android in Guest mode" [r=liuche]
This commit is contained in:
parent
3d5788cdc5
commit
1173389da8
@ -62,7 +62,9 @@ public class RestrictedProfiles {
|
|||||||
DISALLOW_BOOKMARK(6, "no_bookmark"),
|
DISALLOW_BOOKMARK(6, "no_bookmark"),
|
||||||
DISALLOW_ADD_CONTACTS(7, "no_add_contacts"),
|
DISALLOW_ADD_CONTACTS(7, "no_add_contacts"),
|
||||||
DISALLOW_SET_IMAGE(8, "no_set_image"),
|
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 int id;
|
||||||
public final String name;
|
public final String name;
|
||||||
|
@ -7,19 +7,31 @@ package org.mozilla.gecko.preferences;
|
|||||||
|
|
||||||
import org.mozilla.gecko.R;
|
import org.mozilla.gecko.R;
|
||||||
import org.mozilla.gecko.util.ThreadUtils;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
import org.mozilla.gecko.RestrictedProfiles;
|
||||||
|
import org.mozilla.gecko.RestrictedProfiles.Restriction;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.preference.Preference;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
class AndroidImportPreference extends MultiPrefMultiChoicePreference {
|
class AndroidImportPreference extends MultiPrefMultiChoicePreference {
|
||||||
private static final String LOGTAG = "AndroidImport";
|
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 static final String PREF_KEY_PREFIX = "import_android.data.";
|
||||||
private final Context mContext;
|
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) {
|
public AndroidImportPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
@ -19,12 +19,13 @@ public class ClearOnShutdownPref implements GeckoPreferences.PrefHandler {
|
|||||||
public static final String PREF = GeckoPreferences.NON_PREF_PREFIX + "history.clear_on_exit";
|
public static final String PREF = GeckoPreferences.NON_PREF_PREFIX + "history.clear_on_exit";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupPref(Context context, Preference pref) {
|
public boolean setupPref(Context context, Preference pref) {
|
||||||
// The pref is initialized asynchronously. Read the pref explicitly
|
// The pref is initialized asynchronously. Read the pref explicitly
|
||||||
// here to make sure we have the data.
|
// here to make sure we have the data.
|
||||||
final SharedPreferences prefs = GeckoSharedPrefs.forProfile(context);
|
final SharedPreferences prefs = GeckoSharedPrefs.forProfile(context);
|
||||||
final Set<String> clearItems = PrefUtils.getStringSet(prefs, PREF, new HashSet<String>());
|
final Set<String> clearItems = PrefUtils.getStringSet(prefs, PREF, new HashSet<String>());
|
||||||
((ListCheckboxPreference) pref).setChecked(clearItems.size() > 0);
|
((ListCheckboxPreference) pref).setChecked(clearItems.size() > 0);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -700,6 +700,12 @@ OnSharedPreferenceChangeListener
|
|||||||
i--;
|
i--;
|
||||||
continue;
|
continue;
|
||||||
} else if (PREFS_DEVTOOLS_REMOTE_ENABLED.equals(key)) {
|
} 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;
|
final Context thisContext = this;
|
||||||
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -744,7 +750,11 @@ OnSharedPreferenceChangeListener
|
|||||||
continue;
|
continue;
|
||||||
} else if (handlers.containsKey(key)) {
|
} else if (handlers.containsKey(key)) {
|
||||||
PrefHandler handler = handlers.get(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,
|
// Some Preference UI elements are not actually preferences,
|
||||||
@ -1026,13 +1036,16 @@ OnSharedPreferenceChangeListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface PrefHandler {
|
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);
|
public void onChange(Context context, Preference pref, Object newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
private final Map<String, PrefHandler> handlers = new HashMap<String, PrefHandler>() {{
|
private final Map<String, PrefHandler> handlers = new HashMap<String, PrefHandler>() {{
|
||||||
put(ClearOnShutdownPref.PREF, new ClearOnShutdownPref());
|
put(ClearOnShutdownPref.PREF, new ClearOnShutdownPref());
|
||||||
|
put(AndroidImportPreference.PREF_KEY, new AndroidImportPreference.Handler());
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,7 +11,7 @@ interface nsIFile;
|
|||||||
interface nsIInterfaceRequestor;
|
interface nsIInterfaceRequestor;
|
||||||
interface nsIArray;
|
interface nsIArray;
|
||||||
|
|
||||||
[scriptable, uuid(4bde6754-406a-45d1-b18e-dc685adc1db4)]
|
[scriptable, uuid(e7bcc22c-e9fc-4e7d-88b9-7482399b322d)]
|
||||||
interface nsIParentalControlsService : nsISupports
|
interface nsIParentalControlsService : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -26,6 +26,8 @@ interface nsIParentalControlsService : nsISupports
|
|||||||
const short ADD_CONTACT = 7; // Add contacts to the system database
|
const short ADD_CONTACT = 7; // Add contacts to the system database
|
||||||
const short SET_IMAGE = 8; // Setting images as wall paper
|
const short SET_IMAGE = 8; // Setting images as wall paper
|
||||||
const short MODIFY_ACCOUNTS = 9; // Modifying system accounts
|
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
|
* @returns true if the current user account has parental controls
|
||||||
|
Loading…
Reference in New Issue
Block a user