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 org.chromium.payments.mojom.PaymentItem; |
| 8 import org.chromium.payments.mojom.PaymentMethodData; |
| 9 |
| 10 import java.util.Collections; |
| 11 import java.util.HashSet; |
| 12 import java.util.List; |
| 13 import java.util.Map; |
| 14 import java.util.Set; |
| 15 |
| 16 /** |
| 17 * This instrument class represents a single payment option for a service |
| 18 * worker based payment app. |
| 19 * |
| 20 * @see org.chromium.chrome.browser.payments.ServiceWorkerPaymentApp |
| 21 * |
| 22 * @see https://w3c.github.io/webpayments-payment-apps-api/ |
| 23 */ |
| 24 public class ServiceWorkerPaymentInstrument extends PaymentInstrument { |
| 25 private final ServiceWorkerPaymentAppBridge.Option mOption; |
| 26 private final Set<String> mMethodNames; |
| 27 |
| 28 /** |
| 29 * Build a service worker based payment instrument based on a single payment
option |
| 30 * of an installed payment app. |
| 31 * |
| 32 * @see https://w3c.github.io/webpayments-payment-apps-api/#payment-app-opti
ons |
| 33 * |
| 34 * @param scopeUrl The scope url of the corresponding service worker paym
ent app. |
| 35 * @param option A payment app option from the payment app. |
| 36 */ |
| 37 public ServiceWorkerPaymentInstrument(String scopeUrl, |
| 38 ServiceWorkerPaymentAppBridge.Option option) { |
| 39 super(scopeUrl + "#" + option.id, option.label, null /* icon */, option.
icon); |
| 40 mOption = option; |
| 41 |
| 42 mMethodNames = new HashSet<String>(option.enabledMethods); |
| 43 } |
| 44 |
| 45 @Override |
| 46 public Set<String> getInstrumentMethodNames() { |
| 47 return Collections.unmodifiableSet(mMethodNames); |
| 48 } |
| 49 |
| 50 @Override |
| 51 public void invokePaymentApp(String merchantName, String origin, PaymentItem
total, |
| 52 List<PaymentItem> cart, Map<String, PaymentMethodData> methodData, |
| 53 InstrumentDetailsCallback callback) { |
| 54 // TODO(tommyt): crbug.com/669876. Implement this for use with Service W
orker Payment Apps. |
| 55 callback.onInstrumentDetailsError(); |
| 56 } |
| 57 |
| 58 @Override |
| 59 public void dismissInstrument() {} |
| 60 } |
OLD | NEW |