| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
| 6 | 6 |
| 7 import android.content.Intent; | 7 import android.content.Intent; |
| 8 import android.content.pm.ActivityInfo; | 8 import android.content.pm.ActivityInfo; |
| 9 import android.content.pm.ResolveInfo; | 9 import android.content.pm.ResolveInfo; |
| 10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 private static final String TAG = "cr_PaymentAppFinder"; | 42 private static final String TAG = "cr_PaymentAppFinder"; |
| 43 | 43 |
| 44 /** The maximum number of payment method manifests to download. */ | 44 /** The maximum number of payment method manifests to download. */ |
| 45 private static final int MAX_NUMBER_OF_MANIFESTS = 10; | 45 private static final int MAX_NUMBER_OF_MANIFESTS = 10; |
| 46 | 46 |
| 47 /** The name of the intent for the service to check whether an app is ready
to pay. */ | 47 /** The name of the intent for the service to check whether an app is ready
to pay. */ |
| 48 /* package */ static final String ACTION_IS_READY_TO_PAY = | 48 /* package */ static final String ACTION_IS_READY_TO_PAY = |
| 49 "org.chromium.intent.action.IS_READY_TO_PAY"; | 49 "org.chromium.intent.action.IS_READY_TO_PAY"; |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * The basic-card payment method name used by merchant and defined by W3C: | |
| 53 * https://w3c.github.io/webpayments-methods-card/#method-id | |
| 54 */ | |
| 55 /* package */ static final String BASIC_CARD_PAYMENT_METHOD = "basic-card"; | |
| 56 | |
| 57 /** | |
| 58 * Meta data name of an app's supported payment method names. | 52 * Meta data name of an app's supported payment method names. |
| 59 */ | 53 */ |
| 60 /* package */ static final String META_DATA_NAME_OF_PAYMENT_METHOD_NAMES = | 54 /* package */ static final String META_DATA_NAME_OF_PAYMENT_METHOD_NAMES = |
| 61 "org.chromium.payment_method_names"; | 55 "org.chromium.payment_method_names"; |
| 62 | 56 |
| 63 /** | 57 /** |
| 64 * Meta data name of an app's supported default payment method name. | 58 * Meta data name of an app's supported default payment method name. |
| 65 */ | 59 */ |
| 66 /* package */ static final String META_DATA_NAME_OF_DEFAULT_PAYMENT_METHOD_N
AME = | 60 /* package */ static final String META_DATA_NAME_OF_DEFAULT_PAYMENT_METHOD_N
AME = |
| 67 "org.chromium.default_payment_method_name"; | 61 "org.chromium.default_payment_method_name"; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 .findAndroidPaymentApps(); | 101 .findAndroidPaymentApps(); |
| 108 } | 102 } |
| 109 | 103 |
| 110 private AndroidPaymentAppFinder(WebContents webContents, Set<String> methods
, | 104 private AndroidPaymentAppFinder(WebContents webContents, Set<String> methods
, |
| 111 PaymentManifestDownloader downloader, PaymentManifestParser parser, | 105 PaymentManifestDownloader downloader, PaymentManifestParser parser, |
| 112 PackageManagerDelegate packageManagerDelegate, PaymentAppCreatedCall
back callback) { | 106 PackageManagerDelegate packageManagerDelegate, PaymentAppCreatedCall
back callback) { |
| 113 mWebContents = webContents; | 107 mWebContents = webContents; |
| 114 | 108 |
| 115 // For non-URI payment method names, only names published by W3C should
be supported. | 109 // For non-URI payment method names, only names published by W3C should
be supported. |
| 116 Set<String> supportedNonUriPaymentMethods = new HashSet<>(); | 110 Set<String> supportedNonUriPaymentMethods = new HashSet<>(); |
| 117 supportedNonUriPaymentMethods.add(BASIC_CARD_PAYMENT_METHOD); | 111 // https://w3c.github.io/webpayments-methods-card/ |
| 112 supportedNonUriPaymentMethods.add("basic-card"); |
| 113 // https://w3c.github.io/webpayments/proposals/interledger-payment-metho
d.html |
| 114 supportedNonUriPaymentMethods.add("interledger"); |
| 118 | 115 |
| 119 mNonUriPaymentMethods = new HashSet<>(); | 116 mNonUriPaymentMethods = new HashSet<>(); |
| 120 mUriPaymentMethods = new HashSet<>(); | 117 mUriPaymentMethods = new HashSet<>(); |
| 121 for (String method : methods) { | 118 for (String method : methods) { |
| 122 assert !TextUtils.isEmpty(method); | 119 assert !TextUtils.isEmpty(method); |
| 123 if (supportedNonUriPaymentMethods.contains(method)) { | 120 if (supportedNonUriPaymentMethods.contains(method)) { |
| 124 mNonUriPaymentMethods.add(method); | 121 mNonUriPaymentMethods.add(method); |
| 125 } else if (method.startsWith(UrlConstants.HTTPS_URL_PREFIX)) { | 122 } else if (method.startsWith(UrlConstants.HTTPS_URL_PREFIX)) { |
| 126 URI uri; | 123 URI uri; |
| 127 try { | 124 try { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 307 } |
| 311 } | 308 } |
| 312 | 309 |
| 313 for (Map.Entry<String, AndroidPaymentApp> entry : mResult.entrySet()) { | 310 for (Map.Entry<String, AndroidPaymentApp> entry : mResult.entrySet()) { |
| 314 mCallback.onPaymentAppCreated(entry.getValue()); | 311 mCallback.onPaymentAppCreated(entry.getValue()); |
| 315 } | 312 } |
| 316 | 313 |
| 317 mCallback.onAllPaymentAppsCreated(); | 314 mCallback.onAllPaymentAppsCreated(); |
| 318 } | 315 } |
| 319 } | 316 } |
| OLD | NEW |