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

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

Issue 2748093003: PaymentRequest: Introduce PaymentDetailsInit and PaymentDetailsUpdate. (Closed)
Patch Set: PaymentRequest: Introduce PaymentDetailsInit and PaymentDetailsUpdate. Created 3 years, 8 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 mMethodData = getValidatedMethodData(methodData, mCardEditor); 413 mMethodData = getValidatedMethodData(methodData, mCardEditor);
414 if (mMethodData == null) { 414 if (mMethodData == null) {
415 disconnectFromClientWithDebugMessage("Invalid payment methods or dat a"); 415 disconnectFromClientWithDebugMessage("Invalid payment methods or dat a");
416 recordAbortReasonHistogram( 416 recordAbortReasonHistogram(
417 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE R); 417 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE R);
418 return; 418 return;
419 } 419 }
420 420
421 if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return; 421 if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return;
422 422
423 if (mRawTotal == null) {
424 disconnectFromClientWithDebugMessage("Missing total");
425 recordAbortReasonHistogram(
426 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE R);
427 return;
428 }
429
423 PaymentAppFactory.getInstance().create(mWebContents, 430 PaymentAppFactory.getInstance().create(mWebContents,
424 Collections.unmodifiableSet(mMethodData.keySet()), this /* callb ack */); 431 Collections.unmodifiableSet(mMethodData.keySet()), this /* callb ack */);
425 432
426 mRequestShipping = options != null && options.requestShipping; 433 mRequestShipping = options != null && options.requestShipping;
427 mRequestPayerName = options != null && options.requestPayerName; 434 mRequestPayerName = options != null && options.requestPayerName;
428 mRequestPayerPhone = options != null && options.requestPayerPhone; 435 mRequestPayerPhone = options != null && options.requestPayerPhone;
429 mRequestPayerEmail = options != null && options.requestPayerEmail; 436 mRequestPayerEmail = options != null && options.requestPayerEmail;
430 mShippingType = options == null ? PaymentShippingType.SHIPPING : options .shippingType; 437 mShippingType = options == null ? PaymentShippingType.SHIPPING : options .shippingType;
431 438
432 // If there is a single payment method and the merchant has not requeste d any other 439 // If there is a single payment method and the merchant has not requeste d any other
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 recordAbortReasonHistogram( 735 recordAbortReasonHistogram(
729 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE R); 736 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE R);
730 return false; 737 return false;
731 } 738 }
732 739
733 if (mCurrencyFormatter == null) { 740 if (mCurrencyFormatter == null) {
734 mCurrencyFormatter = new CurrencyFormatter(details.total.amount.curr ency, 741 mCurrencyFormatter = new CurrencyFormatter(details.total.amount.curr ency,
735 details.total.amount.currencySystem, Locale.getDefault()); 742 details.total.amount.currencySystem, Locale.getDefault());
736 } 743 }
737 744
738 // Total is never pending. 745 if (details.total != null) {
739 LineItem uiTotal = new LineItem(details.total.label, 746 mRawTotal = details.total;
740 mCurrencyFormatter.getFormattedCurrencyCode(), 747 }
741 mCurrencyFormatter.format(details.total.amount.value), /* isPend ing */ false);
742 748
743 List<LineItem> uiLineItems = getLineItems(details.displayItems, mCurrenc yFormatter); 749 if (mRawTotal != null) {
750 // Total is never pending.
751 LineItem uiTotal = new LineItem(mRawTotal.label,
752 mCurrencyFormatter.getFormattedCurrencyCode(),
753 mCurrencyFormatter.format(mRawTotal.amount.value), /* isPend ing */ false);
744 754
745 mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems); 755 List<LineItem> uiLineItems = getLineItems(details.displayItems, mCur rencyFormatter);
746 mRawTotal = details.total; 756
757 mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems);
758 }
747 mRawLineItems = Collections.unmodifiableList(Arrays.asList(details.displ ayItems)); 759 mRawLineItems = Collections.unmodifiableList(Arrays.asList(details.displ ayItems));
748 760
749 mUiShippingOptions = getShippingOptions(details.shippingOptions, mCurren cyFormatter); 761 mUiShippingOptions = getShippingOptions(details.shippingOptions, mCurren cyFormatter);
750 762
751 for (int i = 0; i < details.modifiers.length; i++) { 763 for (int i = 0; i < details.modifiers.length; i++) {
752 PaymentDetailsModifier modifier = details.modifiers[i]; 764 PaymentDetailsModifier modifier = details.modifiers[i];
753 String[] methods = modifier.methodData.supportedMethods; 765 String[] methods = modifier.methodData.supportedMethods;
754 for (int j = 0; j < methods.length; j++) { 766 for (int j = 0; j < methods.length; j++) {
755 if (mModifiers == null) mModifiers = new ArrayMap<>(); 767 if (mModifiers == null) mModifiers = new ArrayMap<>();
756 mModifiers.put(methods[j], modifier); 768 mModifiers.put(methods[j], modifier);
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 1690
1679 /** 1691 /**
1680 * The frecency score is calculated according to use count and last use date . The formula is 1692 * The frecency score is calculated according to use count and last use date . The formula is
1681 * the same as the one used in GetFrecencyScore in autofill_data_model.cc. 1693 * the same as the one used in GetFrecencyScore in autofill_data_model.cc.
1682 */ 1694 */
1683 private static final double getFrecencyScore(int count, long date) { 1695 private static final double getFrecencyScore(int count, long date) {
1684 long currentTime = System.currentTimeMillis(); 1696 long currentTime = System.currentTimeMillis();
1685 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat h.log(count + 2); 1697 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat h.log(count + 2);
1686 } 1698 }
1687 } 1699 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698