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

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

Issue 2559153002: PaymentApp: Make the PaymentAppFactory asynchronous (Closed)
Patch Set: Rebase onto latest master 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/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 ac430d6aa6eaceb6f0f720bc9464d468db0f23d2..5f25aae1b648c7f1806fbaad2d545ff2210a8435 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,9 +4,12 @@
package org.chromium.chrome.browser.payments;
+import android.content.Context;
import android.graphics.drawable.Drawable;
+import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.SuppressFBWarnings;
+import org.chromium.content_public.browser.WebContents;
import java.util.ArrayList;
import java.util.List;
@@ -16,10 +19,9 @@ import java.util.List;
*/
// TODO(tommyt): crbug.com/669876. Remove these suppressions when we actually
// start using all of the functionality in this class.
-@SuppressFBWarnings({
- "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD",
- "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"})
-public class ServiceWorkerPaymentAppBridge {
+@SuppressFBWarnings(
+ {"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.
@@ -52,10 +54,25 @@ public class ServiceWorkerPaymentAppBridge {
}
/**
- * Get a list of all the installed app manifests.
+ * Fetch all the installed service worker app manifests.
+ *
+ * This method is protected so that it can be overridden by tests.
+ *
+ * @return The installed service worker app manifests.
*/
- public List<Manifest> getAllAppManifests() {
+ @VisibleForTesting
+ protected List<Manifest> getAllAppManifests() {
// TODO(tommyt): crbug.com/669876. Implement this function.
return new ArrayList<Manifest>();
}
+
+ @Override
+ public void create(Context context, WebContents webContents,
+ PaymentAppFactory.PaymentAppCreatedCallback callback) {
+ List<Manifest> manifests = getAllAppManifests();
+ for (int i = 0; i < manifests.size(); i++) {
+ callback.onPaymentAppCreated(new ServiceWorkerPaymentApp(manifests.get(i)));
+ }
+ callback.onAllPaymentAppsCreated();
+ }
}

Powered by Google App Engine
This is Rietveld 408576698