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

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

Issue 2893823004: [Payments] Implement openWindow for service worker based payment handler (Closed)
Patch Set: format Created 3 years, 7 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 @Override 251 @Override
252 public void didSelectTab(Tab tab, TabSelectionType type, int lastId) { 252 public void didSelectTab(Tab tab, TabSelectionType type, int lastId) {
253 if (tab == null || tab.getId() != lastId) onDismiss(); 253 if (tab == null || tab.getId() != lastId) onDismiss();
254 } 254 }
255 }; 255 };
256 256
257 private final Handler mHandler = new Handler(); 257 private final Handler mHandler = new Handler();
258 private final RenderFrameHost mRenderFrameHost; 258 private final RenderFrameHost mRenderFrameHost;
259 private final WebContents mWebContents; 259 private final WebContents mWebContents;
260 private final String mTopLevelOrigin; 260 private final String mTopLevelOrigin;
261 private final String mTopLevelOriginForDisplay;
261 private final String mPaymentRequestOrigin; 262 private final String mPaymentRequestOrigin;
262 private final String mMerchantName; 263 private final String mMerchantName;
263 @Nullable 264 @Nullable
264 private final byte[][] mCertificateChain; 265 private final byte[][] mCertificateChain;
265 private final AddressEditor mAddressEditor; 266 private final AddressEditor mAddressEditor;
266 private final CardEditor mCardEditor; 267 private final CardEditor mCardEditor;
267 private final JourneyLogger mJourneyLogger; 268 private final JourneyLogger mJourneyLogger;
268 private final boolean mIsIncognito; 269 private final boolean mIsIncognito;
269 270
270 private PaymentRequestClient mClient; 271 private PaymentRequestClient mClient;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 * Builds the PaymentRequest service implementation. 359 * Builds the PaymentRequest service implementation.
359 * 360 *
360 * @param renderFrameHost The host of the frame that has invoked the Payment Request API. 361 * @param renderFrameHost The host of the frame that has invoked the Payment Request API.
361 */ 362 */
362 public PaymentRequestImpl(RenderFrameHost renderFrameHost) { 363 public PaymentRequestImpl(RenderFrameHost renderFrameHost) {
363 assert renderFrameHost != null; 364 assert renderFrameHost != null;
364 365
365 mRenderFrameHost = renderFrameHost; 366 mRenderFrameHost = renderFrameHost;
366 mWebContents = WebContentsStatics.fromRenderFrameHost(renderFrameHost); 367 mWebContents = WebContentsStatics.fromRenderFrameHost(renderFrameHost);
367 368
368 mPaymentRequestOrigin = UrlFormatter.formatUrlForSecurityDisplay( 369 mPaymentRequestOrigin = mRenderFrameHost.getLastCommittedURL();
369 mRenderFrameHost.getLastCommittedURL(), true); 370 mTopLevelOrigin = mWebContents.getLastCommittedUrl();
please use gerrit instead 2017/05/25 14:53:26 That's a top level URL, because it contains the fu
gogerald1 2017/05/25 16:53:32 Done.
370 mTopLevelOrigin = 371 mTopLevelOriginForDisplay = UrlFormatter.formatUrlForSecurityDisplay(mTo pLevelOrigin, true);
please use gerrit instead 2017/05/25 14:53:26 This should remain mTopLevelOrigin.
gogerald1 2017/05/25 16:53:32 Done.
371 UrlFormatter.formatUrlForSecurityDisplay(mWebContents.getLastCom mittedUrl(), true);
372 372
373 mMerchantName = mWebContents.getTitle(); 373 mMerchantName = mWebContents.getTitle();
374 374
375 mCertificateChain = CertificateChainHelper.getCertificateChain(mWebConte nts); 375 mCertificateChain = CertificateChainHelper.getCertificateChain(mWebConte nts);
376 376
377 mApps = new ArrayList<>(); 377 mApps = new ArrayList<>();
378 378
379 mAddressEditor = new AddressEditor(); 379 mAddressEditor = new AddressEditor();
380 mCardEditor = new CardEditor(mWebContents, mAddressEditor, sObserverForT est); 380 mCardEditor = new CardEditor(mWebContents, mAddressEditor, sObserverForT est);
381 381
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 mContactEditor = 510 mContactEditor =
511 new ContactEditor(mRequestPayerName, mRequestPayerPhone, mRe questPayerEmail); 511 new ContactEditor(mRequestPayerName, mRequestPayerPhone, mRe questPayerEmail);
512 mContactSection = new ContactDetailsSection( 512 mContactSection = new ContactDetailsSection(
513 activity, Collections.unmodifiableList(profiles), mContactEd itor); 513 activity, Collections.unmodifiableList(profiles), mContactEd itor);
514 } 514 }
515 515
516 setIsAnyPaymentRequestShowing(true); 516 setIsAnyPaymentRequestShowing(true);
517 mUI = new PaymentRequestUI(activity, this, mRequestShipping, 517 mUI = new PaymentRequestUI(activity, this, mRequestShipping,
518 mRequestPayerName || mRequestPayerPhone || mRequestPayerEmail, 518 mRequestPayerName || mRequestPayerPhone || mRequestPayerEmail,
519 mMerchantSupportsAutofillPaymentInstruments, 519 mMerchantSupportsAutofillPaymentInstruments,
520 !PaymentPreferencesUtil.isPaymentCompleteOnce(), mMerchantName, mTopLevelOrigin, 520 !PaymentPreferencesUtil.isPaymentCompleteOnce(), mMerchantName,
521 mTopLevelOriginForDisplay,
521 SecurityStateModel.getSecurityLevelForWebContents(mWebContents), 522 SecurityStateModel.getSecurityLevelForWebContents(mWebContents),
522 new ShippingStrings(mShippingType)); 523 new ShippingStrings(mShippingType));
523 524
524 final FaviconHelper faviconHelper = new FaviconHelper(); 525 final FaviconHelper faviconHelper = new FaviconHelper();
525 faviconHelper.getLocalFaviconImageForURL(Profile.getLastUsedProfile(), 526 faviconHelper.getLocalFaviconImageForURL(Profile.getLastUsedProfile(),
526 mWebContents.getLastCommittedUrl(), 527 mWebContents.getLastCommittedUrl(),
527 activity.getResources().getDimensionPixelSize(R.dimen.payments_f avicon_size), 528 activity.getResources().getDimensionPixelSize(R.dimen.payments_f avicon_size),
528 new FaviconHelper.FaviconImageCallback() { 529 new FaviconHelper.FaviconImageCallback() {
529 @Override 530 @Override
530 public void onFaviconAvailable(Bitmap bitmap, String iconUrl ) { 531 public void onFaviconAvailable(Bitmap bitmap, String iconUrl ) {
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 1866
1866 /** 1867 /**
1867 * The frecency score is calculated according to use count and last use date . The formula is 1868 * The frecency score is calculated according to use count and last use date . The formula is
1868 * the same as the one used in GetFrecencyScore in autofill_data_model.cc. 1869 * the same as the one used in GetFrecencyScore in autofill_data_model.cc.
1869 */ 1870 */
1870 private static final double getFrecencyScore(int count, long date) { 1871 private static final double getFrecencyScore(int count, long date) {
1871 long currentTime = System.currentTimeMillis(); 1872 long currentTime = System.currentTimeMillis();
1872 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat h.log(count + 2); 1873 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat h.log(count + 2);
1873 } 1874 }
1874 } 1875 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698