| 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_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_H_ | 6 #define CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_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/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "chrome/browser/autofill/autofill_type.h" | 14 #include "chrome/browser/autofill/autofill_type.h" |
| 15 #include "chrome/browser/autofill/form_group.h" | 15 #include "chrome/browser/autofill/form_group.h" |
| 16 #include "chrome/browser/autofill/phone_number_i18n.h" |
| 16 | 17 |
| 17 // A form group that stores phone number information. | 18 // A form group that stores phone number information. |
| 18 class PhoneNumber : public FormGroup { | 19 class PhoneNumber : public FormGroup { |
| 19 public: | 20 public: |
| 20 PhoneNumber(); | 21 PhoneNumber(); |
| 21 explicit PhoneNumber(AutofillType::FieldTypeGroup phone_group); | 22 explicit PhoneNumber(AutofillType::FieldTypeGroup phone_group); |
| 22 PhoneNumber(const PhoneNumber& number); | 23 PhoneNumber(const PhoneNumber& number); |
| 23 virtual ~PhoneNumber(); | 24 virtual ~PhoneNumber(); |
| 24 | 25 |
| 25 PhoneNumber& operator=(const PhoneNumber& number); | 26 PhoneNumber& operator=(const PhoneNumber& number); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 private: | 78 private: |
| 78 FRIEND_TEST_ALL_PREFIXES(PhoneNumberTest, Matcher); | 79 FRIEND_TEST_ALL_PREFIXES(PhoneNumberTest, Matcher); |
| 79 | 80 |
| 80 // The numbers will be digits only (no punctuation), so any call to the IsX() | 81 // The numbers will be digits only (no punctuation), so any call to the IsX() |
| 81 // functions should first call StripPunctuation on the text. | 82 // functions should first call StripPunctuation on the text. |
| 82 bool IsNumber(const string16& text, const string16& number) const; | 83 bool IsNumber(const string16& text, const string16& number) const; |
| 83 bool IsWholeNumber(const string16& text) const; | 84 bool IsWholeNumber(const string16& text) const; |
| 84 | 85 |
| 85 static void StripPunctuation(string16* number); | 86 static void StripPunctuation(string16* number); |
| 86 | 87 |
| 87 void ClearCachedNumbers() const; | |
| 88 // Updates cached parsed parts of the number. Returns false only if there was | |
| 89 // parsing involved and it failed. | |
| 90 bool UpdateCacheIfNeeded() const; | |
| 91 | |
| 92 // Phone group - currently it is PHONE_HOME and PHONE_FAX. | 88 // Phone group - currently it is PHONE_HOME and PHONE_FAX. |
| 93 AutofillType::FieldTypeGroup phone_group_; | 89 AutofillType::FieldTypeGroup phone_group_; |
| 94 // Locale for phone normalizing. | 90 // Locale for phone normalizing. |
| 95 std::string locale_; | 91 std::string locale_; |
| 96 // The phone number. | 92 // The phone number. |
| 97 string16 number_; | 93 string16 number_; |
| 98 | 94 |
| 99 // Cached parsed parts of the number. | 95 // Cached number. |
| 100 mutable string16 cached_country_code_; | 96 autofill_i18n::PhoneObject cached_parsed_phone_; |
| 101 mutable string16 cached_city_code_; | |
| 102 mutable string16 cached_local_number_; | |
| 103 }; | 97 }; |
| 104 | 98 |
| 105 #endif // CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_H_ | 99 #endif // CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_H_ |
| OLD | NEW |