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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentInstrument.java

Issue 2586213002: PaymentApp: Implement nativeGetAllAppManifests (Closed)
Patch Set: Rebase Created 3 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.payments; 5 package org.chromium.chrome.browser.payments;
6 6
7 import org.chromium.content_public.browser.WebContents;
7 import org.chromium.payments.mojom.PaymentItem; 8 import org.chromium.payments.mojom.PaymentItem;
8 import org.chromium.payments.mojom.PaymentMethodData; 9 import org.chromium.payments.mojom.PaymentMethodData;
9 10
10 import java.util.Collections; 11 import java.util.Collections;
11 import java.util.HashSet; 12 import java.util.HashSet;
12 import java.util.List; 13 import java.util.List;
13 import java.util.Map; 14 import java.util.Map;
14 import java.util.Set; 15 import java.util.Set;
15 16
16 /** 17 /**
17 * This instrument class represents a single payment option for a service 18 * This instrument class represents a single payment option for a service
18 * worker based payment app. 19 * worker based payment app.
19 * 20 *
20 * @see org.chromium.chrome.browser.payments.ServiceWorkerPaymentApp 21 * @see org.chromium.chrome.browser.payments.ServiceWorkerPaymentApp
21 * 22 *
22 * @see https://w3c.github.io/webpayments-payment-apps-api/ 23 * @see https://w3c.github.io/webpayments-payment-apps-api/
23 */ 24 */
24 public class ServiceWorkerPaymentInstrument extends PaymentInstrument { 25 public class ServiceWorkerPaymentInstrument extends PaymentInstrument {
26 private final WebContents mWebContents;
27 private final long mAppRegistrationId;
25 private final ServiceWorkerPaymentAppBridge.Option mOption; 28 private final ServiceWorkerPaymentAppBridge.Option mOption;
26 private final Set<String> mMethodNames; 29 private final Set<String> mMethodNames;
27 30
28 /** 31 /**
29 * Build a service worker based payment instrument based on a single payment option 32 * Build a service worker based payment instrument based on a single payment option
30 * of an installed payment app. 33 * of an installed payment app.
31 * 34 *
32 * @see https://w3c.github.io/webpayments-payment-apps-api/#payment-app-opti ons 35 * @see https://w3c.github.io/webpayments-payment-apps-api/#payment-app-opti ons
33 * 36 *
34 * @param scopeUrl The scope url of the corresponding service worker paym ent app. 37 * @param webContents The web contents where PaymentRequest was invoke d.
35 * @param option A payment app option from the payment app. 38 * @param appRegistrationId The registration id of the corresponding service worker payment app.
39 * @param option A payment app option from the payment app.
36 */ 40 */
37 public ServiceWorkerPaymentInstrument(String scopeUrl, 41 public ServiceWorkerPaymentInstrument(WebContents webContents, long appRegis trationId,
38 ServiceWorkerPaymentAppBridge.Option option) { 42 ServiceWorkerPaymentAppBridge.Option option) {
39 super(scopeUrl + "#" + option.id, option.label, null /* icon */, option. icon); 43 super(Long.toString(appRegistrationId) + "#" + option.id, option.label, null /* icon */,
44 option.icon);
45 mWebContents = webContents;
46 mAppRegistrationId = appRegistrationId;
40 mOption = option; 47 mOption = option;
41 48
42 mMethodNames = new HashSet<String>(option.enabledMethods); 49 mMethodNames = new HashSet<String>(option.enabledMethods);
43 } 50 }
44 51
45 @Override 52 @Override
46 public Set<String> getInstrumentMethodNames() { 53 public Set<String> getInstrumentMethodNames() {
47 return Collections.unmodifiableSet(mMethodNames); 54 return Collections.unmodifiableSet(mMethodNames);
48 } 55 }
49 56
50 @Override 57 @Override
51 public void invokePaymentApp(String merchantName, String origin, PaymentItem total, 58 public void invokePaymentApp(String merchantName, String origin, PaymentItem total,
52 List<PaymentItem> cart, Map<String, PaymentMethodData> methodData, 59 List<PaymentItem> cart, Map<String, PaymentMethodData> methodData,
53 InstrumentDetailsCallback callback) { 60 InstrumentDetailsCallback callback) {
54 // TODO(tommyt): crbug.com/669876. Implement this for use with Service W orker Payment Apps. 61 ServiceWorkerPaymentAppBridge.invokePaymentApp(
55 callback.onInstrumentDetailsError(); 62 mWebContents, mAppRegistrationId, mOption.id, new HashSet<>(meth odData.values()));
56 } 63 }
57 64
58 @Override 65 @Override
59 public void dismissInstrument() {} 66 public void dismissInstrument() {}
60 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698