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 org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 7 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
8 import org.chromium.chrome.browser.payments.ui.PaymentOption; | 8 import org.chromium.chrome.browser.payments.ui.PaymentOption; |
9 import org.chromium.mojom.payments.ShippingAddress; | 9 import org.chromium.mojom.payments.PaymentAddress; |
10 | 10 |
11 import java.util.regex.Matcher; | 11 import java.util.regex.Matcher; |
12 import java.util.regex.Pattern; | 12 import java.util.regex.Pattern; |
13 | 13 |
14 /** | 14 /** |
15 * The locally stored autofill address. | 15 * The locally stored autofill address. |
16 */ | 16 */ |
17 public class AutofillAddress extends PaymentOption { | 17 public class AutofillAddress extends PaymentOption { |
18 /** | 18 /** |
19 * The pattern for a valid region code. | 19 * The pattern for a valid region code. |
(...skipping 27 matching lines...) Expand all Loading... |
47 assert profile.getSortingCode() != null : "Sorting code should not be nu
ll"; | 47 assert profile.getSortingCode() != null : "Sorting code should not be nu
ll"; |
48 assert profile.getCompanyName() != null : "Company name should not be nu
ll"; | 48 assert profile.getCompanyName() != null : "Company name should not be nu
ll"; |
49 assert profile.getFullName() != null : "Full name should not be null"; | 49 assert profile.getFullName() != null : "Full name should not be null"; |
50 | 50 |
51 mProfile = profile; | 51 mProfile = profile; |
52 } | 52 } |
53 | 53 |
54 /** | 54 /** |
55 * Returns the shipping address for mojo. | 55 * Returns the shipping address for mojo. |
56 */ | 56 */ |
57 public ShippingAddress toShippingAddress() { | 57 public PaymentAddress toPaymentAddress() { |
58 ShippingAddress result = new ShippingAddress(); | 58 PaymentAddress result = new PaymentAddress(); |
59 | 59 |
60 result.regionCode = mProfile.getCountryCode(); | 60 result.regionCode = mProfile.getCountryCode(); |
61 result.addressLine = mProfile.getStreetAddress().split("\n"); | 61 result.addressLine = mProfile.getStreetAddress().split("\n"); |
62 result.administrativeArea = mProfile.getRegion(); | 62 result.administrativeArea = mProfile.getRegion(); |
63 result.locality = mProfile.getLocality(); | 63 result.locality = mProfile.getLocality(); |
64 result.dependentLocality = mProfile.getDependentLocality(); | 64 result.dependentLocality = mProfile.getDependentLocality(); |
65 result.postalCode = mProfile.getPostalCode(); | 65 result.postalCode = mProfile.getPostalCode(); |
66 result.sortingCode = mProfile.getSortingCode(); | 66 result.sortingCode = mProfile.getSortingCode(); |
67 result.organization = mProfile.getCompanyName(); | 67 result.organization = mProfile.getCompanyName(); |
68 result.recipient = mProfile.getFullName(); | 68 result.recipient = mProfile.getFullName(); |
(...skipping 11 matching lines...) Expand all Loading... |
80 String languageCode = mLanguageScriptCodeMatcher.group(LANGUAGE_CODE
_GROUP); | 80 String languageCode = mLanguageScriptCodeMatcher.group(LANGUAGE_CODE
_GROUP); |
81 result.languageCode = languageCode != null ? languageCode : ""; | 81 result.languageCode = languageCode != null ? languageCode : ""; |
82 | 82 |
83 String scriptCode = mLanguageScriptCodeMatcher.group(SCRIPT_CODE_GRO
UP); | 83 String scriptCode = mLanguageScriptCodeMatcher.group(SCRIPT_CODE_GRO
UP); |
84 result.scriptCode = scriptCode != null ? scriptCode : ""; | 84 result.scriptCode = scriptCode != null ? scriptCode : ""; |
85 } | 85 } |
86 | 86 |
87 return result; | 87 return result; |
88 } | 88 } |
89 } | 89 } |
OLD | NEW |