OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/core/payment_request_data_util.h" | 5 #include "components/payments/core/payment_request_data_util.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/autofill/core/browser/autofill_country.h" |
| 11 #include "components/autofill/core/browser/autofill_data_util.h" |
10 #include "components/autofill/core/browser/autofill_profile.h" | 12 #include "components/autofill/core/browser/autofill_profile.h" |
11 #include "components/autofill/core/browser/credit_card.h" | 13 #include "components/autofill/core/browser/credit_card.h" |
12 #include "components/autofill/core/browser/field_types.h" | 14 #include "components/autofill/core/browser/field_types.h" |
13 #include "components/autofill/core/browser/personal_data_manager.h" | 15 #include "components/autofill/core/browser/personal_data_manager.h" |
14 #include "components/payments/core/basic_card_response.h" | 16 #include "components/payments/core/basic_card_response.h" |
15 #include "components/payments/core/payment_address.h" | 17 #include "components/payments/core/payment_address.h" |
16 #include "components/payments/core/payment_method_data.h" | 18 #include "components/payments/core/payment_method_data.h" |
17 #include "third_party/libphonenumber/phonenumber_api.h" | 19 #include "third_party/libphonenumber/phonenumber_api.h" |
18 | 20 |
19 namespace payments { | 21 namespace payments { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return FormatPhoneNumber(phone_number, country_code, | 157 return FormatPhoneNumber(phone_number, country_code, |
156 PhoneNumberUtil::PhoneNumberFormat::INTERNATIONAL); | 158 PhoneNumberUtil::PhoneNumberFormat::INTERNATIONAL); |
157 } | 159 } |
158 | 160 |
159 std::string FormatPhoneForResponse(const std::string& phone_number, | 161 std::string FormatPhoneForResponse(const std::string& phone_number, |
160 const std::string& country_code) { | 162 const std::string& country_code) { |
161 return FormatPhoneNumber(phone_number, country_code, | 163 return FormatPhoneNumber(phone_number, country_code, |
162 PhoneNumberUtil::PhoneNumberFormat::E164); | 164 PhoneNumberUtil::PhoneNumberFormat::E164); |
163 } | 165 } |
164 | 166 |
| 167 std::string GetCountryCodeWithFallback(const autofill::AutofillProfile* profile, |
| 168 const std::string& app_locale) { |
| 169 std::string country_code = |
| 170 base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)); |
| 171 if (!autofill::data_util::IsValidCountryCode(country_code)) |
| 172 country_code = autofill::AutofillCountry::CountryCodeForLocale(app_locale); |
| 173 return country_code; |
| 174 } |
| 175 |
165 } // namespace data_util | 176 } // namespace data_util |
166 } // namespace payments | 177 } // namespace payments |
OLD | NEW |