| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 * price string. This data is passed to the UI. | 293 * price string. This data is passed to the UI. |
| 294 */ | 294 */ |
| 295 private ShoppingCart mUiShoppingCart; | 295 private ShoppingCart mUiShoppingCart; |
| 296 | 296 |
| 297 /** | 297 /** |
| 298 * The UI model for the shipping options. Includes the label and sublabel fo
r each shipping | 298 * The UI model for the shipping options. Includes the label and sublabel fo
r each shipping |
| 299 * option. Also keeps track of the selected shipping option. This data is pa
ssed to the UI. | 299 * option. Also keeps track of the selected shipping option. This data is pa
ssed to the UI. |
| 300 */ | 300 */ |
| 301 private SectionInformation mUiShippingOptions; | 301 private SectionInformation mUiShippingOptions; |
| 302 | 302 |
| 303 private String mId; |
| 303 private Map<String, PaymentMethodData> mMethodData; | 304 private Map<String, PaymentMethodData> mMethodData; |
| 304 private boolean mRequestShipping; | 305 private boolean mRequestShipping; |
| 305 private boolean mRequestPayerName; | 306 private boolean mRequestPayerName; |
| 306 private boolean mRequestPayerPhone; | 307 private boolean mRequestPayerPhone; |
| 307 private boolean mRequestPayerEmail; | 308 private boolean mRequestPayerEmail; |
| 308 private int mShippingType; | 309 private int mShippingType; |
| 309 private SectionInformation mShippingAddressesSection; | 310 private SectionInformation mShippingAddressesSection; |
| 310 private ContactDetailsSection mContactSection; | 311 private ContactDetailsSection mContactSection; |
| 311 private List<PaymentApp> mApps; | 312 private List<PaymentApp> mApps; |
| 312 private List<PaymentApp> mPendingApps; | 313 private List<PaymentApp> mPendingApps; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 451 } |
| 451 | 452 |
| 452 if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return; | 453 if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return; |
| 453 | 454 |
| 454 if (mRawTotal == null) { | 455 if (mRawTotal == null) { |
| 455 recordAbortReasonHistogram( | 456 recordAbortReasonHistogram( |
| 456 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE
R); | 457 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE
R); |
| 457 disconnectFromClientWithDebugMessage("Missing total"); | 458 disconnectFromClientWithDebugMessage("Missing total"); |
| 458 return; | 459 return; |
| 459 } | 460 } |
| 461 mId = details.id; |
| 460 | 462 |
| 461 PaymentAppFactory.getInstance().create(mWebContents, | 463 PaymentAppFactory.getInstance().create(mWebContents, |
| 462 Collections.unmodifiableSet(mMethodData.keySet()), this /* callb
ack */); | 464 Collections.unmodifiableSet(mMethodData.keySet()), this /* callb
ack */); |
| 463 | 465 |
| 464 // If there is a single payment method and the merchant has not requeste
d any other | 466 // If there is a single payment method and the merchant has not requeste
d any other |
| 465 // information, we can safely go directly to the payment app instead of
showing | 467 // information, we can safely go directly to the payment app instead of
showing |
| 466 // Payment Request UI. | 468 // Payment Request UI. |
| 467 mShouldSkipShowingPaymentRequestUi = | 469 mShouldSkipShowingPaymentRequestUi = |
| 468 ChromeFeatureList.isEnabled(ChromeFeatureList.WEB_PAYMENTS_SINGL
E_APP_UI_SKIP) | 470 ChromeFeatureList.isEnabled(ChromeFeatureList.WEB_PAYMENTS_SINGL
E_APP_UI_SKIP) |
| 469 && mMethodData.size() == 1 && !mRequestShipping && !mRequestPaye
rName | 471 && mMethodData.size() == 1 && !mRequestShipping && !mRequestPaye
rName |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 Map<String, PaymentDetailsModifier> modifiers = new HashMap<>(); | 1220 Map<String, PaymentDetailsModifier> modifiers = new HashMap<>(); |
| 1219 for (String instrumentMethodName : instrument.getInstrumentMethodNames()
) { | 1221 for (String instrumentMethodName : instrument.getInstrumentMethodNames()
) { |
| 1220 if (mMethodData.containsKey(instrumentMethodName)) { | 1222 if (mMethodData.containsKey(instrumentMethodName)) { |
| 1221 methodData.put(instrumentMethodName, mMethodData.get(instrumentM
ethodName)); | 1223 methodData.put(instrumentMethodName, mMethodData.get(instrumentM
ethodName)); |
| 1222 } | 1224 } |
| 1223 if (mModifiers != null && mModifiers.containsKey(instrumentMethodNam
e)) { | 1225 if (mModifiers != null && mModifiers.containsKey(instrumentMethodNam
e)) { |
| 1224 modifiers.put(instrumentMethodName, mModifiers.get(instrumentMet
hodName)); | 1226 modifiers.put(instrumentMethodName, mModifiers.get(instrumentMet
hodName)); |
| 1225 } | 1227 } |
| 1226 } | 1228 } |
| 1227 | 1229 |
| 1228 instrument.invokePaymentApp(mMerchantName, mSchemelessOriginForPaymentAp
p, | 1230 instrument.invokePaymentApp(mId, mMerchantName, mSchemelessOriginForPaym
entApp, |
| 1229 mSchemelessIFrameOriginForPaymentApp, mCertificateChain, | 1231 mSchemelessIFrameOriginForPaymentApp, mCertificateChain, |
| 1230 Collections.unmodifiableMap(methodData), mRawTotal, mRawLineItem
s, | 1232 Collections.unmodifiableMap(methodData), mRawTotal, mRawLineItem
s, |
| 1231 Collections.unmodifiableMap(modifiers), this); | 1233 Collections.unmodifiableMap(modifiers), this); |
| 1232 | 1234 |
| 1233 recordSuccessFunnelHistograms("PayClicked"); | 1235 recordSuccessFunnelHistograms("PayClicked"); |
| 1234 mJourneyLogger.setEventOccurred(JourneyLogger.EVENT_PAY_CLICKED); | 1236 mJourneyLogger.setEventOccurred(JourneyLogger.EVENT_PAY_CLICKED); |
| 1235 return !(instrument instanceof AutofillPaymentInstrument); | 1237 return !(instrument instanceof AutofillPaymentInstrument); |
| 1236 } | 1238 } |
| 1237 | 1239 |
| 1238 @Override | 1240 @Override |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 | 1800 |
| 1799 /** | 1801 /** |
| 1800 * The frecency score is calculated according to use count and last use date
. The formula is | 1802 * The frecency score is calculated according to use count and last use date
. The formula is |
| 1801 * the same as the one used in GetFrecencyScore in autofill_data_model.cc. | 1803 * the same as the one used in GetFrecencyScore in autofill_data_model.cc. |
| 1802 */ | 1804 */ |
| 1803 private static final double getFrecencyScore(int count, long date) { | 1805 private static final double getFrecencyScore(int count, long date) { |
| 1804 long currentTime = System.currentTimeMillis(); | 1806 long currentTime = System.currentTimeMillis(); |
| 1805 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat
h.log(count + 2); | 1807 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat
h.log(count + 2); |
| 1806 } | 1808 } |
| 1807 } | 1809 } |
| OLD | NEW |