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

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

Issue 2652763007: Send site certificate chain to android payment app (Closed)
Patch Set: Probable fix Created 3 years, 11 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
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.app.Activity; 7 import android.app.Activity;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.graphics.Bitmap; 9 import android.graphics.Bitmap;
10 import android.os.Handler; 10 import android.os.Handler;
11 import android.support.v4.util.ArrayMap; 11 import android.support.v4.util.ArrayMap;
12 import android.text.TextUtils; 12 import android.text.TextUtils;
13 13
14 import org.chromium.base.Callback; 14 import org.chromium.base.Callback;
15 import org.chromium.base.ContextUtils; 15 import org.chromium.base.ContextUtils;
16 import org.chromium.base.Log; 16 import org.chromium.base.Log;
17 import org.chromium.base.VisibleForTesting; 17 import org.chromium.base.VisibleForTesting;
18 import org.chromium.base.metrics.RecordHistogram; 18 import org.chromium.base.metrics.RecordHistogram;
19 import org.chromium.chrome.R; 19 import org.chromium.chrome.R;
20 import org.chromium.chrome.browser.ChromeActivity; 20 import org.chromium.chrome.browser.ChromeActivity;
21 import org.chromium.chrome.browser.ChromeFeatureList; 21 import org.chromium.chrome.browser.ChromeFeatureList;
22 import org.chromium.chrome.browser.autofill.PersonalDataManager; 22 import org.chromium.chrome.browser.autofill.PersonalDataManager;
23 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; 23 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
24 import org.chromium.chrome.browser.favicon.FaviconHelper; 24 import org.chromium.chrome.browser.favicon.FaviconHelper;
25 //import org.chromium.chrome.browser.pageinfo.CertificateChainHelper;
25 import org.chromium.chrome.browser.payments.ui.Completable; 26 import org.chromium.chrome.browser.payments.ui.Completable;
26 import org.chromium.chrome.browser.payments.ui.ContactDetailsSection; 27 import org.chromium.chrome.browser.payments.ui.ContactDetailsSection;
27 import org.chromium.chrome.browser.payments.ui.LineItem; 28 import org.chromium.chrome.browser.payments.ui.LineItem;
28 import org.chromium.chrome.browser.payments.ui.PaymentInformation; 29 import org.chromium.chrome.browser.payments.ui.PaymentInformation;
29 import org.chromium.chrome.browser.payments.ui.PaymentOption; 30 import org.chromium.chrome.browser.payments.ui.PaymentOption;
30 import org.chromium.chrome.browser.payments.ui.PaymentRequestSection.OptionSecti on.FocusChangedObserver; 31 import org.chromium.chrome.browser.payments.ui.PaymentRequestSection.OptionSecti on.FocusChangedObserver;
31 import org.chromium.chrome.browser.payments.ui.PaymentRequestUI; 32 import org.chromium.chrome.browser.payments.ui.PaymentRequestUI;
32 import org.chromium.chrome.browser.payments.ui.SectionInformation; 33 import org.chromium.chrome.browser.payments.ui.SectionInformation;
33 import org.chromium.chrome.browser.payments.ui.ShoppingCart; 34 import org.chromium.chrome.browser.payments.ui.ShoppingCart;
34 import org.chromium.chrome.browser.preferences.PreferencesLauncher; 35 import org.chromium.chrome.browser.preferences.PreferencesLauncher;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 public void didSelectTab(Tab tab, TabSelectionType type, int lastId) { 207 public void didSelectTab(Tab tab, TabSelectionType type, int lastId) {
207 if (tab == null || tab.getId() != lastId) onDismiss(); 208 if (tab == null || tab.getId() != lastId) onDismiss();
208 } 209 }
209 }; 210 };
210 211
211 private final Handler mHandler = new Handler(); 212 private final Handler mHandler = new Handler();
212 private final ChromeActivity mContext; 213 private final ChromeActivity mContext;
213 private final WebContents mWebContents; 214 private final WebContents mWebContents;
214 private final String mMerchantName; 215 private final String mMerchantName;
215 private final String mOrigin; 216 private final String mOrigin;
217 private final byte[][] mCertificateChain;
216 private final AddressEditor mAddressEditor; 218 private final AddressEditor mAddressEditor;
217 private final CardEditor mCardEditor; 219 private final CardEditor mCardEditor;
218 private final PaymentRequestJourneyLogger mJourneyLogger = new PaymentReques tJourneyLogger(); 220 private final PaymentRequestJourneyLogger mJourneyLogger = new PaymentReques tJourneyLogger();
219 221
220 private Bitmap mFavicon; 222 private Bitmap mFavicon;
221 private PaymentRequestClient mClient; 223 private PaymentRequestClient mClient;
222 224
223 /** 225 /**
224 * The raw total amount being charged, as it was received from the website. This data is passed 226 * The raw total amount being charged, as it was received from the website. This data is passed
225 * to the payment app. 227 * to the payment app.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 assert webContents != null; 293 assert webContents != null;
292 294
293 assert context instanceof ChromeActivity; 295 assert context instanceof ChromeActivity;
294 mContext = (ChromeActivity) context; 296 mContext = (ChromeActivity) context;
295 mWebContents = webContents; 297 mWebContents = webContents;
296 298
297 mMerchantName = webContents.getTitle(); 299 mMerchantName = webContents.getTitle();
298 // The feature is available only in secure context, so it's OK to not sh ow HTTPS. 300 // The feature is available only in secure context, so it's OK to not sh ow HTTPS.
299 mOrigin = UrlFormatter.formatUrlForSecurityDisplay( 301 mOrigin = UrlFormatter.formatUrlForSecurityDisplay(
300 webContents.getLastCommittedUrl(), false); 302 webContents.getLastCommittedUrl(), false);
303 mCertificateChain = null;
please use gerrit instead 2017/01/25 15:39:12 Need to initialize?
rwlbuis 2017/01/25 15:49:40 Oops I messed the most important line up! Will upl
301 304
302 final FaviconHelper faviconHelper = new FaviconHelper(); 305 final FaviconHelper faviconHelper = new FaviconHelper();
303 faviconHelper.getLocalFaviconImageForURL(Profile.getLastUsedProfile(), 306 faviconHelper.getLocalFaviconImageForURL(Profile.getLastUsedProfile(),
304 webContents.getVisibleUrl(), 307 webContents.getVisibleUrl(),
305 mContext.getResources().getDimensionPixelSize(R.dimen.payments_f avicon_size), 308 mContext.getResources().getDimensionPixelSize(R.dimen.payments_f avicon_size),
306 new FaviconHelper.FaviconImageCallback() { 309 new FaviconHelper.FaviconImageCallback() {
307 @Override 310 @Override
308 public void onFaviconAvailable(Bitmap bitmap, String iconUrl ) { 311 public void onFaviconAvailable(Bitmap bitmap, String iconUrl ) {
309 faviconHelper.destroy(); 312 faviconHelper.destroy();
310 if (bitmap == null) return; 313 if (bitmap == null) return;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 mArePaymentMethodsSupported = true; 533 mArePaymentMethodsSupported = true;
531 mMerchantSupportsAutofillPaymentInstruments |= app instanceof Au tofillPaymentApp; 534 mMerchantSupportsAutofillPaymentInstruments |= app instanceof Au tofillPaymentApp;
532 queryApps.put(app, appMethods); 535 queryApps.put(app, appMethods);
533 } 536 }
534 } 537 }
535 538
536 // Query instruments after mMerchantSupportsAutofillPaymentInstruments h as been initialized, 539 // Query instruments after mMerchantSupportsAutofillPaymentInstruments h as been initialized,
537 // so a fast response from a non-autofill payment app at the front of th e app list does not 540 // so a fast response from a non-autofill payment app at the front of th e app list does not
538 // cause NOT_SUPPORTED payment rejection. 541 // cause NOT_SUPPORTED payment rejection.
539 for (Map.Entry<PaymentApp, Map<String, PaymentMethodData>> q : queryApps .entrySet()) { 542 for (Map.Entry<PaymentApp, Map<String, PaymentMethodData>> q : queryApps .entrySet()) {
540 q.getKey().getInstruments(q.getValue(), mOrigin, this); 543 q.getKey().getInstruments(q.getValue(), mOrigin, mCertificateChain, this);
541 } 544 }
542 } 545 }
543 546
544 /** Filter out merchant method data that's not relevant to a payment app. Ca n return null. */ 547 /** Filter out merchant method data that's not relevant to a payment app. Ca n return null. */
545 private static Map<String, PaymentMethodData> filterMerchantMethodData( 548 private static Map<String, PaymentMethodData> filterMerchantMethodData(
546 Map<String, PaymentMethodData> merchantMethodData, Set<String> appMe thods) { 549 Map<String, PaymentMethodData> merchantMethodData, Set<String> appMe thods) {
547 Map<String, PaymentMethodData> result = null; 550 Map<String, PaymentMethodData> result = null;
548 for (String method : appMethods) { 551 for (String method : appMethods) {
549 if (merchantMethodData.containsKey(method)) { 552 if (merchantMethodData.containsKey(method)) {
550 if (result == null) result = new ArrayMap<>(); 553 if (result == null) result = new ArrayMap<>();
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 Map<String, PaymentDetailsModifier> modifiers = new HashMap<>(); 1046 Map<String, PaymentDetailsModifier> modifiers = new HashMap<>();
1044 for (String instrumentMethodName : instrument.getInstrumentMethodNames() ) { 1047 for (String instrumentMethodName : instrument.getInstrumentMethodNames() ) {
1045 if (mMethodData.containsKey(instrumentMethodName)) { 1048 if (mMethodData.containsKey(instrumentMethodName)) {
1046 methodData.put(instrumentMethodName, mMethodData.get(instrumentM ethodName)); 1049 methodData.put(instrumentMethodName, mMethodData.get(instrumentM ethodName));
1047 } 1050 }
1048 if (mModifiers != null && mModifiers.containsKey(instrumentMethodNam e)) { 1051 if (mModifiers != null && mModifiers.containsKey(instrumentMethodNam e)) {
1049 modifiers.put(instrumentMethodName, mModifiers.get(instrumentMet hodName)); 1052 modifiers.put(instrumentMethodName, mModifiers.get(instrumentMet hodName));
1050 } 1053 }
1051 } 1054 }
1052 1055
1053 instrument.invokePaymentApp(mMerchantName, mOrigin, Collections.unmodifi ableMap(methodData), 1056 instrument.invokePaymentApp(mMerchantName, mOrigin, mCertificateChain,
1054 mRawTotal, mRawLineItems, Collections.unmodifiableMap(modifiers) , this); 1057 Collections.unmodifiableMap(methodData), mRawTotal, mRawLineItem s,
1058 Collections.unmodifiableMap(modifiers), this);
1055 1059
1056 recordSuccessFunnelHistograms("PayClicked"); 1060 recordSuccessFunnelHistograms("PayClicked");
1057 return !(instrument instanceof AutofillPaymentInstrument); 1061 return !(instrument instanceof AutofillPaymentInstrument);
1058 } 1062 }
1059 1063
1060 @Override 1064 @Override
1061 public void onDismiss() { 1065 public void onDismiss() {
1062 disconnectFromClientWithDebugMessage("Dialog dismissed"); 1066 disconnectFromClientWithDebugMessage("Dialog dismissed");
1063 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY _USER); 1067 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY _USER);
1064 } 1068 }
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 "PaymentRequest.CheckoutFunnel.Aborted", abortReason, 1477 "PaymentRequest.CheckoutFunnel.Aborted", abortReason,
1474 PaymentRequestMetrics.ABORT_REASON_MAX); 1478 PaymentRequestMetrics.ABORT_REASON_MAX);
1475 1479
1476 if (abortReason == PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER) { 1480 if (abortReason == PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER) {
1477 mJourneyLogger.recordJourneyStatsHistograms("UserAborted"); 1481 mJourneyLogger.recordJourneyStatsHistograms("UserAborted");
1478 } else { 1482 } else {
1479 mJourneyLogger.recordJourneyStatsHistograms("OtherAborted"); 1483 mJourneyLogger.recordJourneyStatsHistograms("OtherAborted");
1480 } 1484 }
1481 } 1485 }
1482 } 1486 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698