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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java

Issue 2482533002: [Payments] Display warning messages for incomplete shipping address and update editor title (Closed)
Patch Set: refactor function Created 4 years, 1 month 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/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..e14bc1781b9469c1242fe430c9a8aa27064ee2ab 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,16 @@ 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());
// The country dropdown is always present on the editor.
if (mCountryField == null) {
@@ -170,7 +144,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 +226,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) {

Powered by Google App Engine
This is Rietveld 408576698