Commit ebca9504 authored by Natalie Chouinard's avatar Natalie Chouinard Committed by Commit Bot

Move Autofill Settings constants to autofill/

Move constants related to Autofill settings alongside the code that uses
them. This will help future Settings modularization efforts.

Change-Id: Ie50712842bafa681adfae29e46325b9b3cab9452
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2004050
Commit-Queue: sebsg <sebsg@chromium.org>
Reviewed-by: default avatarsebsg <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732537}
parent 19e4d784
......@@ -17,7 +17,7 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.ResourceId;
import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.settings.MainPreferences;
import org.chromium.chrome.browser.settings.autofill.AutofillEditorBase;
import org.chromium.content_public.browser.WebContents;
import java.util.ArrayList;
......@@ -160,7 +160,7 @@ public class PersonalDataManager {
* locale. All other fields are empty strings, because JNI does not handle null strings.
*/
public AutofillProfile() {
this("" /* guid */, MainPreferences.SETTINGS_ORIGIN /* origin */, true /* isLocal */,
this("" /* guid */, AutofillEditorBase.SETTINGS_ORIGIN /* origin */, true /* isLocal */,
"" /* fullName */, "" /* companyName */, "" /* streetAddress */,
"" /* region */, "" /* locality */, "" /* dependentLocality */,
"" /* postalCode */, "" /* sortingCode */,
......@@ -406,7 +406,7 @@ public class PersonalDataManager {
}
public CreditCard() {
this("" /* guid */, MainPreferences.SETTINGS_ORIGIN /*origin */, true /* isLocal */,
this("" /* guid */, AutofillEditorBase.SETTINGS_ORIGIN /*origin */, true /* isLocal */,
false /* isCached */, "" /* name */, "" /* number */, "" /* obfuscatedNumber */,
"" /* month */, "" /* year */, "" /* basicCardIssuerNetwork */,
0 /* issuerIconDrawableId */, CardType.UNKNOWN, "" /* billingAddressId */,
......
......@@ -58,11 +58,6 @@ public class MainPreferences extends PreferenceFragmentCompat
public static final String PREF_DOWNLOADS = "downloads";
public static final String PREF_DEVELOPER = "developer";
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 final ManagedPreferenceDelegate mManagedPreferenceDelegate;
private final Map<String, Preference> mAllPreferences = new HashMap<>();
private SignInPreference mSignInPreference;
......
......@@ -27,13 +27,17 @@ import android.widget.Spinner;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.autofill.prefeditor.EditorDialog;
import org.chromium.chrome.browser.settings.MainPreferences;
import org.chromium.chrome.browser.settings.SettingsUtils;
import org.chromium.components.browser_ui.widget.FadingEdgeScrollView;
/** Base class for Autofill editors (e.g. credit cards and profiles). */
public abstract class AutofillEditorBase
extends Fragment implements OnItemSelectedListener, OnTouchListener, TextWatcher {
/** We know which profile to edit based on the GUID stuffed in extras. */
public static final String AUTOFILL_GUID = "guid";
/** Needs to be in sync with autofill::kSettingsOrigin[]. */
public static final String SETTINGS_ORIGIN = "Chrome settings";
/** GUID of the profile we are editing. Empty if creating a new profile. */
protected String mGUID;
......@@ -51,11 +55,9 @@ public abstract class AutofillEditorBase
setHasOptionsMenu(true);
mContext = container.getContext();
// We know which profile to edit based on the GUID stuffed in
// our extras by MainPreferences.
Bundle extras = getArguments();
if (extras != null) {
mGUID = extras.getString(MainPreferences.AUTOFILL_GUID);
mGUID = extras.getString(AUTOFILL_GUID);
}
if (mGUID == null) {
mGUID = "";
......
......@@ -25,7 +25,6 @@ import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.payments.SettingsAutofillAndPaymentsObserver;
import org.chromium.chrome.browser.settings.MainPreferences;
import org.chromium.components.browser_ui.widget.text.ChromeTextInputLayout;
import java.text.SimpleDateFormat;
......@@ -188,7 +187,7 @@ public class AutofillLocalCardEditor extends AutofillCreditCardEditor {
}
CreditCard card = personalDataManager.getCreditCardForNumber(cardNumber);
card.setGUID(mGUID);
card.setOrigin(MainPreferences.SETTINGS_ORIGIN);
card.setOrigin(SETTINGS_ORIGIN);
card.setName(mNameText.getText().toString().trim());
card.setMonth(String.valueOf(mExpirationMonth.getSelectedItemPosition() + 1));
card.setYear((String) mExpirationYear.getSelectedItem());
......
......@@ -21,7 +21,6 @@ import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.payments.AndroidPaymentAppFactory;
import org.chromium.chrome.browser.payments.ServiceWorkerPaymentAppBridge;
import org.chromium.chrome.browser.settings.ChromeSwitchPreference;
import org.chromium.chrome.browser.settings.MainPreferences;
import org.chromium.chrome.browser.settings.ManagedPreferenceDelegate;
/**
......@@ -96,7 +95,7 @@ public class AutofillPaymentMethodsFragment extends PreferenceFragmentCompat
}
Bundle args = card_pref.getExtras();
args.putString(MainPreferences.AUTOFILL_GUID, card.getGUID());
args.putString(AutofillEditorBase.AUTOFILL_GUID, card.getGUID());
getPreferenceScreen().addPreference(card_pref);
}
......
......@@ -18,7 +18,6 @@ import org.chromium.chrome.browser.autofill.prefeditor.EditorObserverForTest;
import org.chromium.chrome.browser.payments.AddressEditor;
import org.chromium.chrome.browser.payments.AutofillAddress;
import org.chromium.chrome.browser.payments.SettingsAutofillAndPaymentsObserver;
import org.chromium.chrome.browser.settings.MainPreferences;
/**
* Launches the UI to edit, create or delete an Autofill profile entry.
......@@ -46,7 +45,7 @@ public class AutofillProfileEditorPreference extends Preference {
Bundle extras = getExtras();
// We know which profile to edit based on the GUID stuffed in our extras
// by MainPreferences.
mGUID = extras.getString(MainPreferences.AUTOFILL_GUID);
mGUID = extras.getString(AutofillEditorBase.AUTOFILL_GUID);
prepareEditorDialog();
prepareAddressEditor();
}
......
......@@ -21,7 +21,6 @@ import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.prefeditor.EditorObserverForTest;
import org.chromium.chrome.browser.settings.ChromeSwitchPreference;
import org.chromium.chrome.browser.settings.MainPreferences;
import org.chromium.chrome.browser.settings.ManagedPreferenceDelegate;
/**
......@@ -97,7 +96,7 @@ public class AutofillProfilesFragment extends PreferenceFragmentCompat
pref.setFragment(AutofillServerProfileFragment.class.getName());
}
Bundle args = pref.getExtras();
args.putString(MainPreferences.AUTOFILL_GUID, profile.getGUID());
args.putString(AutofillEditorBase.AUTOFILL_GUID, profile.getGUID());
try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
getPreferenceScreen().addPreference(pref);
}
......
......@@ -14,7 +14,6 @@ import org.chromium.chrome.browser.ChromeStringConstants;
import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.settings.MainPreferences;
import org.chromium.chrome.browser.settings.SettingsUtils;
/**
......@@ -36,7 +35,7 @@ public class AutofillServerProfileFragment
// our extras by MainPreferences.
Bundle extras = getArguments();
if (extras != null) {
mGUID = extras.getString(MainPreferences.AUTOFILL_GUID);
mGUID = extras.getString(AutofillEditorBase.AUTOFILL_GUID);
}
assert mGUID != null;
AutofillProfile profile = PersonalDataManager.getInstance().getProfile(mGUID);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment