Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillAddress.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillAddress.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillAddress.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..56b66835159cd6b50e1bcb6e95788fd1130e6c6d |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillAddress.java |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.payments; |
| + |
| +import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| +import org.chromium.chrome.browser.payments.ui.PaymentOption; |
| +import org.chromium.mojom.payments.ShippingAddress; |
| + |
| +/** |
| + * The locally stored autofill address. |
| + */ |
| +public class AutofillAddress extends PaymentOption { |
| + private final AutofillProfile mProfile; |
| + |
| + /** |
| + * Builds for the autofill address. |
| + */ |
| + public AutofillAddress(AutofillProfile profile) { |
| + super(profile.getGUID(), profile.getFullName(), profile.getStreetAddress(), |
| + PaymentOption.NO_ICON); |
| + mProfile = profile; |
| + } |
| + |
| + /** |
| + * Returns the shipping address for mojo. |
| + */ |
| + public ShippingAddress toShippingAddress() { |
| + ShippingAddress result = new ShippingAddress(); |
| + |
| + result.regionCode = mProfile.getCountryCode(); |
| + result.addressLine = mProfile.getStreetAddress().split("\n"); |
| + result.administrativeArea = mProfile.getRegion(); |
| + result.locality = mProfile.getLocality(); |
| + result.dependentLocality = mProfile.getDependentLocality(); |
| + result.postalCode = mProfile.getPostalCode(); |
| + result.sortingCode = mProfile.getSortingCode(); |
| + result.organization = mProfile.getCompanyName(); |
| + result.recipient = mProfile.getFullName(); |
| + |
| + String[] languageScriptCode = mProfile.getLanguageCode() == null |
| + ? new String[0] |
| + : mProfile.getLanguageCode().split("-"); |
| + result.languageCode = languageScriptCode.length > 0 ? languageScriptCode[0] : null; |
|
Ted C
2016/04/22 03:59:36
will try to see where this get used, but just an F
please use gerrit instead
2016/04/25 19:22:29
Thank you for the heads up. I think this language
|
| + result.scriptCode = languageScriptCode.length > 1 ? languageScriptCode[1] : null; |
| + |
| + return result; |
| + } |
| +} |