OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.chrome.browser.payments; | |
6 | |
7 import android.content.Context; | |
8 | |
9 import org.chromium.content_public.browser.WebContents; | |
10 import org.chromium.payments.mojom.PaymentItem; | |
11 import org.chromium.payments.mojom.PaymentMethodData; | |
12 | |
13 import java.util.HashSet; | |
14 import java.util.List; | |
15 import java.util.Map; | |
16 import java.util.Set; | |
17 | |
18 /** | |
19 * This instrument class represents a single payment option for a web based | |
20 * payment app. | |
21 * | |
22 * @see org.chromium.chrome.browser.payments.WebBasedPaymentApp | |
23 * | |
24 * @see https://w3c.github.io/webpayments-payment-apps-api/ | |
25 */ | |
26 public class WebBasedPaymentInstrument extends PaymentInstrument { | |
27 private final Context mContext; | |
28 private final WebContents mWebContents; | |
29 private final String mAppId; | |
30 private final WebBasedPaymentAppBridge.Option mOption; | |
31 private final Set<String> mMethodNames; | |
32 | |
33 /** | |
34 * Build a web based payment instrument based on a single payment option of | |
35 * an installed payment app. | |
36 * | |
37 * @see https://w3c.github.io/webpayments-payment-apps-api/#payment-app-opti ons | |
38 * | |
39 * @param context The context. | |
40 * @param webContents The web contents where PaymentRequest was invoked. | |
41 * @param appId A string that uniquely represents the corresponding pa yment app. | |
42 * @param option A payment app option from the payment app. | |
43 */ | |
44 public WebBasedPaymentInstrument(Context context, WebContents webContents, | |
45 String appId, WebBasedPaymentAppBridge.Option option) { | |
46 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.
| |
47 mContext = context; | |
48 mWebContents = webContents; | |
49 mAppId = appId; | |
50 mOption = option; | |
51 | |
52 mMethodNames = new HashSet<String>(option.enabledMethods); | |
53 } | |
54 | |
55 @Override | |
56 public Set<String> getInstrumentMethodNames() { | |
57 return mMethodNames; | |
please use gerrit instead
2016/11/29 14:28:44
Collections.unmodifiableSet()
tommyt
2016/11/30 13:44:39
Done.
| |
58 } | |
59 | |
60 @Override | |
61 public void invokePayment(String merchantName, String origin, PaymentItem to tal, | |
62 List<PaymentItem> cart, Map<String, PaymentMethodData> methodData, | |
63 InstrumentDetailsCallback callback) { | |
64 // 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.
| |
65 callback.onInstrumentDetailsError(); | |
66 } | |
67 | |
68 @Override | |
69 public void dismissInstrument() {} | |
70 } | |
OLD | NEW |