Chromium Code Reviews| 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 93b007b9ceb0eb1ab43031b95dd456ae643af101..8390ec3418b7bc7ca124613e67463863063b21cb 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 |
| @@ -9,7 +9,6 @@ import android.os.Handler; |
| import org.chromium.content_public.browser.WebContents; |
| import org.chromium.payments.mojom.PaymentMethodData; |
| -import java.util.ArrayList; |
| import java.util.Collections; |
| import java.util.HashSet; |
| import java.util.List; |
| @@ -20,31 +19,30 @@ 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()); |
| } |
| } |
| @@ -52,18 +50,10 @@ public class ServiceWorkerPaymentApp implements PaymentApp { |
| public void getInstruments(Map<String, PaymentMethodData> unusedMethodDataMap, |
| String unusedOrigin, String unusedIFrameOrigin, byte[][] unusedCertificateChain, |
| final InstrumentsCallback callback) { |
| - final List<PaymentInstrument> instruments = |
| - new ArrayList<PaymentInstrument>(); |
| - |
| - for (ServiceWorkerPaymentAppBridge.Option option : mManifest.options) { |
| - instruments.add(new ServiceWorkerPaymentInstrument( |
| - mWebContents, mManifest.registrationId, option)); |
| - } |
| - |
| new Handler().post(new Runnable() { |
| @Override |
| public void run() { |
| - callback.onInstrumentsReady(ServiceWorkerPaymentApp.this, instruments); |
| + callback.onInstrumentsReady(ServiceWorkerPaymentApp.this, mInstruments); |
|
please use gerrit instead
2017/05/09 18:54:36
Collections.unmodifiableList(mInstruments)
zino
2017/05/10 18:28:39
Done.
|
| } |
| }); |
| } |