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

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

Issue 1904553003: Java implementation of PaymentRequest mojo service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable Pay button before user provided required information. Created 4 years, 8 months 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/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;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698