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

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

Issue 2770193003: Implement request id in PaymentDetailsInit (Closed)
Patch Set: s/requestId/id 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 * price string. This data is passed to the UI. 288 * price string. This data is passed to the UI.
289 */ 289 */
290 private ShoppingCart mUiShoppingCart; 290 private ShoppingCart mUiShoppingCart;
291 291
292 /** 292 /**
293 * The UI model for the shipping options. Includes the label and sublabel fo r each shipping 293 * The UI model for the shipping options. Includes the label and sublabel fo r each shipping
294 * option. Also keeps track of the selected shipping option. This data is pa ssed to the UI. 294 * option. Also keeps track of the selected shipping option. This data is pa ssed to the UI.
295 */ 295 */
296 private SectionInformation mUiShippingOptions; 296 private SectionInformation mUiShippingOptions;
297 297
298 private String mId;
please use gerrit instead 2017/03/27 16:22:36 Make this final and move it to the block of final
rwlbuis 2017/03/27 20:45:29 I dont think I can make it final.
298 private Map<String, PaymentMethodData> mMethodData; 299 private Map<String, PaymentMethodData> mMethodData;
299 private boolean mRequestShipping; 300 private boolean mRequestShipping;
300 private boolean mRequestPayerName; 301 private boolean mRequestPayerName;
301 private boolean mRequestPayerPhone; 302 private boolean mRequestPayerPhone;
302 private boolean mRequestPayerEmail; 303 private boolean mRequestPayerEmail;
303 private int mShippingType; 304 private int mShippingType;
304 private SectionInformation mShippingAddressesSection; 305 private SectionInformation mShippingAddressesSection;
305 private ContactDetailsSection mContactSection; 306 private ContactDetailsSection mContactSection;
306 private List<PaymentApp> mApps; 307 private List<PaymentApp> mApps;
307 private List<PaymentApp> mPendingApps; 308 private List<PaymentApp> mPendingApps;
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 PaymentDetailsModifier modifier = details.modifiers[i]; 753 PaymentDetailsModifier modifier = details.modifiers[i];
753 String[] methods = modifier.methodData.supportedMethods; 754 String[] methods = modifier.methodData.supportedMethods;
754 for (int j = 0; j < methods.length; j++) { 755 for (int j = 0; j < methods.length; j++) {
755 if (mModifiers == null) mModifiers = new ArrayMap<>(); 756 if (mModifiers == null) mModifiers = new ArrayMap<>();
756 mModifiers.put(methods[j], modifier); 757 mModifiers.put(methods[j], modifier);
757 } 758 }
758 } 759 }
759 760
760 updateInstrumentModifiedTotals(); 761 updateInstrumentModifiedTotals();
761 762
763 if (details.id != null) {
please use gerrit instead 2017/03/27 16:22:36 "id" can be set only in init(). It should not be s
rwlbuis 2017/03/27 20:45:29 Done.
764 mId = details.id;
765 }
766
762 return true; 767 return true;
763 } 768 }
764 769
765 /** Updates the modifiers for payment instruments and order summary. */ 770 /** Updates the modifiers for payment instruments and order summary. */
766 private void updateInstrumentModifiedTotals() { 771 private void updateInstrumentModifiedTotals() {
767 if (!ChromeFeatureList.isEnabled(ChromeFeatureList.WEB_PAYMENTS_MODIFIER S)) return; 772 if (!ChromeFeatureList.isEnabled(ChromeFeatureList.WEB_PAYMENTS_MODIFIER S)) return;
768 if (mModifiers == null) return; 773 if (mModifiers == null) return;
769 if (mPaymentMethodsSection == null) return; 774 if (mPaymentMethodsSection == null) return;
770 775
771 for (int i = 0; i < mPaymentMethodsSection.getSize(); i++) { 776 for (int i = 0; i < mPaymentMethodsSection.getSize(); i++) {
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 @Override 1165 @Override
1161 public boolean onPayClicked(PaymentOption selectedShippingAddress, 1166 public boolean onPayClicked(PaymentOption selectedShippingAddress,
1162 PaymentOption selectedShippingOption, PaymentOption selectedPaymentM ethod) { 1167 PaymentOption selectedShippingOption, PaymentOption selectedPaymentM ethod) {
1163 assert selectedPaymentMethod instanceof PaymentInstrument; 1168 assert selectedPaymentMethod instanceof PaymentInstrument;
1164 PaymentInstrument instrument = (PaymentInstrument) selectedPaymentMethod ; 1169 PaymentInstrument instrument = (PaymentInstrument) selectedPaymentMethod ;
1165 mPaymentAppRunning = true; 1170 mPaymentAppRunning = true;
1166 1171
1167 PaymentOption selectedContact = mContactSection != null ? mContactSectio n.getSelectedItem() 1172 PaymentOption selectedContact = mContactSection != null ? mContactSectio n.getSelectedItem()
1168 : null; 1173 : null;
1169 mPaymentResponseHelper = new PaymentResponseHelper( 1174 mPaymentResponseHelper = new PaymentResponseHelper(
1170 selectedShippingAddress, selectedShippingOption, selectedContact , this); 1175 mId, selectedShippingAddress, selectedShippingOption, selectedCo ntact, this);
please use gerrit instead 2017/03/27 16:22:36 No need to pass `mId` back into the renderer. The
rwlbuis 2017/03/27 20:45:29 Done.
1171 1176
1172 // Create maps that are subsets of mMethodData and mModifiers, that cont ain 1177 // Create maps that are subsets of mMethodData and mModifiers, that cont ain
1173 // the payment methods supported by the selected payment instrument. If the 1178 // the payment methods supported by the selected payment instrument. If the
1174 // intersection of method data contains more than one payment method, th e 1179 // intersection of method data contains more than one payment method, th e
1175 // payment app is at liberty to choose (or have the user choose) one of the 1180 // payment app is at liberty to choose (or have the user choose) one of the
1176 // methods. 1181 // methods.
1177 Map<String, PaymentMethodData> methodData = new HashMap<>(); 1182 Map<String, PaymentMethodData> methodData = new HashMap<>();
1178 Map<String, PaymentDetailsModifier> modifiers = new HashMap<>(); 1183 Map<String, PaymentDetailsModifier> modifiers = new HashMap<>();
1179 for (String instrumentMethodName : instrument.getInstrumentMethodNames() ) { 1184 for (String instrumentMethodName : instrument.getInstrumentMethodNames() ) {
1180 if (mMethodData.containsKey(instrumentMethodName)) { 1185 if (mMethodData.containsKey(instrumentMethodName)) {
1181 methodData.put(instrumentMethodName, mMethodData.get(instrumentM ethodName)); 1186 methodData.put(instrumentMethodName, mMethodData.get(instrumentM ethodName));
1182 } 1187 }
1183 if (mModifiers != null && mModifiers.containsKey(instrumentMethodNam e)) { 1188 if (mModifiers != null && mModifiers.containsKey(instrumentMethodNam e)) {
1184 modifiers.put(instrumentMethodName, mModifiers.get(instrumentMet hodName)); 1189 modifiers.put(instrumentMethodName, mModifiers.get(instrumentMet hodName));
1185 } 1190 }
1186 } 1191 }
1187 1192
1188 instrument.invokePaymentApp(mMerchantName, mSchemelessOriginForPaymentAp p, 1193 instrument.invokePaymentApp(mId, mMerchantName, mSchemelessOriginForPaym entApp,
1189 mSchemelessIFrameOriginForPaymentApp, mCertificateChain, 1194 mSchemelessIFrameOriginForPaymentApp, mCertificateChain,
1190 Collections.unmodifiableMap(methodData), mRawTotal, mRawLineItem s, 1195 Collections.unmodifiableMap(methodData), mRawTotal, mRawLineItem s,
1191 Collections.unmodifiableMap(modifiers), this); 1196 Collections.unmodifiableMap(modifiers), this);
1192 1197
1193 recordSuccessFunnelHistograms("PayClicked"); 1198 recordSuccessFunnelHistograms("PayClicked");
1194 return !(instrument instanceof AutofillPaymentInstrument); 1199 return !(instrument instanceof AutofillPaymentInstrument);
1195 } 1200 }
1196 1201
1197 @Override 1202 @Override
1198 public void onDismiss() { 1203 public void onDismiss() {
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698