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

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

Issue 2838433002: [Payments] Cache payment manifests. (Closed)
Patch Set: fix tests Created 3 years, 8 months 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/PaymentManifestWebDataService.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentManifestWebDataService.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentManifestWebDataService.java
new file mode 100644
index 0000000000000000000000000000000000000000..757261ead3d69aeb86666261dec61ade8ef21b20
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentManifestWebDataService.java
@@ -0,0 +1,119 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.payments;
+
+import org.chromium.base.ThreadUtils;
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+import org.chromium.payments.mojom.WebAppManifestSection;
+
+/** Java wrapper of the payment manifest web data service. */
+@JNINamespace("payments")
+public class PaymentManifestWebDataService {
+ /** Interface for the callback to invoke when getting data from the web data service. */
+ public interface PaymentManifestWebDataServiceCallback {
+ /**
+ * Called when getPaymentMethodManifest success.
+ *
+ * @param webAppsIds The web apps Ids in the payment method manifest.
+ */
+ @CalledByNative("PaymentManifestWebDataServiceCallback")
+ void onPaymentMethodManifestFetched(String[] webAppsIds);
+
+ /**
+ * Called when getPaymentWebAppManifest success.
+ *
+ * @param manifest The web app manifest sections.
+ */
+ @CalledByNative("PaymentManifestWebDataServiceCallback")
+ void onPaymentWebAppManifestFetched(WebAppManifestSection[] manifest);
please use gerrit instead 2017/04/24 18:22:31 Can you define a simpler interface that hides the
gogerald1 2017/04/26 13:46:31 Distinguish them looks a little more consistent he
please use gerrit instead 2017/04/26 15:00:43 You're right that PaymentManifestDownloader has tw
gogerald1 2017/04/26 17:30:30 Acknowledged.
+ }
+
+ private static PaymentManifestWebDataService sWebDataService;
+
+ /**
+ * Gets an instance of this class.
+ *
+ * @return An instance of PaymentManifestWebDataService.
+ */
+ public static PaymentManifestWebDataService getInstance() {
+ ThreadUtils.assertOnUiThread();
+ if (sWebDataService == null) {
+ sWebDataService = new PaymentManifestWebDataService();
+ }
+ return sWebDataService;
+ }
+
+ private final long mManifestWebDataServiceAndroid;
please use gerrit instead 2017/04/24 18:22:31 Please put all member variables together.
gogerald1 2017/04/26 13:46:31 Done.
+
+ private PaymentManifestWebDataService() {
+ mManifestWebDataServiceAndroid = nativeInit();
+ }
+
+ /**
+ * Gets the payment method's manifest.
+ *
+ * @param methodName The payment method name.
+ * @param callback The callback to invoke when finishing the request.
+ * @return True if the result will be returned through callback.
+ */
+ public boolean getPaymentMethodManifest(
+ String methodName, PaymentManifestWebDataServiceCallback callback) {
+ return nativeGetPaymentMethodManifest(mManifestWebDataServiceAndroid, methodName, callback);
+ }
+
+ /**
+ * Adds the supported web apps Ids of the method.
please use gerrit instead 2017/04/24 18:22:31 s/web app Ids/Android app package names/g Here an
gogerald1 2017/04/26 13:46:32 Done.
+ *
+ * @param methodName The method name.
+ * @param webAppsIds The supported web apps Ids.
+ */
+ public void addPaymentMethodManifest(String methodName, String[] webAppsIds) {
+ nativeAddPaymentMethodManifest(mManifestWebDataServiceAndroid, methodName, webAppsIds);
+ }
+
+ /**
+ * Gets the payment web app's manifest.
+ *
+ * @param webAppId The id of the payment web app.
please use gerrit instead 2017/04/24 18:22:31 s/webAppId/androidAppPackageName/ (or packageName)
gogerald1 2017/04/26 13:46:31 Done.
+ * @param callback The callback to invoke when finishing the request.
+ * @return True if the result will be returned through callback.
+ */
+ public boolean getPaymentWebAppManifest(
+ String webAppId, PaymentManifestWebDataServiceCallback callback) {
+ return nativeGetPaymentWebAppManifest(mManifestWebDataServiceAndroid, webAppId, callback);
+ }
+
+ @CalledByNative
+ private static WebAppManifestSection[] createManifest(int numberOfsections) {
+ return new WebAppManifestSection[numberOfsections];
+ }
+
+ @CalledByNative
+ private static void addSectionToManifest(WebAppManifestSection[] manifest, int sectionIndex,
+ String id, long minVersion, int numberOfFingerprints) {
+ manifest[sectionIndex] = new WebAppManifestSection();
+ manifest[sectionIndex].id = id;
+ manifest[sectionIndex].minVersion = minVersion;
+ manifest[sectionIndex].fingerprints = new byte[numberOfFingerprints][];
+ }
+
+ @CalledByNative
+ private static void addFingerprintToSection(WebAppManifestSection[] manifest, int sectionIndex,
+ int fingerprintIndex, byte[] fingerprint) {
+ manifest[sectionIndex].fingerprints[fingerprintIndex] = fingerprint;
+ }
+
+ private native long nativeInit();
please use gerrit instead 2017/04/24 18:22:31 If there's initialization, then you also need dest
gogerald1 2017/04/26 13:46:31 Done.
+ private native boolean nativeGetPaymentMethodManifest(
+ long nativePaymentManifestWebDataServiceAndroid, String methodName,
+ PaymentManifestWebDataServiceCallback callback);
+ private native void nativeAddPaymentMethodManifest(
+ long nativePaymentManifestWebDataServiceAndroid, String methodName,
+ String[] webAppsIds);
+ private native boolean nativeGetPaymentWebAppManifest(
please use gerrit instead 2017/04/24 18:22:31 Can you group the "Get" methods together?
gogerald1 2017/04/26 13:46:32 Done.
+ long nativePaymentManifestWebDataServiceAndroid, String webAppId,
+ PaymentManifestWebDataServiceCallback callback);
+}

Powered by Google App Engine
This is Rietveld 408576698