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..1d0bb8c0e3ed513e84e4538c9c1f7cfc3239a18e |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/WebBasedPaymentInstrument.java |
| @@ -0,0 +1,73 @@ |
| +// 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.PaymentAppManifest; |
| +import org.chromium.payments.mojom.PaymentAppOption; |
| +import org.chromium.payments.mojom.PaymentItem; |
| +import org.chromium.payments.mojom.PaymentMethodData; |
| + |
| +import java.util.Arrays; |
| +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 PaymentAppManifest mManifest; |
|
zino
2016/11/27 18:41:23
It's difficult to imagine use-case of this variabl
tommyt
2016/11/28 14:13:23
I've removed this member variable. It was used in
|
| + private final PaymentAppOption mOption; |
| + |
| + /** |
| + * Build a web based payment instrument based on a single payment option of |
| + * an installed payment app manifest. |
| + * |
| + * @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 manifest A manifest that describes the corresponding payment app. |
| + * @param option A payment app option from the manifest. |
| + */ |
| + public WebBasedPaymentInstrument(Context context, WebContents webContents, |
| + String appId, PaymentAppManifest manifest, PaymentAppOption option) { |
| + super(appId + "#" + option.id, option.label, null, null); |
| + mContext = context; |
| + mWebContents = webContents; |
| + mAppId = appId; |
| + mManifest = manifest; |
| + mOption = option; |
| + } |
| + |
| + @Override |
| + public Set<String> getInstrumentMethodNames() { |
| + return new HashSet<>(Arrays.asList(mOption.enabledMethods[0])); |
| + } |
| + |
| + @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. |
| + callback.onInstrumentDetailsError(); |
| + } |
| + |
| + @Override |
| + public void dismissInstrument() {} |
| +} |