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

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

Issue 2645813006: Download web payment manifests. (Closed)
Patch Set: WIP Downloader tests - do not review Created 3 years, 11 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/PaymentManifestDownloader.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentManifestDownloader.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentManifestDownloader.java
new file mode 100644
index 0000000000000000000000000000000000000000..8d8dcee1d42dfd6894d0abb44883dd4c1a752a48
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentManifestDownloader.java
@@ -0,0 +1,64 @@
+// 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.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+import org.chromium.content_public.browser.WebContents;
+
+/**
+ * Downloads the payment method manifest based on the payment method name that is a URL with HTTPS
+ * scheme, e.g., https://bobpay.com. The download happens via two consecutive HTTP requests:
+ *
+ * 1) HEAD request for the payment method name. The HTTP response header is parsed for Link header
+ * that points to the location of the payment method manifest file. Example of a relative
+ * location:
+ *
+ * Link: <data/payment-manifest.json>; rel="payment-method-manifest"
+ *
+ * (This is relative to the payment method URL.) Example of an absolute location:
+ *
+ * Link: <https://bobpay.com/data/payment-manifest.json>; rel="payment-method-manifest"
+ *
+ * The absolute location must use HTTPS scheme.
+ *
+ * 2) GET request for the payment method manifest file.
+ */
+@JNINamespace("payments")
+public class PaymentManifestDownloader {
+ /** Interface for the callback to invoke when finished downloading. */
+ public interface ManifestDownloadCallback {
+ /**
+ * Called on successful download of a payment method manifest.
+ *
+ * @param contents The successfully downloaded payment method manifest.
+ */
+ @CalledByNative("ManifestDownloadCallback")
+ void onManifestDownloadSuccess(String contents);
+
+ /** Called on failed download of a payment method manifest. */
+ @CalledByNative("ManifestDownloadCallback")
+ void onManifestDownloadFailure();
+ }
+
+ /**
+ * Downloads the manifest file asynchronously.
+ *
+ * @param webContents The web contents to use as the context for the download. If this goes
+ * away, the download is cancelled.
+ * @param methodName The payment method name that is a URL with HTTPS scheme. Must be a URL and
+ * must start with "https://".
+ * @param callback The callback to invoke when finished downloading.
+ */
+ public static void download(
+ WebContents webContents, String methodName, ManifestDownloadCallback callback) {
+ nativeDownloadPaymentManifest(webContents, methodName, callback);
+ }
+
+ private PaymentManifestDownloader() {}
+
+ private static native void nativeDownloadPaymentManifest(
+ WebContents webContents, String methodName, ManifestDownloadCallback callback);
+}

Powered by Google App Engine
This is Rietveld 408576698