use of org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate in project AndroidChromium by JackyAndroid.
the class DataReductionPreferences method createDataReductionSwitch.
private void createDataReductionSwitch(boolean isEnabled) {
final ChromeSwitchPreference dataReductionSwitch = new ChromeSwitchPreference(getActivity(), null);
dataReductionSwitch.setKey(PREF_DATA_REDUCTION_SWITCH);
dataReductionSwitch.setSummaryOn(R.string.text_on);
dataReductionSwitch.setSummaryOff(R.string.text_off);
dataReductionSwitch.setDrawDivider(true);
dataReductionSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
DataReductionProxySettings.getInstance().setDataReductionProxyEnabled(dataReductionSwitch.getContext(), (boolean) newValue);
DataReductionPreferences.this.updatePreferences((boolean) newValue);
return true;
}
});
dataReductionSwitch.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
return CommandLine.getInstance().hasSwitch(ENABLE_DATA_REDUCTION_PROXY) || DataReductionProxySettings.getInstance().isDataReductionProxyManaged();
}
});
getPreferenceScreen().addPreference(dataReductionSwitch);
// Note: setting the switch state before the preference is added to the screen results in
// some odd behavior where the switch state doesn't always match the internal enabled state
// (e.g. the switch will say "On" when data reduction is really turned off), so
// .setChecked() should be called after .addPreference()
dataReductionSwitch.setChecked(isEnabled);
}
use of org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate in project AndroidChromium by JackyAndroid.
the class AccountManagementFragment method configureAddAccountPreference.
private void configureAddAccountPreference() {
ChromeBasePreference addAccount = (ChromeBasePreference) findPreference(PREF_ADD_ACCOUNT);
if (ChildAccountService.isChildAccount()) {
getPreferenceScreen().removePreference(addAccount);
} else {
addAccount.setTitle(getResources().getString(R.string.account_management_add_account_title));
addAccount.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (!isVisible() || !isResumed())
return false;
AccountManagementScreenHelper.logEvent(ProfileAccountManagementMetrics.ADD_ACCOUNT, mGaiaServiceType);
AccountAdder.getInstance().addAccount(getActivity(), AccountAdder.ADD_ACCOUNT_RESULT);
// Return to the last opened tab if triggered from the content area.
if (mGaiaServiceType != AccountManagementScreenHelper.GAIA_SERVICE_TYPE_NONE) {
if (isAdded())
getActivity().finish();
}
return true;
}
});
addAccount.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
return !canAddAccounts();
}
});
}
}
use of org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate in project AndroidChromium by JackyAndroid.
the class SavePasswordsPreferences method createAutoSignInCheckbox.
private void createAutoSignInCheckbox() {
if (!ChromeFeatureList.isEnabled(CREDENTIAL_MANAGER_API)) {
return;
}
mAutoSignInSwitch = new ChromeBaseCheckBoxPreference(getActivity(), null);
mAutoSignInSwitch.setKey(PREF_AUTOSIGNIN_SWITCH);
mAutoSignInSwitch.setTitle(R.string.passwords_auto_signin_title);
mAutoSignInSwitch.setOrder(ORDER_AUTO_SIGNIN_CHECKBOX);
mAutoSignInSwitch.setSummary(R.string.passwords_auto_signin_description);
mAutoSignInSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
PrefServiceBridge.getInstance().setPasswordManagerAutoSigninEnabled((boolean) newValue);
return true;
}
});
mAutoSignInSwitch.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
return PrefServiceBridge.getInstance().isPasswordManagerAutoSigninManaged();
}
});
getPreferenceScreen().addPreference(mAutoSignInSwitch);
mAutoSignInSwitch.setChecked(PrefServiceBridge.getInstance().isPasswordManagerAutoSigninEnabled());
}
use of org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate in project AndroidChromium by JackyAndroid.
the class PrivacyPreferences method createManagedPreferenceDelegate.
private ManagedPreferenceDelegate createManagedPreferenceDelegate() {
return new ManagedPreferenceDelegate() {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
String key = preference.getKey();
PrefServiceBridge prefs = PrefServiceBridge.getInstance();
if (PREF_NAVIGATION_ERROR.equals(key)) {
return prefs.isResolveNavigationErrorManaged();
}
if (PREF_SEARCH_SUGGESTIONS.equals(key)) {
return prefs.isSearchSuggestManaged();
}
if (PREF_SAFE_BROWSING_EXTENDED_REPORTING.equals(key) || PREF_SAFE_BROWSING_SCOUT_REPORTING.equals(key)) {
return prefs.isSafeBrowsingExtendedReportingManaged();
}
if (PREF_SAFE_BROWSING.equals(key)) {
return prefs.isSafeBrowsingManaged();
}
if (PREF_NETWORK_PREDICTIONS.equals(key)) {
return prefs.isNetworkPredictionManaged();
}
return false;
}
};
}
use of org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate in project AndroidChromium by JackyAndroid.
the class SingleCategoryPreferences method updateThirdPartyCookiesCheckBox.
private void updateThirdPartyCookiesCheckBox() {
ChromeBaseCheckBoxPreference thirdPartyCookiesPref = (ChromeBaseCheckBoxPreference) getPreferenceScreen().findPreference(THIRD_PARTY_COOKIES_TOGGLE_KEY);
thirdPartyCookiesPref.setEnabled(PrefServiceBridge.getInstance().isAcceptCookiesEnabled());
thirdPartyCookiesPref.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
return PrefServiceBridge.getInstance().isBlockThirdPartyCookiesManaged();
}
});
}
Aggregations