Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/WebBasedPaymentInstrument.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/WebBasedPaymentInstrument.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/WebBasedPaymentInstrument.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..54dba1591a1e342bbc869d69798692024ad9f389 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/WebBasedPaymentInstrument.java |
| @@ -0,0 +1,70 @@ |
| +// 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 android.content.Context; |
| + |
| +import org.chromium.content_public.browser.WebContents; |
| +import org.chromium.payments.mojom.PaymentItem; |
| +import org.chromium.payments.mojom.PaymentMethodData; |
| + |
| +import java.util.HashSet; |
| +import java.util.List; |
| +import java.util.Map; |
| +import java.util.Set; |
| + |
| +/** |
| + * This instrument class represents a single payment option for a web based |
| + * payment app. |
| + * |
| + * @see org.chromium.chrome.browser.payments.WebBasedPaymentApp |
| + * |
| + * @see https://w3c.github.io/webpayments-payment-apps-api/ |
| + */ |
| +public class WebBasedPaymentInstrument extends PaymentInstrument { |
| + private final Context mContext; |
| + private final WebContents mWebContents; |
| + private final String mAppId; |
| + private final WebBasedPaymentAppBridge.Option mOption; |
| + private final Set<String> mMethodNames; |
| + |
| + /** |
| + * Build a web based payment instrument based on a single payment option of |
| + * an installed payment app. |
| + * |
| + * @see https://w3c.github.io/webpayments-payment-apps-api/#payment-app-options |
| + * |
| + * @param context The context. |
| + * @param webContents The web contents where PaymentRequest was invoked. |
| + * @param appId A string that uniquely represents the corresponding payment app. |
| + * @param option A payment app option from the payment app. |
| + */ |
| + public WebBasedPaymentInstrument(Context context, WebContents webContents, |
| + String appId, WebBasedPaymentAppBridge.Option option) { |
| + super(appId + "#" + option.id, option.label, null, option.icon); |
|
please use gerrit instead
2016/11/29 14:28:44
Add a comment next to null indicating the paramete
tommyt
2016/11/30 13:44:39
Done.
|
| + mContext = context; |
| + mWebContents = webContents; |
| + mAppId = appId; |
| + mOption = option; |
| + |
| + mMethodNames = new HashSet<String>(option.enabledMethods); |
| + } |
| + |
| + @Override |
| + public Set<String> getInstrumentMethodNames() { |
| + return mMethodNames; |
|
please use gerrit instead
2016/11/29 14:28:44
Collections.unmodifiableSet()
tommyt
2016/11/30 13:44:39
Done.
|
| + } |
| + |
| + @Override |
| + public void invokePayment(String merchantName, String origin, PaymentItem total, |
| + List<PaymentItem> cart, Map<String, PaymentMethodData> methodData, |
| + InstrumentDetailsCallback callback) { |
| + // TODO(tommyt): Implement this for use with Web Based Payment Apps. |
|
please use gerrit instead
2016/11/29 14:28:44
TODO should have a bug link. File a bug, assign to
tommyt
2016/11/30 13:44:39
Done.
|
| + callback.onInstrumentDetailsError(); |
| + } |
| + |
| + @Override |
| + public void dismissInstrument() {} |
| +} |