OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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.Context; | 7 import android.content.Context; |
8 | 8 |
9 import org.chromium.base.VisibleForTesting; | 9 import org.chromium.base.VisibleForTesting; |
10 import org.chromium.content_public.browser.WebContents; | 10 import org.chromium.content_public.browser.WebContents; |
11 | 11 |
12 import java.util.ArrayList; | 12 import java.util.ArrayList; |
13 import java.util.List; | 13 import java.util.List; |
14 | 14 |
15 /** | 15 /** |
16 * Builds instances of payment apps. | 16 * Builds instances of payment apps. |
17 */ | 17 */ |
18 public class PaymentAppFactory { | 18 public class PaymentAppFactory { |
19 /** | 19 /** |
20 * Can be used to build additional types of payment apps without Chrome know ing about their | 20 * Can be used to build additional types of payment apps without Chrome know ing about their |
21 * types. | 21 * types. |
22 */ | 22 */ |
23 private static PaymentAppFactoryAddition sAdditionalFactory; | 23 private static PaymentAppFactoryAddition sAdditionalFactory; |
24 | 24 |
25 private static WebBasedPaymentAppBridge sWebBasedPaymentAppBridge = | |
26 new WebBasedPaymentAppBridge(); | |
27 | |
25 /** | 28 /** |
26 * The interface for additional payment app factories. | 29 * The interface for additional payment app factories. |
27 */ | 30 */ |
28 public interface PaymentAppFactoryAddition { | 31 public interface PaymentAppFactoryAddition { |
29 /** | 32 /** |
30 * Builds instances of payment apps. | 33 * Builds instances of payment apps. |
31 * | 34 * |
32 * @param context The application context. | 35 * @param context The application context. |
33 * @param webContents The web contents that invoked PaymentRequest. | 36 * @param webContents The web contents that invoked PaymentRequest. |
34 */ | 37 */ |
(...skipping 12 matching lines...) Expand all Loading... | |
47 | 50 |
48 /** | 51 /** |
49 * Builds instances of payment apps. | 52 * Builds instances of payment apps. |
50 * | 53 * |
51 * @param context The context. | 54 * @param context The context. |
52 * @param webContents The web contents where PaymentRequest was invoked. | 55 * @param webContents The web contents where PaymentRequest was invoked. |
53 */ | 56 */ |
54 public static List<PaymentApp> create(Context context, WebContents webConten ts) { | 57 public static List<PaymentApp> create(Context context, WebContents webConten ts) { |
55 List<PaymentApp> result = new ArrayList<>(2); | 58 List<PaymentApp> result = new ArrayList<>(2); |
56 result.add(new AutofillPaymentApp(context, webContents)); | 59 result.add(new AutofillPaymentApp(context, webContents)); |
60 result.addAll(createWebBasedPaymentApps(context, webContents)); | |
please use gerrit instead
2016/11/29 14:28:44
Put this behind a command-line flag before it's 10
tommyt
2016/11/30 13:44:38
Done.
| |
57 if (sAdditionalFactory != null) { | 61 if (sAdditionalFactory != null) { |
58 result.addAll( | 62 result.addAll( |
59 sAdditionalFactory.create(context, webContents)); | 63 sAdditionalFactory.create(context, webContents)); |
60 } | 64 } |
61 return result; | 65 return result; |
62 } | 66 } |
67 | |
68 /** | |
69 * Build a WebBasedPaymentApp instance for each installed web based | |
70 * payment app. | |
71 * | |
72 * @param context The context. | |
73 * @param webContents The web contents where PaymentRequest was invoked. | |
74 */ | |
75 private static List<WebBasedPaymentApp> createWebBasedPaymentApps( | |
76 Context context, WebContents webContents) { | |
agrieve
2016/11/28 17:59:53
Here and in other places, you should try and say w
tommyt
2016/11/30 13:44:38
Yeah, this did actually turn out a bit cargo-cult-
| |
77 List<WebBasedPaymentApp> result = new ArrayList<>(); | |
78 for (WebBasedPaymentAppBridge.Manifest manifest : | |
79 sWebBasedPaymentAppBridge.getAllAppManifests()) { | |
80 result.add(new WebBasedPaymentApp(context, webContents, manifest)); | |
81 } | |
82 return result; | |
83 } | |
63 } | 84 } |
OLD | NEW |