Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 android.content.Context; | |
| 8 | |
| 9 import org.chromium.content_public.browser.WebContents; | |
| 10 import org.chromium.payments.mojom.PaymentAppManifest; | |
| 11 import org.chromium.payments.mojom.PaymentAppOption; | |
| 12 import org.chromium.payments.mojom.PaymentItem; | |
| 13 import org.chromium.payments.mojom.PaymentMethodData; | |
| 14 | |
| 15 import java.util.Arrays; | |
| 16 import java.util.HashSet; | |
| 17 import java.util.List; | |
| 18 import java.util.Map; | |
| 19 import java.util.Set; | |
| 20 | |
| 21 /** | |
| 22 * This instrument class represents a single payment option for a web based | |
| 23 * payment app. | |
| 24 * | |
| 25 * @see org.chromium.chrome.browser.payments.WebBasedPaymentApp | |
| 26 * | |
| 27 * @see https://w3c.github.io/webpayments-payment-apps-api/ | |
| 28 */ | |
| 29 public class WebBasedPaymentInstrument extends PaymentInstrument { | |
| 30 private final Context mContext; | |
| 31 private final WebContents mWebContents; | |
| 32 private final String mAppId; | |
| 33 private final PaymentAppManifest mManifest; | |
|
zino
2016/11/27 18:41:23
It's difficult to imagine use-case of this variabl
tommyt
2016/11/28 14:13:23
I've removed this member variable. It was used in
| |
| 34 private final PaymentAppOption mOption; | |
| 35 | |
| 36 /** | |
| 37 * Build a web based payment instrument based on a single payment option of | |
| 38 * an installed payment app manifest. | |
| 39 * | |
| 40 * @see https://w3c.github.io/webpayments-payment-apps-api/#payment-app-opti ons | |
| 41 * | |
| 42 * @param context The context. | |
| 43 * @param webContents The web contents where PaymentRequest was invoked. | |
| 44 * @param appId A string that uniquely represents the corresponding pa yment app. | |
| 45 * @param manifest A manifest that describes the corresponding payment ap p. | |
| 46 * @param option A payment app option from the manifest. | |
| 47 */ | |
| 48 public WebBasedPaymentInstrument(Context context, WebContents webContents, | |
| 49 String appId, PaymentAppManifest manifest, PaymentAppOption option) { | |
| 50 super(appId + "#" + option.id, option.label, null, null); | |
| 51 mContext = context; | |
| 52 mWebContents = webContents; | |
| 53 mAppId = appId; | |
| 54 mManifest = manifest; | |
| 55 mOption = option; | |
| 56 } | |
| 57 | |
| 58 @Override | |
| 59 public Set<String> getInstrumentMethodNames() { | |
| 60 return new HashSet<>(Arrays.asList(mOption.enabledMethods[0])); | |
| 61 } | |
| 62 | |
| 63 @Override | |
| 64 public void invokePayment(String merchantName, String origin, PaymentItem to tal, | |
| 65 List<PaymentItem> cart, Map<String, PaymentMethodData> methodData, | |
| 66 InstrumentDetailsCallback callback) { | |
| 67 // TODO(tommyt): Implement this for use with Web Based Payment Apps. | |
| 68 callback.onInstrumentDetailsError(); | |
| 69 } | |
| 70 | |
| 71 @Override | |
| 72 public void dismissInstrument() {} | |
| 73 } | |
| OLD | NEW |