| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CORE_BROWSER_PHONE_NUMBER_I18N_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PHONE_NUMBER_I18N_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PHONE_NUMBER_I18N_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PHONE_NUMBER_I18N_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 const std::string& region, | 57 const std::string& region, |
| 58 base::string16* whole_number) WARN_UNUSED_RESULT; | 58 base::string16* whole_number) WARN_UNUSED_RESULT; |
| 59 | 59 |
| 60 // Returns true if |number_a| and |number_b| parse to the same phone number in | 60 // Returns true if |number_a| and |number_b| parse to the same phone number in |
| 61 // the given |region|. | 61 // the given |region|. |
| 62 bool PhoneNumbersMatch(const base::string16& number_a, | 62 bool PhoneNumbersMatch(const base::string16& number_a, |
| 63 const base::string16& number_b, | 63 const base::string16& number_b, |
| 64 const std::string& region, | 64 const std::string& region, |
| 65 const std::string& app_locale); | 65 const std::string& app_locale); |
| 66 | 66 |
| 67 // Takes a phone number provided by a user and returns a string formatted for |
| 68 // display in the national format of the region defined by |region|. If |
| 69 // the phone number could not be parsed this may return an empty string. |
| 70 base::string16 FormatPhoneNumberForRegion(const base::string16& whole_number, |
| 71 const std::string& region); |
| 72 |
| 67 // The cached phone number, does parsing only once, improves performance. | 73 // The cached phone number, does parsing only once, improves performance. |
| 68 class PhoneObject { | 74 class PhoneObject { |
| 69 public: | 75 public: |
| 70 PhoneObject(const base::string16& number, | 76 PhoneObject(const base::string16& number, |
| 71 const std::string& region); | 77 const std::string& region); |
| 72 PhoneObject(const PhoneObject&); | 78 PhoneObject(const PhoneObject&); |
| 73 PhoneObject(); | 79 PhoneObject(); |
| 74 ~PhoneObject(); | 80 ~PhoneObject(); |
| 75 | 81 |
| 76 std::string region() const { return region_; } | 82 std::string region() const { return region_; } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 103 | 109 |
| 104 // The whole number, normalized to contain only digits if possible. | 110 // The whole number, normalized to contain only digits if possible. |
| 105 // Set on first request. | 111 // Set on first request. |
| 106 mutable base::string16 whole_number_; | 112 mutable base::string16 whole_number_; |
| 107 }; | 113 }; |
| 108 | 114 |
| 109 } // namespace i18n | 115 } // namespace i18n |
| 110 } // namespace autofill | 116 } // namespace autofill |
| 111 | 117 |
| 112 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PHONE_NUMBER_I18N_H_ | 118 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PHONE_NUMBER_I18N_H_ |
| OLD | NEW |