OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.payments; |
| 6 |
| 7 import org.chromium.base.annotations.CalledByNative; |
| 8 import org.chromium.base.annotations.JNINamespace; |
| 9 import org.chromium.content_public.browser.WebContents; |
| 10 |
| 11 /** |
| 12 * Downloads the payment method manifest based on the payment method name that i
s a URL with HTTPS |
| 13 * scheme, e.g., https://bobpay.com. The download happens via two consecutive HT
TP requests: |
| 14 * |
| 15 * 1) HEAD request for the payment method name. The HTTP response header is pars
ed for Link header |
| 16 * that points to the location of the payment method manifest file. Example o
f a relative |
| 17 * location: |
| 18 * |
| 19 * Link: <data/payment-manifest.json>; rel="payment-method-manifest
" |
| 20 * |
| 21 * (This is relative to the payment method URL.) Example of an absolute locat
ion: |
| 22 * |
| 23 * Link: <https://bobpay.com/data/payment-manifest.json>; rel="paym
ent-method-manifest" |
| 24 * |
| 25 * The absolute location must use HTTPS scheme. |
| 26 * |
| 27 * 2) GET request for the payment method manifest file. |
| 28 */ |
| 29 @JNINamespace("payments") |
| 30 public class PaymentManifestDownloader { |
| 31 /** Interface for the callback to invoke when finished downloading. */ |
| 32 public interface ManifestDownloadCallback { |
| 33 /** |
| 34 * Called on successful download of a payment method manifest. |
| 35 * |
| 36 * @param contents The successfully downloaded payment method manifest. |
| 37 */ |
| 38 @CalledByNative("ManifestDownloadCallback") |
| 39 void onManifestDownloadSuccess(String contents); |
| 40 |
| 41 /** Called on failed download of a payment method manifest. */ |
| 42 @CalledByNative("ManifestDownloadCallback") |
| 43 void onManifestDownloadFailure(); |
| 44 } |
| 45 |
| 46 /** |
| 47 * Downloads the manifest file asynchronously. |
| 48 * |
| 49 * @param webContents The web contents to use as the context for the downloa
d. If this goes |
| 50 * away, the download is cancelled. |
| 51 * @param methodName The payment method name that is a URL with HTTPS schem
e. Must be a URL and |
| 52 * must start with "https://". |
| 53 * @param callback The callback to invoke when finished downloading. |
| 54 */ |
| 55 public static void download( |
| 56 WebContents webContents, String methodName, ManifestDownloadCallback
callback) { |
| 57 nativeDownloadPaymentManifest(webContents, methodName, callback); |
| 58 } |
| 59 |
| 60 private PaymentManifestDownloader() {} |
| 61 |
| 62 private static native void nativeDownloadPaymentManifest( |
| 63 WebContents webContents, String methodName, ManifestDownloadCallback
callback); |
| 64 } |
OLD | NEW |