Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java |
| index 597a23c0599bb49695ef2899b2c128c8620a58b3..d818d30f6b7e73465b6da01efefbd8f332d3d2ab 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java |
| @@ -6,7 +6,6 @@ package org.chromium.chrome.browser.payments; |
| import android.os.Handler; |
| import android.telephony.PhoneNumberUtils; |
| -import android.text.TextUtils; |
| import android.util.Pair; |
| import org.chromium.base.Callback; |
| @@ -43,31 +42,6 @@ public class AddressEditor extends EditorBase<AutofillAddress> { |
| @Nullable private List<AddressUiComponent> mAddressUiComponents; |
| /** |
| - * Returns whether the given profile can be sent to the merchant as-is without editing first. If |
| - * the country code is not set or invalid, but all fields for the default locale's country code |
| - * are present, then the profile is deemed "complete." AutoflllAddress.toPaymentAddress() will |
| - * use the default locale to fill in a blank country code before sending the address to the |
| - * renderer. |
| - * |
| - * @param profile The profile to check. |
| - * @return Whether the profile is complete. |
| - */ |
| - public boolean isProfileComplete(@Nullable AutofillProfile profile) { |
| - if (profile == null || TextUtils.isEmpty(profile.getFullName()) |
| - || !getPhoneValidator().isValid(profile.getPhoneNumber())) { |
| - return false; |
| - } |
| - |
| - List<Integer> requiredFields = AutofillProfileBridge.getRequiredAddressFields( |
| - AutofillAddress.getCountryCode(profile)); |
| - for (int i = 0; i < requiredFields.size(); i++) { |
| - if (TextUtils.isEmpty(getProfileField(profile, requiredFields.get(i)))) return false; |
| - } |
| - |
| - return true; |
| - } |
| - |
| - /** |
| * Adds the given phone number to the autocomplete set, if it's valid. |
| * |
| * @param phoneNumber The phone number to possibly add. |
| @@ -98,16 +72,15 @@ public class AddressEditor extends EditorBase<AutofillAddress> { |
| boolean isNewAddress = toEdit == null; |
| // Ensure that |address| and |profile| are always not null. |
| - final AutofillAddress address = isNewAddress |
| - ? new AutofillAddress(new AutofillProfile(), false) |
| - : toEdit; |
| + final AutofillAddress address = |
| + isNewAddress ? new AutofillAddress(mContext, new AutofillProfile()) : toEdit; |
| final AutofillProfile profile = address.getProfile(); |
| // The title of the editor depends on whether we're adding a new address or editing an |
| // existing address. |
| - final EditorModel editor = new EditorModel(mContext.getString(isNewAddress |
| - ? R.string.autofill_create_profile |
| - : R.string.autofill_edit_profile)); |
| + final EditorModel editor = |
| + new EditorModel(isNewAddress |
| + ? mContext.getString(R.string.autofill_create_profile) : toEdit.getEditTitle()); |
|
Ted C
2016/11/08 22:14:06
+4 indent
gogerald1
2016/11/09 01:42:46
Done.
|
| // The country dropdown is always present on the editor. |
| if (mCountryField == null) { |
| @@ -170,7 +143,7 @@ public class AddressEditor extends EditorBase<AutofillAddress> { |
| // Address fields are cached, so their values need to be updated for every new profile |
| // that's being edited. |
| for (Map.Entry<Integer, EditorFieldModel> entry : mAddressFields.entrySet()) { |
| - entry.getValue().setValue(getProfileField(profile, entry.getKey())); |
| + entry.getValue().setValue(AutofillAddress.getProfileField(profile, entry.getKey())); |
| } |
| // Both country code and language code dictate which fields should be added to the editor. |
| @@ -252,34 +225,6 @@ public class AddressEditor extends EditorBase<AutofillAddress> { |
| profile.setGUID(pdm.setProfile(profile)); |
| } |
| - /** @return The given autofill profile field. */ |
| - private static String getProfileField(AutofillProfile profile, int field) { |
| - assert profile != null; |
| - switch (field) { |
| - case AddressField.COUNTRY: |
| - return profile.getCountryCode(); |
| - case AddressField.ADMIN_AREA: |
| - return profile.getRegion(); |
| - case AddressField.LOCALITY: |
| - return profile.getLocality(); |
| - case AddressField.DEPENDENT_LOCALITY: |
| - return profile.getDependentLocality(); |
| - case AddressField.SORTING_CODE: |
| - return profile.getSortingCode(); |
| - case AddressField.POSTAL_CODE: |
| - return profile.getPostalCode(); |
| - case AddressField.STREET_ADDRESS: |
| - return profile.getStreetAddress(); |
| - case AddressField.ORGANIZATION: |
| - return profile.getCompanyName(); |
| - case AddressField.RECIPIENT: |
| - return profile.getFullName(); |
| - } |
| - |
| - assert false; |
| - return null; |
| - } |
| - |
| /** Writes the given value into the specified autofill profile field. */ |
| private static void setProfileField( |
| AutofillProfile profile, int field, @Nullable CharSequence value) { |