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

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

Issue 2774233005: Creating PaymentOptionsProvider interface (Closed)
Patch Set: rouslan 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.h ('k') | components/payments/core/BUILD.gn » ('j') | 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 10
(...skipping 18 matching lines...) Expand all
29 29
30 void PaymentRequestSpec::AddObserver(Observer* observer) { 30 void PaymentRequestSpec::AddObserver(Observer* observer) {
31 CHECK(observer); 31 CHECK(observer);
32 observers_.AddObserver(observer); 32 observers_.AddObserver(observer);
33 } 33 }
34 34
35 void PaymentRequestSpec::RemoveObserver(Observer* observer) { 35 void PaymentRequestSpec::RemoveObserver(Observer* observer) {
36 observers_.RemoveObserver(observer); 36 observers_.RemoveObserver(observer);
37 } 37 }
38 38
39 bool PaymentRequestSpec::request_shipping() const {
40 return options_->request_shipping;
41 }
42 bool PaymentRequestSpec::request_payer_name() const {
43 return options_->request_payer_name;
44 }
45 bool PaymentRequestSpec::request_payer_phone() const {
46 return options_->request_payer_phone;
47 }
48 bool PaymentRequestSpec::request_payer_email() const {
49 return options_->request_payer_email;
50 }
51
52 PaymentShippingType PaymentRequestSpec::shipping_type() const {
53 // Transform Mojo-specific enum into platform-agnostic equivalent.
54 switch (options_->shipping_type) {
55 case mojom::PaymentShippingType::DELIVERY:
56 return PaymentShippingType::DELIVERY;
57 case payments::mojom::PaymentShippingType::PICKUP:
58 return PaymentShippingType::PICKUP;
59 case payments::mojom::PaymentShippingType::SHIPPING:
60 return PaymentShippingType::SHIPPING;
61 default:
62 NOTREACHED();
63 }
64 // Needed for compilation on some platforms.
65 return PaymentShippingType::SHIPPING;
66 }
67
39 bool PaymentRequestSpec::IsMethodSupportedThroughBasicCard( 68 bool PaymentRequestSpec::IsMethodSupportedThroughBasicCard(
40 const std::string& method_name) { 69 const std::string& method_name) {
41 return basic_card_specified_networks_.count(method_name) > 0; 70 return basic_card_specified_networks_.count(method_name) > 0;
42 } 71 }
43 72
44 base::string16 PaymentRequestSpec::GetFormattedCurrencyAmount( 73 base::string16 PaymentRequestSpec::GetFormattedCurrencyAmount(
45 const std::string& amount) { 74 const std::string& amount) {
46 CurrencyFormatter* formatter = GetOrCreateCurrencyFormatter( 75 CurrencyFormatter* formatter = GetOrCreateCurrencyFormatter(
47 details_->total->amount->currency, 76 details_->total->amount->currency,
48 details_->total->amount->currency_system, app_locale_); 77 details_->total->amount->currency_system, app_locale_);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 const std::string& currency_system, 174 const std::string& currency_system,
146 const std::string& locale_name) { 175 const std::string& locale_name) {
147 if (!currency_formatter_) { 176 if (!currency_formatter_) {
148 currency_formatter_.reset( 177 currency_formatter_.reset(
149 new CurrencyFormatter(currency_code, currency_system, locale_name)); 178 new CurrencyFormatter(currency_code, currency_system, locale_name));
150 } 179 }
151 return currency_formatter_.get(); 180 return currency_formatter_.get();
152 } 181 }
153 182
154 } // namespace payments 183 } // namespace payments
OLDNEW
« no previous file with comments | « components/payments/content/payment_request_spec.h ('k') | components/payments/core/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698