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

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

Issue 2808883002: [Payments] Fix bug in shipping option selection. (Closed)
Patch Set: Initial 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 | « chrome/test/BUILD.gn ('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_spec.h" 5 #include "components/payments/content/payment_request_spec.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "components/payments/core/payment_method_data.h" 10 #include "components/payments/core/payment_method_data.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 // As per the spec, the selected shipping option should initially be the last 172 // As per the spec, the selected shipping option should initially be the last
173 // one in the array that has its selected field set to true. 173 // one in the array that has its selected field set to true.
174 auto selected_shipping_option_it = std::find_if( 174 auto selected_shipping_option_it = std::find_if(
175 details().shipping_options.rbegin(), details().shipping_options.rend(), 175 details().shipping_options.rbegin(), details().shipping_options.rend(),
176 [](const payments::mojom::PaymentShippingOptionPtr& element) { 176 [](const payments::mojom::PaymentShippingOptionPtr& element) {
177 return element->selected; 177 return element->selected;
178 }); 178 });
179 if (selected_shipping_option_it != details().shipping_options.rend()) { 179 if (selected_shipping_option_it != details().shipping_options.rend()) {
180 selected_shipping_option_ = selected_shipping_option_it->get(); 180 selected_shipping_option_ = selected_shipping_option_it->get();
181 } else {
182 // It's possible that there is no selected shipping option.
183 // TODO(crbug.com/710004): Show an error in this case.
184 selected_shipping_option_ = nullptr;
181 } 185 }
182 } 186 }
183 187
184 void PaymentRequestSpec::NotifyOnInvalidSpecProvided() { 188 void PaymentRequestSpec::NotifyOnInvalidSpecProvided() {
185 for (auto& observer : observers_) 189 for (auto& observer : observers_)
186 observer.OnInvalidSpecProvided(); 190 observer.OnInvalidSpecProvided();
187 if (observer_for_testing_) 191 if (observer_for_testing_)
188 observer_for_testing_->OnInvalidSpecProvided(); 192 observer_for_testing_->OnInvalidSpecProvided();
189 } 193 }
190 194
191 void PaymentRequestSpec::NotifyOnSpecUpdated() { 195 void PaymentRequestSpec::NotifyOnSpecUpdated() {
192 for (auto& observer : observers_) 196 for (auto& observer : observers_)
193 observer.OnSpecUpdated(); 197 observer.OnSpecUpdated();
194 if (observer_for_testing_) 198 if (observer_for_testing_)
195 observer_for_testing_->OnSpecUpdated(); 199 observer_for_testing_->OnSpecUpdated();
196 } 200 }
197 201
198 CurrencyFormatter* PaymentRequestSpec::GetOrCreateCurrencyFormatter( 202 CurrencyFormatter* PaymentRequestSpec::GetOrCreateCurrencyFormatter(
199 const std::string& currency_code, 203 const std::string& currency_code,
200 const std::string& currency_system, 204 const std::string& currency_system,
201 const std::string& locale_name) { 205 const std::string& locale_name) {
202 if (!currency_formatter_) { 206 if (!currency_formatter_) {
203 currency_formatter_.reset( 207 currency_formatter_.reset(
204 new CurrencyFormatter(currency_code, currency_system, locale_name)); 208 new CurrencyFormatter(currency_code, currency_system, locale_name));
205 } 209 }
206 return currency_formatter_.get(); 210 return currency_formatter_.get();
207 } 211 }
208 212
209 } // namespace payments 213 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698