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

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

Issue 2739033004: Send origin of the iframe browsing context (Closed)
Patch Set: Standalone Created 3 years, 9 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.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.graphics.Bitmap; 10 import android.graphics.Bitmap;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 public void didSelectTab(Tab tab, TabSelectionType type, int lastId) { 245 public void didSelectTab(Tab tab, TabSelectionType type, int lastId) {
246 if (tab == null || tab.getId() != lastId) onDismiss(); 246 if (tab == null || tab.getId() != lastId) onDismiss();
247 } 247 }
248 }; 248 };
249 249
250 private final Handler mHandler = new Handler(); 250 private final Handler mHandler = new Handler();
251 private final RenderFrameHost mRenderFrameHost; 251 private final RenderFrameHost mRenderFrameHost;
252 private final WebContents mWebContents; 252 private final WebContents mWebContents;
253 private final String mSchemelessOriginForPaymentApp; 253 private final String mSchemelessOriginForPaymentApp;
254 private final String mOriginForDisplay; 254 private final String mOriginForDisplay;
255 private final String mSchemelessIFrameOriginForPaymentApp;
255 private final String mMerchantName; 256 private final String mMerchantName;
256 private final byte[][] mCertificateChain; 257 private final byte[][] mCertificateChain;
257 private final AddressEditor mAddressEditor; 258 private final AddressEditor mAddressEditor;
258 private final CardEditor mCardEditor; 259 private final CardEditor mCardEditor;
259 private final PaymentRequestJourneyLogger mJourneyLogger = new PaymentReques tJourneyLogger(); 260 private final PaymentRequestJourneyLogger mJourneyLogger = new PaymentReques tJourneyLogger();
260 261
261 private PaymentRequestClient mClient; 262 private PaymentRequestClient mClient;
262 private boolean mIsCurrentPaymentRequestShowing; 263 private boolean mIsCurrentPaymentRequestShowing;
263 264
264 /** 265 /**
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 348
348 /** 349 /**
349 * Builds the PaymentRequest service implementation. 350 * Builds the PaymentRequest service implementation.
350 * 351 *
351 * @param webContents The web contents that have invoked the PaymentRequest API. 352 * @param webContents The web contents that have invoked the PaymentRequest API.
352 */ 353 */
353 public PaymentRequestImpl(RenderFrameHost renderFrameHost) { 354 public PaymentRequestImpl(RenderFrameHost renderFrameHost) {
354 assert renderFrameHost != null; 355 assert renderFrameHost != null;
355 356
356 mRenderFrameHost = renderFrameHost; 357 mRenderFrameHost = renderFrameHost;
358
357 mWebContents = WebContentsStatics.fromRenderFrameHost(renderFrameHost); 359 mWebContents = WebContentsStatics.fromRenderFrameHost(renderFrameHost);
358 360
359 mSchemelessOriginForPaymentApp = UrlFormatter.formatUrlForSecurityDispla y( 361 mSchemelessOriginForPaymentApp = UrlFormatter.formatUrlForSecurityDispla y(
360 mWebContents.getLastCommittedUrl(), false /* omit scheme for pay ment apps. */); 362 mWebContents.getLastCommittedUrl(), false /* omit scheme for pay ment apps. */);
361 363
362 mOriginForDisplay = UrlFormatter.formatUrlForSecurityDisplay( 364 mOriginForDisplay = UrlFormatter.formatUrlForSecurityDisplay(
363 mWebContents.getLastCommittedUrl(), true /* include scheme in di splay */); 365 mWebContents.getLastCommittedUrl(), true /* include scheme in di splay */);
364 366
367 mSchemelessIFrameOriginForPaymentApp = UrlFormatter.formatUrlForSecurity Display(
368 mRenderFrameHost.getLastCommittedURL(), false /* omit scheme for payment apps. */);
369
365 mMerchantName = mWebContents.getTitle(); 370 mMerchantName = mWebContents.getTitle();
366 371
367 mCertificateChain = CertificateChainHelper.getCertificateChain(mWebConte nts); 372 mCertificateChain = CertificateChainHelper.getCertificateChain(mWebConte nts);
368 373
369 mApps = new ArrayList<>(); 374 mApps = new ArrayList<>();
370 375
371 mAddressEditor = new AddressEditor(); 376 mAddressEditor = new AddressEditor();
372 mCardEditor = new CardEditor(mWebContents, mAddressEditor, sObserverForT est); 377 mCardEditor = new CardEditor(mWebContents, mAddressEditor, sObserverForT est);
373 378
374 if (sCanMakePaymentQueries == null) sCanMakePaymentQueries = new ArrayMa p<>(); 379 if (sCanMakePaymentQueries == null) sCanMakePaymentQueries = new ArrayMa p<>();
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 query.notifyObserversOfResponse(false); 650 query.notifyObserversOfResponse(false);
646 } 651 }
647 } 652 }
648 653
649 if (disconnectIfNoPaymentMethodsSupported()) return; 654 if (disconnectIfNoPaymentMethodsSupported()) return;
650 655
651 // Query instruments after mMerchantSupportsAutofillPaymentInstruments h as been initialized, 656 // Query instruments after mMerchantSupportsAutofillPaymentInstruments h as been initialized,
652 // so a fast response from a non-autofill payment app at the front of th e app list does not 657 // so a fast response from a non-autofill payment app at the front of th e app list does not
653 // cause NOT_SUPPORTED payment rejection. 658 // cause NOT_SUPPORTED payment rejection.
654 for (Map.Entry<PaymentApp, Map<String, PaymentMethodData>> q : queryApps .entrySet()) { 659 for (Map.Entry<PaymentApp, Map<String, PaymentMethodData>> q : queryApps .entrySet()) {
655 q.getKey().getInstruments( 660 q.getKey().getInstruments(q.getValue(), mSchemelessOriginForPaymentA pp,
656 q.getValue(), mSchemelessOriginForPaymentApp, mCertificateCh ain, this); 661 mSchemelessIFrameOriginForPaymentApp, mCertificateChain, thi s);
657 } 662 }
658 } 663 }
659 664
660 /** Filter out merchant method data that's not relevant to a payment app. Ca n return null. */ 665 /** Filter out merchant method data that's not relevant to a payment app. Ca n return null. */
661 private static Map<String, PaymentMethodData> filterMerchantMethodData( 666 private static Map<String, PaymentMethodData> filterMerchantMethodData(
662 Map<String, PaymentMethodData> merchantMethodData, Set<String> appMe thods) { 667 Map<String, PaymentMethodData> merchantMethodData, Set<String> appMe thods) {
663 Map<String, PaymentMethodData> result = null; 668 Map<String, PaymentMethodData> result = null;
664 for (String method : appMethods) { 669 for (String method : appMethods) {
665 if (merchantMethodData.containsKey(method)) { 670 if (merchantMethodData.containsKey(method)) {
666 if (result == null) result = new ArrayMap<>(); 671 if (result == null) result = new ArrayMap<>();
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 for (String instrumentMethodName : instrument.getInstrumentMethodNames() ) { 1173 for (String instrumentMethodName : instrument.getInstrumentMethodNames() ) {
1169 if (mMethodData.containsKey(instrumentMethodName)) { 1174 if (mMethodData.containsKey(instrumentMethodName)) {
1170 methodData.put(instrumentMethodName, mMethodData.get(instrumentM ethodName)); 1175 methodData.put(instrumentMethodName, mMethodData.get(instrumentM ethodName));
1171 } 1176 }
1172 if (mModifiers != null && mModifiers.containsKey(instrumentMethodNam e)) { 1177 if (mModifiers != null && mModifiers.containsKey(instrumentMethodNam e)) {
1173 modifiers.put(instrumentMethodName, mModifiers.get(instrumentMet hodName)); 1178 modifiers.put(instrumentMethodName, mModifiers.get(instrumentMet hodName));
1174 } 1179 }
1175 } 1180 }
1176 1181
1177 instrument.invokePaymentApp(mMerchantName, mSchemelessOriginForPaymentAp p, 1182 instrument.invokePaymentApp(mMerchantName, mSchemelessOriginForPaymentAp p,
1178 mCertificateChain, Collections.unmodifiableMap(methodData), mRaw Total, 1183 mSchemelessIFrameOriginForPaymentApp, mCertificateChain,
1179 mRawLineItems, Collections.unmodifiableMap(modifiers), this); 1184 Collections.unmodifiableMap(methodData), mRawTotal, mRawLineItem s,
1185 Collections.unmodifiableMap(modifiers), this);
1180 1186
1181 recordSuccessFunnelHistograms("PayClicked"); 1187 recordSuccessFunnelHistograms("PayClicked");
1182 return !(instrument instanceof AutofillPaymentInstrument); 1188 return !(instrument instanceof AutofillPaymentInstrument);
1183 } 1189 }
1184 1190
1185 @Override 1191 @Override
1186 public void onDismiss() { 1192 public void onDismiss() {
1187 disconnectFromClientWithDebugMessage("Dialog dismissed"); 1193 disconnectFromClientWithDebugMessage("Dialog dismissed");
1188 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY _USER); 1194 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY _USER);
1189 } 1195 }
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 1668
1663 /** 1669 /**
1664 * The frecency score is calculated according to use count and last use date . The formula is 1670 * The frecency score is calculated according to use count and last use date . The formula is
1665 * the same as the one used in GetFrecencyScore in autofill_data_model.cc. 1671 * the same as the one used in GetFrecencyScore in autofill_data_model.cc.
1666 */ 1672 */
1667 private static final double getFrecencyScore(int count, long date) { 1673 private static final double getFrecencyScore(int count, long date) {
1668 long currentTime = System.currentTimeMillis(); 1674 long currentTime = System.currentTimeMillis();
1669 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat h.log(count + 2); 1675 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat h.log(count + 2);
1670 } 1676 }
1671 } 1677 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698