OLD | NEW |
---|---|
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 } | 411 } |
412 | 412 |
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; |
please use gerrit instead
2017/03/27 14:00:05
Please add this block of code here:
if (mRawTotal
zino
2017/03/27 14:47:47
Done.
| |
422 | 422 |
423 PaymentAppFactory.getInstance().create(mWebContents, | 423 PaymentAppFactory.getInstance().create(mWebContents, |
424 Collections.unmodifiableSet(mMethodData.keySet()), this /* callb ack */); | 424 Collections.unmodifiableSet(mMethodData.keySet()), this /* callb ack */); |
425 | 425 |
426 mRequestShipping = options != null && options.requestShipping; | 426 mRequestShipping = options != null && options.requestShipping; |
427 mRequestPayerName = options != null && options.requestPayerName; | 427 mRequestPayerName = options != null && options.requestPayerName; |
428 mRequestPayerPhone = options != null && options.requestPayerPhone; | 428 mRequestPayerPhone = options != null && options.requestPayerPhone; |
429 mRequestPayerEmail = options != null && options.requestPayerEmail; | 429 mRequestPayerEmail = options != null && options.requestPayerEmail; |
430 mShippingType = options == null ? PaymentShippingType.SHIPPING : options .shippingType; | 430 mShippingType = options == null ? PaymentShippingType.SHIPPING : options .shippingType; |
431 | 431 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 recordAbortReasonHistogram( | 728 recordAbortReasonHistogram( |
729 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE R); | 729 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE R); |
730 return false; | 730 return false; |
731 } | 731 } |
732 | 732 |
733 if (mCurrencyFormatter == null) { | 733 if (mCurrencyFormatter == null) { |
734 mCurrencyFormatter = new CurrencyFormatter(details.total.amount.curr ency, | 734 mCurrencyFormatter = new CurrencyFormatter(details.total.amount.curr ency, |
735 details.total.amount.currencySystem, Locale.getDefault()); | 735 details.total.amount.currencySystem, Locale.getDefault()); |
736 } | 736 } |
737 | 737 |
738 // Total is never pending. | 738 if (details.total != null) { |
739 LineItem uiTotal = new LineItem(details.total.label, | 739 mRawTotal = details.total; |
740 mCurrencyFormatter.getFormattedCurrencyCode(), | 740 } |
741 mCurrencyFormatter.format(details.total.amount.value), /* isPend ing */ false); | |
742 | 741 |
743 List<LineItem> uiLineItems = getLineItems(details.displayItems, mCurrenc yFormatter); | 742 if (mRawTotal != null) { |
please use gerrit instead
2017/03/27 14:00:05
Please remove the lines 740-742. That should make
zino
2017/03/27 14:47:47
Done.
please use gerrit instead
2017/03/27 14:59:39
I'm so sorry. I think you original code was actual
zino
2017/03/27 15:05:55
Oh, right :) Thanks!
| |
743 // Total is never pending. | |
744 LineItem uiTotal = new LineItem(mRawTotal.label, | |
745 mCurrencyFormatter.getFormattedCurrencyCode(), | |
746 mCurrencyFormatter.format(mRawTotal.amount.value), /* isPend ing */ false); | |
744 | 747 |
745 mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems); | 748 List<LineItem> uiLineItems = getLineItems(details.displayItems, mCur rencyFormatter); |
746 mRawTotal = details.total; | 749 |
750 mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems); | |
751 } | |
747 mRawLineItems = Collections.unmodifiableList(Arrays.asList(details.displ ayItems)); | 752 mRawLineItems = Collections.unmodifiableList(Arrays.asList(details.displ ayItems)); |
748 | 753 |
749 mUiShippingOptions = getShippingOptions(details.shippingOptions, mCurren cyFormatter); | 754 mUiShippingOptions = getShippingOptions(details.shippingOptions, mCurren cyFormatter); |
750 | 755 |
751 for (int i = 0; i < details.modifiers.length; i++) { | 756 for (int i = 0; i < details.modifiers.length; i++) { |
752 PaymentDetailsModifier modifier = details.modifiers[i]; | 757 PaymentDetailsModifier modifier = details.modifiers[i]; |
753 String[] methods = modifier.methodData.supportedMethods; | 758 String[] methods = modifier.methodData.supportedMethods; |
754 for (int j = 0; j < methods.length; j++) { | 759 for (int j = 0; j < methods.length; j++) { |
755 if (mModifiers == null) mModifiers = new ArrayMap<>(); | 760 if (mModifiers == null) mModifiers = new ArrayMap<>(); |
756 mModifiers.put(methods[j], modifier); | 761 mModifiers.put(methods[j], modifier); |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1678 | 1683 |
1679 /** | 1684 /** |
1680 * The frecency score is calculated according to use count and last use date . The formula is | 1685 * 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. | 1686 * the same as the one used in GetFrecencyScore in autofill_data_model.cc. |
1682 */ | 1687 */ |
1683 private static final double getFrecencyScore(int count, long date) { | 1688 private static final double getFrecencyScore(int count, long date) { |
1684 long currentTime = System.currentTimeMillis(); | 1689 long currentTime = System.currentTimeMillis(); |
1685 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat h.log(count + 2); | 1690 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat h.log(count + 2); |
1686 } | 1691 } |
1687 } | 1692 } |
OLD | NEW |