OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autofill/browser/phone_number.h" | 5 #include "components/autofill/browser/phone_number.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 void StripPunctuation(string16* number) { | 27 void StripPunctuation(string16* number) { |
28 RemoveChars(*number, kPhoneNumberSeparators, number); | 28 RemoveChars(*number, kPhoneNumberSeparators, number); |
29 } | 29 } |
30 | 30 |
31 // Returns the region code for this phone number, which is an ISO 3166 2-letter | 31 // Returns the region code for this phone number, which is an ISO 3166 2-letter |
32 // country code. The returned value is based on the |profile|; if the |profile| | 32 // country code. The returned value is based on the |profile|; if the |profile| |
33 // does not have a country code associated with it, falls back to the country | 33 // does not have a country code associated with it, falls back to the country |
34 // code corresponding to the |app_locale|. | 34 // code corresponding to the |app_locale|. |
35 std::string GetRegion(const AutofillProfile& profile, | 35 std::string GetRegion(const AutofillProfile& profile, |
36 const std::string& app_locale) { | 36 const std::string& app_locale) { |
37 std::string country_code = profile.CountryCode(); | 37 string16 country_code = profile.GetRawInfo(ADDRESS_HOME_COUNTRY); |
38 if (!country_code.empty()) | 38 if (!country_code.empty()) |
39 return country_code; | 39 return UTF16ToASCII(country_code); |
40 | 40 |
41 return AutofillCountry::CountryCodeForLocale(app_locale); | 41 return AutofillCountry::CountryCodeForLocale(app_locale); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 PhoneNumber::PhoneNumber(AutofillProfile* profile) | 46 PhoneNumber::PhoneNumber(AutofillProfile* profile) |
47 : profile_(profile) { | 47 : profile_(profile) { |
48 } | 48 } |
49 | 49 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return true; | 229 return true; |
230 } | 230 } |
231 | 231 |
232 return autofill_i18n::ConstructPhoneNumber( | 232 return autofill_i18n::ConstructPhoneNumber( |
233 country_, city_, phone_, GetRegion(profile, app_locale), value); | 233 country_, city_, phone_, GetRegion(profile, app_locale), value); |
234 } | 234 } |
235 | 235 |
236 bool PhoneNumber::PhoneCombineHelper::IsEmpty() const { | 236 bool PhoneNumber::PhoneCombineHelper::IsEmpty() const { |
237 return phone_.empty() && whole_number_.empty(); | 237 return phone_.empty() && whole_number_.empty(); |
238 } | 238 } |
OLD | NEW |