| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentAppBridge.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentAppBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentAppBridge.java
|
| index 4d41d73939cea5145210d14598763ab1ae71d8fd..988753b09301286f7f7e5e5c1c0e612f928c1423 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentAppBridge.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentAppBridge.java
|
| @@ -4,16 +4,17 @@
|
|
|
| package org.chromium.chrome.browser.payments;
|
|
|
| -import android.graphics.drawable.Drawable;
|
| -
|
| import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.base.annotations.SuppressFBWarnings;
|
| import org.chromium.content_public.browser.WebContents;
|
| +import org.chromium.chrome.browser.payments.PaymentAppFactory;
|
| import org.chromium.payments.mojom.PaymentDetailsModifier;
|
| import org.chromium.payments.mojom.PaymentItem;
|
| import org.chromium.payments.mojom.PaymentMethodData;
|
|
|
| import java.util.ArrayList;
|
| +import java.util.Arrays;
|
| +import java.util.HashSet;
|
| import java.util.List;
|
| import java.util.Set;
|
|
|
| @@ -25,41 +26,10 @@ import java.util.Set;
|
| @SuppressFBWarnings({"UWF_NULL_FIELD", "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD",
|
| "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"})
|
| public class ServiceWorkerPaymentAppBridge implements PaymentAppFactory.PaymentAppFactoryAddition {
|
| - /**
|
| - * This class represents a payment app manifest as defined in the Payment
|
| - * App API specification.
|
| - *
|
| - * @see https://w3c.github.io/webpayments-payment-apps-api/#payment-app-manifest
|
| - */
|
| - public static class Manifest {
|
| - /**
|
| - * The registration ID of the service worker.
|
| - *
|
| - * This can be used to identify a service worker based payment app.
|
| - */
|
| - public long registrationId;
|
| - public String label;
|
| - public Drawable icon;
|
| - public List<Option> options = new ArrayList<>();
|
| - }
|
| -
|
| - /**
|
| - * This class represents a payment option as defined in the Payment App API
|
| - * specification.
|
| - *
|
| - * @see https://w3c.github.io/webpayments-payment-apps-api/#payment-app-options
|
| - */
|
| - public static class Option {
|
| - public String id;
|
| - public String label;
|
| - public Drawable icon;
|
| - public List<String> enabledMethods = new ArrayList<>();
|
| - }
|
| -
|
| @Override
|
| public void create(WebContents webContents, Set<String> methodNames,
|
| PaymentAppFactory.PaymentAppCreatedCallback callback) {
|
| - nativeGetAllAppManifests(webContents, callback);
|
| + nativeGetAllPaymentApps(webContents, callback);
|
| }
|
|
|
| /**
|
| @@ -85,30 +55,15 @@ public class ServiceWorkerPaymentAppBridge implements PaymentAppFactory.PaymentA
|
| }
|
|
|
| @CalledByNative
|
| - private static Manifest createManifest(long registrationId, String label, String icon) {
|
| - Manifest manifest = new Manifest();
|
| - manifest.registrationId = registrationId;
|
| - manifest.label = label;
|
| - // TODO(tommyt): crbug.com/669876. Handle icons.
|
| - manifest.icon = null;
|
| - return manifest;
|
| + private static List<PaymentInstrument> createInstrumentList() {
|
| + return new ArrayList<PaymentInstrument>();
|
| }
|
|
|
| @CalledByNative
|
| - private static Option createAndAddOption(
|
| - Manifest manifest, String id, String label, String icon) {
|
| - Option option = new Option();
|
| - option.id = id;
|
| - option.label = label;
|
| - // TODO(tommyt): crbug.com/669876. Handle icons.
|
| - option.icon = null;
|
| - manifest.options.add(option);
|
| - return option;
|
| - }
|
| -
|
| - @CalledByNative
|
| - private static void addEnabledMethod(Option option, String enabledMethod) {
|
| - option.enabledMethods.add(enabledMethod);
|
| + private static void addInstrument(List<PaymentInstrument> instruments, WebContents webContents,
|
| + long swRegistrationId, String instrumentId, String label, String[] methodNames) {
|
| + instruments.add(new ServiceWorkerPaymentInstrument(webContents, swRegistrationId,
|
| + instrumentId, label, new HashSet<String>(Arrays.asList(methodNames))));
|
| }
|
|
|
| @CalledByNative
|
| @@ -147,16 +102,15 @@ public class ServiceWorkerPaymentAppBridge implements PaymentAppFactory.PaymentA
|
| }
|
|
|
| @CalledByNative
|
| - private static void onGotManifest(Manifest manifest, WebContents webContents, Object callback) {
|
| - assert callback instanceof PaymentAppFactory.PaymentAppCreatedCallback;
|
| - ((PaymentAppFactory.PaymentAppCreatedCallback) callback)
|
| - .onPaymentAppCreated(new ServiceWorkerPaymentApp(webContents, manifest));
|
| + private static void onPaymentAppCreated(List<PaymentInstrument> instruments,
|
| + WebContents webContents, PaymentAppFactory.PaymentAppCreatedCallback callback) {
|
| + callback.onPaymentAppCreated(new ServiceWorkerPaymentApp(webContents, instruments));
|
| }
|
|
|
| @CalledByNative
|
| - private static void onGotAllManifests(Object callback) {
|
| - assert callback instanceof PaymentAppFactory.PaymentAppCreatedCallback;
|
| - ((PaymentAppFactory.PaymentAppCreatedCallback) callback).onAllPaymentAppsCreated();
|
| + private static void onAllPaymentAppsCreated(
|
| + PaymentAppFactory.PaymentAppCreatedCallback callback) {
|
| + callback.onAllPaymentAppsCreated();
|
| }
|
|
|
| @CalledByNative
|
| @@ -171,12 +125,8 @@ public class ServiceWorkerPaymentAppBridge implements PaymentAppFactory.PaymentA
|
| }
|
| }
|
|
|
| - /*
|
| - * TODO(tommyt): crbug.com/505554. Change the |callback| parameter below to
|
| - * be of type PaymentAppFactory.PaymentAppCreatedCallback, once this JNI bug
|
| - * has been resolved.
|
| - */
|
| - private static native void nativeGetAllAppManifests(WebContents webContents, Object callback);
|
| + private static native void nativeGetAllPaymentApps(
|
| + WebContents webContents, PaymentAppFactory.PaymentAppCreatedCallback callback);
|
|
|
| /*
|
| * TODO(tommyt): crbug.com/505554. Change the |callback| parameter below to
|
|
|