Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentAppBridge.java

Issue 2925063003: [Payments] Implement payment instrument icons (Closed)
Patch Set: fix comment lines Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentInstrument.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
8 import android.graphics.Bitmap;
9 import android.graphics.drawable.BitmapDrawable;
10
7 import org.chromium.base.annotations.CalledByNative; 11 import org.chromium.base.annotations.CalledByNative;
8 import org.chromium.base.annotations.SuppressFBWarnings; 12 import org.chromium.base.annotations.SuppressFBWarnings;
13 import org.chromium.chrome.browser.ChromeActivity;
9 import org.chromium.content_public.browser.WebContents; 14 import org.chromium.content_public.browser.WebContents;
10 import org.chromium.payments.mojom.PaymentDetailsModifier; 15 import org.chromium.payments.mojom.PaymentDetailsModifier;
11 import org.chromium.payments.mojom.PaymentItem; 16 import org.chromium.payments.mojom.PaymentItem;
12 import org.chromium.payments.mojom.PaymentMethodData; 17 import org.chromium.payments.mojom.PaymentMethodData;
13 18
14 import java.util.ArrayList; 19 import java.util.ArrayList;
15 import java.util.HashSet; 20 import java.util.HashSet;
16 import java.util.List; 21 import java.util.List;
17 import java.util.Set; 22 import java.util.Set;
18 23
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 modifiers.toArray(new PaymentDetailsModifier[0]), instrumentId, callback); 60 modifiers.toArray(new PaymentDetailsModifier[0]), instrumentId, callback);
56 } 61 }
57 62
58 @CalledByNative 63 @CalledByNative
59 private static List<PaymentInstrument> createInstrumentList() { 64 private static List<PaymentInstrument> createInstrumentList() {
60 return new ArrayList<PaymentInstrument>(); 65 return new ArrayList<PaymentInstrument>();
61 } 66 }
62 67
63 @CalledByNative 68 @CalledByNative
64 private static void addInstrument(List<PaymentInstrument> instruments, WebCo ntents webContents, 69 private static void addInstrument(List<PaymentInstrument> instruments, WebCo ntents webContents,
65 long swRegistrationId, String instrumentId, String label, String[] m ethodNameArray) { 70 long swRegistrationId, String instrumentId, String label, String[] m ethodNameArray,
71 Bitmap icon) {
72 Context context = ChromeActivity.fromWebContents(webContents);
73 if (context == null) return;
74
66 Set<String> methodNames = new HashSet<String>(); 75 Set<String> methodNames = new HashSet<String>();
67 for (int i = 0; i < methodNameArray.length; i++) { 76 for (int i = 0; i < methodNameArray.length; i++) {
68 methodNames.add(methodNameArray[i]); 77 methodNames.add(methodNameArray[i]);
69 } 78 }
70 instruments.add(new ServiceWorkerPaymentInstrument( 79
71 webContents, swRegistrationId, instrumentId, label, methodNames) ); 80 instruments.add(
81 new ServiceWorkerPaymentInstrument(webContents, swRegistrationId , instrumentId,
82 label, methodNames, new BitmapDrawable(context.getResour ces(), icon)));
72 } 83 }
73 84
74 @CalledByNative 85 @CalledByNative
75 private static String[] getSupportedMethodsFromMethodData(PaymentMethodData data) { 86 private static String[] getSupportedMethodsFromMethodData(PaymentMethodData data) {
76 return data.supportedMethods; 87 return data.supportedMethods;
77 } 88 }
78 89
79 @CalledByNative 90 @CalledByNative
80 private static String getStringifiedDataFromMethodData(PaymentMethodData dat a) { 91 private static String getStringifiedDataFromMethodData(PaymentMethodData dat a) {
81 return data.stringifiedData; 92 return data.stringifiedData;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 /* 153 /*
143 * TODO(tommyt): crbug.com/505554. Change the |callback| parameter below to 154 * TODO(tommyt): crbug.com/505554. Change the |callback| parameter below to
144 * be of type PaymentInstrument.InstrumentDetailsCallback, once this JNI bug 155 * be of type PaymentInstrument.InstrumentDetailsCallback, once this JNI bug
145 * has been resolved. 156 * has been resolved.
146 */ 157 */
147 private static native void nativeInvokePaymentApp(WebContents webContents, l ong registrationId, 158 private static native void nativeInvokePaymentApp(WebContents webContents, l ong registrationId,
148 String topLevelOrigin, String paymentRequestOrigin, String paymentRe questId, 159 String topLevelOrigin, String paymentRequestOrigin, String paymentRe questId,
149 PaymentMethodData[] methodData, PaymentItem total, PaymentDetailsMod ifier[] modifiers, 160 PaymentMethodData[] methodData, PaymentItem total, PaymentDetailsMod ifier[] modifiers,
150 String instrumentKey, Object callback); 161 String instrumentKey, Object callback);
151 } 162 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/ServiceWorkerPaymentInstrument.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698