| 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..f59dce9991945b27148e2bc3dcd45084cb49e559
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentManifestDownloader.java
|
| @@ -0,0 +1,63 @@
|
| +// 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;
|
| +
|
| +import java.net.URL;
|
| +
|
| +/**
|
| + * See comment in:
|
| + * components/payments/payment_manifest_downloader.h
|
| + */
|
| +@JNINamespace("payments")
|
| +public class PaymentManifestDownloader {
|
| + /** Interface for the callback to invoke when finished downloading. */
|
| + 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();
|
| + }
|
| +
|
| + private final WebContents mWebContents;
|
| +
|
| + /**
|
| + * Builds the downloader.
|
| + *
|
| + * @param webContents The web contents to use as the context for the download. If this goes
|
| + * away, the download is cancelled.
|
| + */
|
| + public PaymentManifestDownloader(WebContents webContents) {
|
| + mWebContents = webContents;
|
| + }
|
| +
|
| + /**
|
| + * Downloads the manifest file asynchronously.
|
| + *
|
| + * @param methodName The payment method name that is a URL with HTTPS scheme.
|
| + * @param callback The callback to invoke when finished downloading.
|
| + */
|
| + public void download(URL methodName, ManifestDownloadCallback callback) {
|
| + nativeDownloadPaymentManifest(mWebContents, methodName, callback);
|
| + }
|
| +
|
| + @CalledByNative("PaymentManifestDownloader")
|
| + private static String getUrlString(URL methodName) {
|
| + return methodName.toString();
|
| + }
|
| +
|
| + private static native void nativeDownloadPaymentManifest(
|
| + WebContents webContents, URL methodName, ManifestDownloadCallback callback);
|
| +}
|
|
|