Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1435)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentAppFactory.java

Issue 2526293003: PaymentApp: Add classes for supporting Web Based Payment Apps (Closed)
Patch Set: Make the service worker unittests work even with the feature flag off Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..69116d1574beebe756fb0636c041aafcec41211b 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
@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.payments;
import android.content.Context;
import org.chromium.base.VisibleForTesting;
+import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.content_public.browser.WebContents;
import java.util.ArrayList;
@@ -23,6 +24,12 @@ public class PaymentAppFactory {
private static PaymentAppFactoryAddition sAdditionalFactory;
/**
+ * Native bridge that can be used to retrieve information about installed service worker
+ * payment apps.
+ */
+ private static ServiceWorkerPaymentAppBridge sServiceWorkerPaymentAppBridge;
+
+ /**
* The interface for additional payment app factories.
*/
public interface PaymentAppFactoryAddition {
@@ -46,6 +53,15 @@ public class PaymentAppFactory {
}
/**
+ * Set a custom native bridge for service worker payment apps for testing.
+ */
+ @VisibleForTesting
+ public static void setServiceWorkerPaymentAppBridgeForTest(
+ ServiceWorkerPaymentAppBridge bridge) {
+ sServiceWorkerPaymentAppBridge = bridge;
+ }
+
+ /**
* Builds instances of payment apps.
*
* @param context The context.
@@ -54,10 +70,36 @@ public class PaymentAppFactory {
public static List<PaymentApp> create(Context context, WebContents webContents) {
List<PaymentApp> result = new ArrayList<>(2);
result.add(new AutofillPaymentApp(context, webContents));
+
+ 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() {
+ if (sServiceWorkerPaymentAppBridge == null) {
+ if (ChromeFeatureList.isEnabled(ChromeFeatureList.SERVICE_WORKER_PAYMENT_APPS)) {
+ sServiceWorkerPaymentAppBridge = new ServiceWorkerPaymentAppBridge();
+ } else {
+ return new ArrayList<>();
+ }
+ }
+
+ List<ServiceWorkerPaymentApp> result = new ArrayList<>();
+
+ for (ServiceWorkerPaymentAppBridge.Manifest manifest :
+ sServiceWorkerPaymentAppBridge.getAllAppManifests()) {
+ result.add(new ServiceWorkerPaymentApp(manifest));
+ }
+
+ return result;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698