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

Side by Side Diff: components/payments/content/payment_request_state.cc

Issue 2815723002: [Web Payments] Add Spinners and timeout while waiting for UpdateWith (Closed)
Patch Set: Address comments. 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
« no previous file with comments | « components/payments/content/payment_request_spec.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/payments/content/payment_request_state.h" 5 #include "components/payments/content/payment_request_state.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/core/browser/autofill_data_util.h" 10 #include "components/autofill/core/browser/autofill_data_util.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 basic_card_network, card, shipping_profiles_, app_locale_, 91 basic_card_network, card, shipping_profiles_, app_locale_,
92 payment_request_delegate_); 92 payment_request_delegate_);
93 available_instruments_.push_back(std::move(instrument)); 93 available_instruments_.push_back(std::move(instrument));
94 94
95 if (selected) 95 if (selected)
96 SetSelectedInstrument(available_instruments_.back().get()); 96 SetSelectedInstrument(available_instruments_.back().get());
97 } 97 }
98 98
99 void PaymentRequestState::SetSelectedShippingOption( 99 void PaymentRequestState::SetSelectedShippingOption(
100 const std::string& shipping_option_id) { 100 const std::string& shipping_option_id) {
101 spec_->StartWaitingForUpdateWith(
102 PaymentRequestSpec::UpdateReason::SHIPPING_OPTION);
101 // This will inform the merchant and will lead to them calling updateWith with 103 // This will inform the merchant and will lead to them calling updateWith with
102 // new PaymentDetails. 104 // new PaymentDetails.
103 delegate_->OnShippingOptionIdSelected(shipping_option_id); 105 delegate_->OnShippingOptionIdSelected(shipping_option_id);
104 } 106 }
105 107
106 void PaymentRequestState::SetSelectedShippingProfile( 108 void PaymentRequestState::SetSelectedShippingProfile(
107 autofill::AutofillProfile* profile) { 109 autofill::AutofillProfile* profile) {
110 spec_->StartWaitingForUpdateWith(
111 PaymentRequestSpec::UpdateReason::SHIPPING_ADDRESS);
108 selected_shipping_profile_ = profile; 112 selected_shipping_profile_ = profile;
109 UpdateIsReadyToPayAndNotifyObservers(); 113 UpdateIsReadyToPayAndNotifyObservers();
110 delegate_->OnShippingAddressSelected( 114 delegate_->OnShippingAddressSelected(
111 PaymentResponseHelper::GetMojomPaymentAddressFromAutofillProfile( 115 PaymentResponseHelper::GetMojomPaymentAddressFromAutofillProfile(
112 selected_shipping_profile_, app_locale_)); 116 selected_shipping_profile_, app_locale_));
113 } 117 }
114 118
115 void PaymentRequestState::SetSelectedContactProfile( 119 void PaymentRequestState::SetSelectedContactProfile(
116 autofill::AutofillProfile* profile) { 120 autofill::AutofillProfile* profile) {
117 selected_contact_profile_ = profile; 121 selected_contact_profile_ = profile;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 bool PaymentRequestState::ArePaymentOptionsSatisfied() { 217 bool PaymentRequestState::ArePaymentOptionsSatisfied() {
214 // TODO(mathp): Have a measure of shipping address completeness. 218 // TODO(mathp): Have a measure of shipping address completeness.
215 if (spec_->request_shipping() && selected_shipping_profile_ == nullptr) 219 if (spec_->request_shipping() && selected_shipping_profile_ == nullptr)
216 return false; 220 return false;
217 221
218 profile_util::PaymentsProfileComparator comparator(app_locale_, *spec_); 222 profile_util::PaymentsProfileComparator comparator(app_locale_, *spec_);
219 return comparator.IsContactInfoComplete(selected_contact_profile_); 223 return comparator.IsContactInfoComplete(selected_contact_profile_);
220 } 224 }
221 225
222 } // namespace payments 226 } // namespace payments
OLDNEW
« no previous file with comments | « components/payments/content/payment_request_spec.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698