| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentApp.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentApp.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentApp.java
|
| index 1744b28f9b65ac99ebc710ed90362188633db15e..fedac1322bb44bf9a02c62ca533419e15461125b 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentApp.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentApp.java
|
| @@ -10,7 +10,6 @@ import org.chromium.content_public.browser.WebContents;
|
| import org.chromium.payments.mojom.PaymentItem;
|
| import org.chromium.payments.mojom.PaymentMethodData;
|
|
|
| -import java.util.ArrayList;
|
| import java.util.Collections;
|
| import java.util.HashSet;
|
| import java.util.List;
|
| @@ -21,50 +20,42 @@ import java.util.Set;
|
| * This app class represents a service worker based payment app.
|
| *
|
| * Such apps are implemented as service workers according to the Payment
|
| - * App API specification.
|
| + * Handler API specification.
|
| *
|
| - * @see https://w3c.github.io/webpayments-payment-apps-api/
|
| + * @see https://w3c.github.io/webpayments-payment-handler/
|
| */
|
| public class ServiceWorkerPaymentApp implements PaymentApp {
|
| private final WebContents mWebContents;
|
| - private final ServiceWorkerPaymentAppBridge.Manifest mManifest;
|
| + private final List<PaymentInstrument> mInstruments;
|
| private final Set<String> mMethodNames;
|
|
|
| /**
|
| - * Build a service worker payment app instance based on an installed manifest.
|
| + * Build a service worker payment app instance per origin.
|
| *
|
| - * @see https://w3c.github.io/webpayments-payment-apps-api/#payment-app-manifest
|
| + * @see https://w3c.github.io/webpayments-payment-handler/#structure-of-a-web-payment-app
|
| *
|
| * @param webContents The web contents where PaymentRequest was invoked.
|
| - * @param manifest A manifest that describes this payment app.
|
| + * @param instruments A list of payment instruments supported by the payment app.
|
| */
|
| - public ServiceWorkerPaymentApp(
|
| - WebContents webContents, ServiceWorkerPaymentAppBridge.Manifest manifest) {
|
| + public ServiceWorkerPaymentApp(WebContents webContents, List<PaymentInstrument> instruments) {
|
| mWebContents = webContents;
|
| - mManifest = manifest;
|
| + mInstruments = instruments;
|
|
|
| mMethodNames = new HashSet<>();
|
| - for (ServiceWorkerPaymentAppBridge.Option option : manifest.options) {
|
| - mMethodNames.addAll(option.enabledMethods);
|
| + for (PaymentInstrument instrument : instruments) {
|
| + mMethodNames.addAll(instrument.getInstrumentMethodNames());
|
| }
|
| }
|
|
|
| @Override
|
| public void getInstruments(Map<String, PaymentMethodData> unusedMethodDataMap,
|
| String unusedOrigin, String unusedIFrameOrigin, byte[][] unusedCertificateChain,
|
| - PaymentItem unusedTotal, final InstrumentsCallback callback) {
|
| - final List<PaymentInstrument> instruments =
|
| - new ArrayList<PaymentInstrument>();
|
| -
|
| - for (ServiceWorkerPaymentAppBridge.Option option : mManifest.options) {
|
| - instruments.add(new ServiceWorkerPaymentInstrument(
|
| - mWebContents, mManifest.registrationId, option));
|
| - }
|
| -
|
| + PaymentItem unusedItem, final InstrumentsCallback callback) {
|
| new Handler().post(new Runnable() {
|
| @Override
|
| public void run() {
|
| - callback.onInstrumentsReady(ServiceWorkerPaymentApp.this, instruments);
|
| + callback.onInstrumentsReady(
|
| + ServiceWorkerPaymentApp.this, Collections.unmodifiableList(mInstruments));
|
| }
|
| });
|
| }
|
|
|