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.PaymentAddress; | 9 import org.chromium.mojom.payments.PaymentAddress; |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... | |
40 : "Country code should be in valid format"; | 40 : "Country code should be in valid format"; |
41 | 41 |
42 assert profile.getStreetAddress() != null : "Street address should not b e null"; | 42 assert profile.getStreetAddress() != null : "Street address should not b e null"; |
43 assert profile.getRegion() != null : "Region should not be null"; | 43 assert profile.getRegion() != null : "Region should not be null"; |
44 assert profile.getLocality() != null : "Locality should not be null"; | 44 assert profile.getLocality() != null : "Locality should not be null"; |
45 assert profile.getDependentLocality() != null : "Dependent locality shou ld not be null"; | 45 assert profile.getDependentLocality() != null : "Dependent locality shou ld not be null"; |
46 assert profile.getPostalCode() != null : "Postal code should not be null "; | 46 assert profile.getPostalCode() != null : "Postal code should not be null "; |
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 assert profile.getPhoneNumber() != null : "Phone number should not be nu ll"; | |
please use gerrit instead
2016/06/06 17:35:48
To avoid hitting this assert, you should check for
zino
2016/06/06 18:02:17
Done.
| |
50 | 51 |
51 mProfile = profile; | 52 mProfile = profile; |
52 } | 53 } |
53 | 54 |
54 /** | 55 /** |
55 * Returns the shipping address for mojo. | 56 * Returns the shipping address for mojo. |
56 */ | 57 */ |
57 public PaymentAddress toPaymentAddress() { | 58 public PaymentAddress toPaymentAddress() { |
58 PaymentAddress result = new PaymentAddress(); | 59 PaymentAddress result = new PaymentAddress(); |
59 | 60 |
60 result.regionCode = mProfile.getCountryCode(); | 61 result.country = mProfile.getCountryCode(); |
61 result.addressLine = mProfile.getStreetAddress().split("\n"); | 62 result.addressLine = mProfile.getStreetAddress().split("\n"); |
62 result.administrativeArea = mProfile.getRegion(); | 63 result.region = mProfile.getRegion(); |
63 result.locality = mProfile.getLocality(); | 64 result.city = mProfile.getLocality(); |
64 result.dependentLocality = mProfile.getDependentLocality(); | 65 result.dependentLocality = mProfile.getDependentLocality(); |
65 result.postalCode = mProfile.getPostalCode(); | 66 result.postalCode = mProfile.getPostalCode(); |
66 result.sortingCode = mProfile.getSortingCode(); | 67 result.sortingCode = mProfile.getSortingCode(); |
67 result.organization = mProfile.getCompanyName(); | 68 result.organization = mProfile.getCompanyName(); |
68 result.recipient = mProfile.getFullName(); | 69 result.recipient = mProfile.getFullName(); |
69 result.languageCode = ""; | 70 result.languageCode = ""; |
70 result.scriptCode = ""; | 71 result.scriptCode = ""; |
72 result.careOf = ""; | |
73 result.phone = mProfile.getPhoneNumber(); | |
71 | 74 |
72 if (mProfile.getLanguageCode() == null) return result; | 75 if (mProfile.getLanguageCode() == null) return result; |
73 | 76 |
74 if (mLanguageScriptCodeMatcher == null) { | 77 if (mLanguageScriptCodeMatcher == null) { |
75 mLanguageScriptCodeMatcher = Pattern.compile(LANGUAGE_SCRIPT_CODE_PA TTERN) | 78 mLanguageScriptCodeMatcher = Pattern.compile(LANGUAGE_SCRIPT_CODE_PA TTERN) |
76 .matcher(mProfile.getLanguageCo de()); | 79 .matcher(mProfile.getLanguageCo de()); |
77 } | 80 } |
78 | 81 |
79 if (mLanguageScriptCodeMatcher.matches()) { | 82 if (mLanguageScriptCodeMatcher.matches()) { |
80 String languageCode = mLanguageScriptCodeMatcher.group(LANGUAGE_CODE _GROUP); | 83 String languageCode = mLanguageScriptCodeMatcher.group(LANGUAGE_CODE _GROUP); |
81 result.languageCode = languageCode != null ? languageCode : ""; | 84 result.languageCode = languageCode != null ? languageCode : ""; |
82 | 85 |
83 String scriptCode = mLanguageScriptCodeMatcher.group(SCRIPT_CODE_GRO UP); | 86 String scriptCode = mLanguageScriptCodeMatcher.group(SCRIPT_CODE_GRO UP); |
84 result.scriptCode = scriptCode != null ? scriptCode : ""; | 87 result.scriptCode = scriptCode != null ? scriptCode : ""; |
85 } | 88 } |
86 | 89 |
87 return result; | 90 return result; |
88 } | 91 } |
89 } | 92 } |
OLD | NEW |