| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
| 6 | 6 |
| 7 import android.text.TextUtils; | 7 import android.text.TextUtils; |
| 8 | 8 |
| 9 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 9 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| 10 import org.chromium.chrome.browser.payments.ui.PaymentOption; | 10 import org.chromium.chrome.browser.payments.ui.PaymentOption; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 mIsComplete = isComplete; | 45 mIsComplete = isComplete; |
| 46 } | 46 } |
| 47 | 47 |
| 48 /** @return The autofill profile where this address data lives. */ | 48 /** @return The autofill profile where this address data lives. */ |
| 49 public AutofillProfile getProfile() { | 49 public AutofillProfile getProfile() { |
| 50 return mProfile; | 50 return mProfile; |
| 51 } | 51 } |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * Updates the address and marks it "complete." Called after the user has ed
ited this address. | 54 * Updates the address and marks it "complete." Called after the user has ed
ited this address. |
| 55 * Updates the label and sublabel. | 55 * Updates the identifier, label, and sublabel. |
| 56 * | 56 * |
| 57 * @param profile The new profile to use. The GUID should not change. | 57 * @param profile The new profile to use. |
| 58 */ | 58 */ |
| 59 public void completeAddress(AutofillProfile profile) { | 59 public void completeAddress(AutofillProfile profile) { |
| 60 assert profile.getGUID().equals(mProfile.getGUID()); | |
| 61 mProfile = profile; | 60 mProfile = profile; |
| 62 mIsComplete = true; | 61 mIsComplete = true; |
| 63 updateLabels(mProfile.getFullName(), mProfile.getLabel()); | 62 updateIdentifierAndLabels(mProfile.getGUID(), mProfile.getFullName(), mP
rofile.getLabel()); |
| 64 } | 63 } |
| 65 | 64 |
| 66 /** @return The country code to use, e.g., when constructing an editor for t
his address. */ | 65 /** @return The country code to use, e.g., when constructing an editor for t
his address. */ |
| 67 public static String getCountryCode(@Nullable AutofillProfile profile) { | 66 public static String getCountryCode(@Nullable AutofillProfile profile) { |
| 68 if (sRegionCodePattern == null) sRegionCodePattern = Pattern.compile(REG
ION_CODE_PATTERN); | 67 if (sRegionCodePattern == null) sRegionCodePattern = Pattern.compile(REG
ION_CODE_PATTERN); |
| 69 | 68 |
| 70 return profile == null || TextUtils.isEmpty(profile.getCountryCode()) | 69 return profile == null || TextUtils.isEmpty(profile.getCountryCode()) |
| 71 || !sRegionCodePattern.matcher(profile.getCountryCode())
.matches() | 70 || !sRegionCodePattern.matcher(profile.getCountryCode())
.matches() |
| 72 ? Locale.getDefault().getCountry() : profile.getCountryCode(); | 71 ? Locale.getDefault().getCountry() : profile.getCountryCode(); |
| 73 } | 72 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 103 result.scriptCode = ensureNotNull(matcher.group(SCRIPT_CODE_GROUP)); | 102 result.scriptCode = ensureNotNull(matcher.group(SCRIPT_CODE_GROUP)); |
| 104 } | 103 } |
| 105 | 104 |
| 106 return result; | 105 return result; |
| 107 } | 106 } |
| 108 | 107 |
| 109 private static String ensureNotNull(@Nullable String value) { | 108 private static String ensureNotNull(@Nullable String value) { |
| 110 return value == null ? "" : value; | 109 return value == null ? "" : value; |
| 111 } | 110 } |
| 112 } | 111 } |
| OLD | NEW |