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..1cc27d316b9b329a502e192a1ecb1cabf63bf444 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,8 +4,6 @@ |
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; |
@@ -14,6 +12,7 @@ import org.chromium.payments.mojom.PaymentItem; |
import org.chromium.payments.mojom.PaymentMethodData; |
import java.util.ArrayList; |
+import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
@@ -25,41 +24,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 +53,19 @@ 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; |
- } |
- |
- @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; |
+ private static List<PaymentInstrument> createInstrumentList() { |
+ return new ArrayList<PaymentInstrument>(); |
} |
@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[] methodNameArray) { |
+ Set<String> methodNames = new HashSet<String>(); |
+ for (int i = 0; i < methodNameArray.length; i++) { |
+ methodNames.add(methodNameArray[i]); |
+ } |
+ instruments.add(new ServiceWorkerPaymentInstrument( |
+ webContents, swRegistrationId, instrumentId, label, methodNames)); |
} |
@CalledByNative |
@@ -147,14 +104,15 @@ public class ServiceWorkerPaymentAppBridge implements PaymentAppFactory.PaymentA |
} |
@CalledByNative |
- private static void onGotManifest(Manifest manifest, WebContents webContents, Object callback) { |
+ private static void onPaymentAppCreated( |
+ List<PaymentInstrument> instruments, WebContents webContents, Object callback) { |
assert callback instanceof PaymentAppFactory.PaymentAppCreatedCallback; |
((PaymentAppFactory.PaymentAppCreatedCallback) callback) |
- .onPaymentAppCreated(new ServiceWorkerPaymentApp(webContents, manifest)); |
+ .onPaymentAppCreated(new ServiceWorkerPaymentApp(webContents, instruments)); |
} |
@CalledByNative |
- private static void onGotAllManifests(Object callback) { |
+ private static void onAllPaymentAppsCreated(Object callback) { |
assert callback instanceof PaymentAppFactory.PaymentAppCreatedCallback; |
((PaymentAppFactory.PaymentAppCreatedCallback) callback).onAllPaymentAppsCreated(); |
} |
@@ -173,10 +131,10 @@ 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 |
+ * be of type PaymentInstrument.InstrumentDetailsCallback, once this JNI bug |
* has been resolved. |
*/ |
- private static native void nativeGetAllAppManifests(WebContents webContents, Object callback); |
+ private static native void nativeGetAllPaymentApps(WebContents webContents, Object callback); |
/* |
* TODO(tommyt): crbug.com/505554. Change the |callback| parameter below to |