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 #ifndef COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_I18N_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_I18N_H_ |
6 #define COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_I18N_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_I18N_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 const string16& value, | 32 const string16& value, |
33 const std::string& region, | 33 const std::string& region, |
34 string16* country_code, | 34 string16* country_code, |
35 string16* city_code, | 35 string16* city_code, |
36 string16* number, | 36 string16* number, |
37 i18n::phonenumbers::PhoneNumber* i18n_number) WARN_UNUSED_RESULT; | 37 i18n::phonenumbers::PhoneNumber* i18n_number) WARN_UNUSED_RESULT; |
38 | 38 |
39 // Normalizes phone number, by changing digits in the extended fonts | 39 // Normalizes phone number, by changing digits in the extended fonts |
40 // (such as \xFF1x) into '0'-'9'. Also strips out non-digit characters. | 40 // (such as \xFF1x) into '0'-'9'. Also strips out non-digit characters. |
41 string16 NormalizePhoneNumber(const string16& value, | 41 string16 NormalizePhoneNumber(const string16& value, |
42 const std::string& region); | 42 const std::string& region, |
| 43 const std::string& app_locale); |
43 | 44 |
44 // Constructs whole phone number from parts. | 45 // Constructs whole phone number from parts. |
45 // |city_code| - area code, could be empty. | 46 // |city_code| - area code, could be empty. |
46 // |country_code| - country code, could be empty. | 47 // |country_code| - country code, could be empty. |
47 // |number| - local number, should not be empty. | 48 // |number| - local number, should not be empty. |
48 // |region| - current region, the parsing is based on. | 49 // |region| - current region, the parsing is based on. |
| 50 // |app_locale| - current app locale. |
49 // |whole_number| - constructed whole number. | 51 // |whole_number| - constructed whole number. |
50 // Separator characters are stripped before parsing the digits. | 52 // Separator characters are stripped before parsing the digits. |
51 // Returns true if parsing was successful, false otherwise. | 53 // Returns true if parsing was successful, false otherwise. |
52 bool ConstructPhoneNumber(const string16& country_code, | 54 bool ConstructPhoneNumber(const string16& country_code, |
53 const string16& city_code, | 55 const string16& city_code, |
54 const string16& number, | 56 const string16& number, |
55 const std::string& region, | 57 const std::string& region, |
| 58 const std::string& app_locale, |
56 string16* whole_number) WARN_UNUSED_RESULT; | 59 string16* whole_number) WARN_UNUSED_RESULT; |
57 | 60 |
58 // Returns true if |number_a| and |number_b| parse to the same phone number in | 61 // Returns true if |number_a| and |number_b| parse to the same phone number in |
59 // the given |region|. | 62 // the given |region|. |
60 bool PhoneNumbersMatch(const string16& number_a, | 63 bool PhoneNumbersMatch(const string16& number_a, |
61 const string16& number_b, | 64 const string16& number_b, |
62 const std::string& region); | 65 const std::string& region, |
| 66 const std::string& app_locale); |
63 | 67 |
64 // The cached phone number, does parsing only once, improves performance. | 68 // The cached phone number, does parsing only once, improves performance. |
65 class PhoneObject { | 69 class PhoneObject { |
66 public: | 70 public: |
67 PhoneObject(const string16& number, const std::string& region); | 71 PhoneObject(const string16& number, |
| 72 const std::string& region, |
| 73 const std::string& app_locale); |
68 PhoneObject(const PhoneObject&); | 74 PhoneObject(const PhoneObject&); |
69 PhoneObject(); | 75 PhoneObject(); |
70 ~PhoneObject(); | 76 ~PhoneObject(); |
71 | 77 |
72 std::string region() const { return region_; } | 78 std::string region() const { return region_; } |
73 | 79 |
74 string16 country_code() const { return country_code_; } | 80 string16 country_code() const { return country_code_; } |
75 string16 city_code() const { return city_code_; } | 81 string16 city_code() const { return city_code_; } |
76 string16 number() const { return number_; } | 82 string16 number() const { return number_; } |
77 | 83 |
(...skipping 19 matching lines...) Expand all Loading... |
97 mutable string16 formatted_number_; | 103 mutable string16 formatted_number_; |
98 | 104 |
99 // The whole number, normalized to contain only digits if possible. | 105 // The whole number, normalized to contain only digits if possible. |
100 // Set on first request. | 106 // Set on first request. |
101 mutable string16 whole_number_; | 107 mutable string16 whole_number_; |
102 }; | 108 }; |
103 | 109 |
104 } // namespace autofill_i18n | 110 } // namespace autofill_i18n |
105 | 111 |
106 #endif // COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_I18N_H_ | 112 #endif // COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_I18N_H_ |
OLD | NEW |