Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentAppFactory.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentAppFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentAppFactory.java |
index 06bf964172c65de8d180ec1d4b8670dbb0d33201..4d4b7ae2563cb34977c669c4757d5d9ad39a1115 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentAppFactory.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentAppFactory.java |
@@ -6,7 +6,9 @@ package org.chromium.chrome.browser.payments; |
import android.content.Context; |
+import org.chromium.base.CommandLine; |
import org.chromium.base.VisibleForTesting; |
+import org.chromium.chrome.browser.ChromeSwitches; |
import org.chromium.content_public.browser.WebContents; |
import java.util.ArrayList; |
@@ -22,6 +24,9 @@ public class PaymentAppFactory { |
*/ |
private static PaymentAppFactoryAddition sAdditionalFactory; |
+ private static ServiceWorkerPaymentAppBridge sServiceWorkerPaymentAppBridge = |
+ new ServiceWorkerPaymentAppBridge(); |
+ |
/** |
* The interface for additional payment app factories. |
*/ |
@@ -54,10 +59,29 @@ public class PaymentAppFactory { |
public static List<PaymentApp> create(Context context, WebContents webContents) { |
List<PaymentApp> result = new ArrayList<>(2); |
result.add(new AutofillPaymentApp(context, webContents)); |
+ |
+ if (CommandLine.getInstance().hasSwitch( |
please use gerrit instead
2016/11/30 15:08:28
The new way to add command line flags is base::Fea
tommyt
2016/12/01 13:55:49
Done.
|
+ ChromeSwitches.ENABLE_SERVICE_WORKER_PAYMENT_APPS)) { |
+ result.addAll(createServiceWorkerPaymentApps()); |
+ } |
+ |
if (sAdditionalFactory != null) { |
result.addAll( |
sAdditionalFactory.create(context, webContents)); |
} |
return result; |
} |
+ |
+ /** |
+ * Build a ServiceWorkerPaymentApp instance for each installed service |
+ * worker based payment app. |
+ */ |
+ private static List<ServiceWorkerPaymentApp> createServiceWorkerPaymentApps() { |
+ List<ServiceWorkerPaymentApp> result = new ArrayList<>(); |
+ for (ServiceWorkerPaymentAppBridge.Manifest manifest : |
+ sServiceWorkerPaymentAppBridge.getAllAppManifests()) { |
+ result.add(new ServiceWorkerPaymentApp(manifest)); |
+ } |
+ return result; |
+ } |
} |