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

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: Created 4 years, 1 month 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..d085efde4c5ed935c6ca61be345483466f0a8e82 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
@@ -8,9 +8,11 @@ import android.content.Context;
import org.chromium.base.VisibleForTesting;
import org.chromium.content_public.browser.WebContents;
+import org.chromium.payments.mojom.PaymentAppManifest;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
/**
* Builds instances of payment apps.
@@ -22,6 +24,9 @@ public class PaymentAppFactory {
*/
private static PaymentAppFactoryAddition sAdditionalFactory;
+ private static WebBasedPaymentAppBridge sWebBasedPaymentAppBridge =
+ new WebBasedPaymentAppBridge();
+
/**
* 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));
+ result.addAll(createWebBasedPaymentApps(context, webContents));
if (sAdditionalFactory != null) {
result.addAll(
sAdditionalFactory.create(context, webContents));
}
return result;
}
+
+ /**
+ * Build a WebBasedPaymentApp instance for each installed web based
+ * payment app.
+ *
+ * @param context The context.
+ * @param webContents The web contents where PaymentRequest was invoked.
+ */
+ private static List<WebBasedPaymentApp> createWebBasedPaymentApps(
+ Context context, WebContents webContents) {
+ List<WebBasedPaymentApp> result = new ArrayList<>();
+ for (Map.Entry<String, PaymentAppManifest> entry :
+ sWebBasedPaymentAppBridge.getAllAppManifests().entrySet()) {
+ result.add(new WebBasedPaymentApp(context, webContents,
+ entry.getKey(), entry.getValue()));
+ }
+ return result;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698