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

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

Issue 2708933003: [Payments] Add timeout to the address_normalizer. (Closed)
Patch Set: Nits Created 3 years, 9 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.os.Handler;
8
9 import org.chromium.chrome.browser.autofill.PersonalDataManager; 7 import org.chromium.chrome.browser.autofill.PersonalDataManager;
10 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; 8 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
11 import org.chromium.chrome.browser.autofill.PersonalDataManager.NormalizedAddres sRequestDelegate; 9 import org.chromium.chrome.browser.autofill.PersonalDataManager.NormalizedAddres sRequestDelegate;
12 import org.chromium.chrome.browser.payments.ui.PaymentOption; 10 import org.chromium.chrome.browser.payments.ui.PaymentOption;
13 import org.chromium.payments.mojom.PaymentResponse; 11 import org.chromium.payments.mojom.PaymentResponse;
14 12
15 /** 13 /**
16 * The helper class to create and prepare a PaymentResponse. 14 * The helper class to create and prepare a PaymentResponse.
17 */ 15 */
18 public class PaymentResponseHelper implements NormalizedAddressRequestDelegate { 16 public class PaymentResponseHelper implements NormalizedAddressRequestDelegate {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // The shipping address needs to be normalized before sending the re sponse to the 81 // The shipping address needs to be normalized before sending the re sponse to the
84 // merchant. 82 // merchant.
85 mIsWaitingForShippingNormalization = true; 83 mIsWaitingForShippingNormalization = true;
86 PersonalDataManager.getInstance().normalizeAddress( 84 PersonalDataManager.getInstance().normalizeAddress(
87 mSelectedShippingAddress.getProfile().getGUID(), 85 mSelectedShippingAddress.getProfile().getGUID(),
88 AutofillAddress.getCountryCode(mSelectedShippingAddress.getP rofile()), this); 86 AutofillAddress.getCountryCode(mSelectedShippingAddress.getP rofile()), this);
89 } 87 }
90 } 88 }
91 89
92 /** 90 /**
93 * Called when the intrument details have started loading. Starts a timeout to stop the shipping
94 * address normalization if it takes too long.
95 */
96 public void onInstrumentsDetailsLoading() {
97 if (mIsWaitingForShippingNormalization) {
98 // If the normalization is not completed yet, start a timer to cance l it if it takes too
99 // long.
100 new Handler().postDelayed(new Runnable() {
101 @Override
102 public void run() {
103 onAddressNormalized(null);
104 }
105 }, PersonalDataManager.getInstance().getNormalizationTimeoutMS());
106 }
107 }
108
109 /**
110 * Called after the payment instrument's details were received. 91 * Called after the payment instrument's details were received.
111 * 92 *
112 * @param methodName The method name of the payment instrument. 93 * @param methodName The method name of the payment instrument.
113 * @param stringifiedDetails A string containing all the details of the pay ment instrument's 94 * @param stringifiedDetails A string containing all the details of the pay ment instrument's
114 * details. 95 * details.
115 */ 96 */
116 public void onInstrumentDetailsReceived(String methodName, String stringifie dDetails) { 97 public void onInstrumentDetailsReceived(String methodName, String stringifie dDetails) {
117 mPaymentResponse.methodName = methodName; 98 mPaymentResponse.methodName = methodName;
118 mPaymentResponse.stringifiedDetails = stringifiedDetails; 99 mPaymentResponse.stringifiedDetails = stringifiedDetails;
119 100
(...skipping 17 matching lines...) Expand all
137 118
138 // Wait for the payment details before sending the response. 119 // Wait for the payment details before sending the response.
139 if (!mIsWaitingForPaymentsDetails) mDelegate.onPaymentResponseReady(mPay mentResponse); 120 if (!mIsWaitingForPaymentsDetails) mDelegate.onPaymentResponseReady(mPay mentResponse);
140 } 121 }
141 122
142 @Override 123 @Override
143 public void onCouldNotNormalize(AutofillProfile profile) { 124 public void onCouldNotNormalize(AutofillProfile profile) {
144 onAddressNormalized(null); 125 onAddressNormalized(null);
145 } 126 }
146 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698