Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4399)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillAndPaymentsPreferences.java

Issue 2636023002: [Autofill and payments] Redesign Autofill settings UIs (Closed)
Patch Set: no need refresh in onCreate Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillAndPaymentsPreferences.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillAndPaymentsPreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillAndPaymentsPreferences.java
new file mode 100644
index 0000000000000000000000000000000000000000..88282cbb0d63b8f534acc975270c2804e7ccb735
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillAndPaymentsPreferences.java
@@ -0,0 +1,88 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.preferences.autofill;
+
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceFragment;
+
+import org.chromium.chrome.R;
+import org.chromium.chrome.browser.autofill.PersonalDataManager;
+import org.chromium.chrome.browser.preferences.ChromeSwitchPreference;
+
+/**
+ * Autofill and payments settings fragment, which allows the user to edit autofill and credit card
+ * profiles and control payment apps.
+ */
+public class AutofillAndPaymentsPreferences
+ extends PreferenceFragment implements PersonalDataManager.PersonalDataManagerObserver {
+ public static final String AUTOFILL_GUID = "guid";
+
+ // Needs to be in sync with kSettingsOrigin[] in
+ // chrome/browser/ui/webui/options/autofill_options_handler.cc
+ public static final String SETTINGS_ORIGIN = "Chrome settings";
+ private static final String PREF_AUTOFILL_SWITCH = "autofill_switch";
+ private static final String PREF_AUTOFILL_PROFILES = "autofill_profiles";
+ private static final String PREF_AUTOFILL_CREDIT_CARDS = "autofill_credit_cards";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.autofill_and_payments_preferences);
+ getActivity().setTitle(R.string.prefs_autofill_and_payments);
+
+ ChromeSwitchPreference autofillSwitch =
+ (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
+ autofillSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ PersonalDataManager.setAutofillEnabled((boolean) newValue);
+ return true;
+ }
+ });
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ ((ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH))
+ .setChecked(PersonalDataManager.isAutofillEnabled());
+ refreshSummary();
+ }
+
+ private void refreshSummary() {
+ Preference pref = findPreference(PREF_AUTOFILL_PROFILES);
+ if (PersonalDataManager.getInstance().hasProfiles()) {
+ pref.setSummary(getActivity().getString(R.string.autofill_update_profiles_summary));
+ } else {
+ pref.setSummary(getActivity().getString(R.string.autofill_add_profiles_summary));
+ }
+
+ pref = findPreference(PREF_AUTOFILL_CREDIT_CARDS);
+ if (PersonalDataManager.getInstance().hasCreditCards()) {
+ pref.setSummary(getActivity().getString(R.string.autofill_update_credit_cards_summary));
+ } else {
+ pref.setSummary(getActivity().getString(R.string.autofill_add_credit_cards_summary));
+ }
+ }
+
+ @Override
+ public void onPersonalDataChanged() {
+ refreshSummary();
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ PersonalDataManager.getInstance().registerDataObserver(this);
+ }
+
+ @Override
+ public void onDestroyView() {
+ PersonalDataManager.getInstance().unregisterDataObserver(this);
+ super.onDestroyView();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698