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 CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_I18N_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_I18N_H_ |
6 #define CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_I18N_H_ | 6 #define CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_I18N_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | |
13 #include "base/string16.h" | 14 #include "base/string16.h" |
14 | 15 |
16 namespace i18n { | |
17 namespace phonenumbers { | |
dhollowa
2011/06/10 15:13:27
nit: namespaces don't indent when nested.
GeorgeY
2011/06/10 22:36:35
Done.
| |
18 class PhoneNumber; | |
19 } | |
20 } | |
21 | |
15 // Utilities to process, normalize and compare international phone numbers. | 22 // Utilities to process, normalize and compare international phone numbers. |
16 | |
17 namespace autofill_i18n { | 23 namespace autofill_i18n { |
18 | 24 |
19 // Most of the following functions require |locale| to operate. The |locale| is | 25 // Most of the following functions require |locale| to operate. The |locale| is |
20 // a ISO 3166 standard code ("US" for USA, "CZ" for Czech Republic, etc.). | 26 // a ISO 3166 standard code ("US" for USA, "CZ" for Czech Republic, etc.). |
21 | 27 |
22 // Normalizes phone number, by changing digits in the extended fonts | 28 // Normalizes phone number, by changing digits in the extended fonts |
23 // (such as \xFF1x) into '0'-'9'. Also strips out non-digit characters. | 29 // (such as \xFF1x) into '0'-'9'. Also strips out non-digit characters. |
24 string16 NormalizePhoneNumber(const string16& value, | 30 string16 NormalizePhoneNumber(const string16& value, |
25 const std::string& locale); | 31 const std::string& locale); |
26 | 32 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 | 87 |
82 // Compares two phones, normalizing them before comparision. | 88 // Compares two phones, normalizing them before comparision. |
83 PhoneMatch ComparePhones(const string16& phone1, | 89 PhoneMatch ComparePhones(const string16& phone1, |
84 const string16& phone2, | 90 const string16& phone2, |
85 const std::string& locale); | 91 const std::string& locale); |
86 | 92 |
87 bool PhoneNumbersMatch(const string16& number_a, | 93 bool PhoneNumbersMatch(const string16& number_a, |
88 const string16& number_b, | 94 const string16& number_b, |
89 const std::string& country_code); | 95 const std::string& country_code); |
90 | 96 |
97 // The cached phone number, does parsing only once, improves performance. | |
98 class PhoneObject { | |
99 public: | |
100 PhoneObject(const string16& number, const std::string& locale); | |
101 PhoneObject(const PhoneObject&); | |
102 PhoneObject(); | |
103 ~PhoneObject(); | |
104 | |
105 string16 GetCountryCode() const; | |
106 string16 GetCityCode() const; | |
107 string16 GetNumber() const; | |
108 std::string GetLocale() const { return locale_; } | |
109 | |
110 string16 GetWholeNumber() const; | |
111 | |
112 PhoneMatch ComparePhones(const string16& phone) const; | |
113 PhoneMatch ComparePhones(const PhoneObject& phone) const; | |
114 | |
115 PhoneObject& operator=(const PhoneObject& other); | |
116 | |
117 bool ValidNumber() const { return i18n_number_ != NULL; } | |
118 private: | |
Ilya Sherman
2011/06/10 07:17:33
nit: Please leave a blank line above "private:"
GeorgeY
2011/06/10 22:36:35
Done.
| |
119 void Clear(); | |
120 | |
121 string16 city_code_; | |
122 string16 country_code_; | |
123 string16 number_; | |
124 mutable string16 whole_number_; // Set on first request. | |
125 std::string locale_; | |
126 i18n::phonenumbers::PhoneNumber* i18n_number_; | |
127 }; | |
128 | |
91 } // namespace autofill_i18n | 129 } // namespace autofill_i18n |
92 | 130 |
93 #endif // CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_I18N_H_ | 131 #endif // CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_I18N_H_ |
OLD | NEW |