| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "chrome/browser/autofill/form_group.h" | 13 #include "chrome/browser/autofill/form_group.h" |
| 14 | 14 |
| 15 // A form group that stores phone number information. | 15 // A form group that stores phone number information. |
| 16 class PhoneNumber : public FormGroup { | 16 class PhoneNumber : public FormGroup { |
| 17 public: | 17 public: |
| 18 PhoneNumber(); | 18 PhoneNumber(); |
| 19 explicit PhoneNumber(const PhoneNumber& number); |
| 19 virtual ~PhoneNumber(); | 20 virtual ~PhoneNumber(); |
| 20 | 21 |
| 22 PhoneNumber& operator=(const PhoneNumber& number); |
| 23 |
| 21 // FormGroup implementation: | 24 // FormGroup implementation: |
| 22 virtual FormGroup* Clone() const = 0; | |
| 23 virtual void GetPossibleFieldTypes(const string16& text, | 25 virtual void GetPossibleFieldTypes(const string16& text, |
| 24 FieldTypeSet* possible_types) const; | 26 FieldTypeSet* possible_types) const; |
| 25 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; | 27 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; |
| 26 virtual void FindInfoMatches(const AutofillType& type, | 28 virtual void FindInfoMatches(const AutofillType& type, |
| 27 const string16& info, | 29 const string16& info, |
| 28 std::vector<string16>* matched_text) const; | 30 std::vector<string16>* matched_text) const; |
| 29 virtual string16 GetFieldText(const AutofillType& type) const; | 31 virtual string16 GetFieldText(const AutofillType& type) const; |
| 30 virtual void SetInfo(const AutofillType& type, const string16& value); | 32 virtual void SetInfo(const AutofillType& type, const string16& value); |
| 31 | 33 |
| 32 // Parses |value| to extract the components of a phone number. |number| | 34 // Parses |value| to extract the components of a phone number. |number| |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 static const int kSuffixLength = 4; | 48 static const int kSuffixLength = 4; |
| 47 | 49 |
| 48 // The following functions should return the field type for each part of the | 50 // The following functions should return the field type for each part of the |
| 49 // phone number. Currently, these are either fax or home phone number types. | 51 // phone number. Currently, these are either fax or home phone number types. |
| 50 virtual AutofillFieldType GetNumberType() const = 0; | 52 virtual AutofillFieldType GetNumberType() const = 0; |
| 51 virtual AutofillFieldType GetCityCodeType() const = 0; | 53 virtual AutofillFieldType GetCityCodeType() const = 0; |
| 52 virtual AutofillFieldType GetCountryCodeType() const = 0; | 54 virtual AutofillFieldType GetCountryCodeType() const = 0; |
| 53 virtual AutofillFieldType GetCityAndNumberType() const = 0; | 55 virtual AutofillFieldType GetCityAndNumberType() const = 0; |
| 54 virtual AutofillFieldType GetWholeNumberType() const = 0; | 56 virtual AutofillFieldType GetWholeNumberType() const = 0; |
| 55 | 57 |
| 56 protected: | |
| 57 explicit PhoneNumber(const PhoneNumber& phone_number); | |
| 58 | |
| 59 private: | 58 private: |
| 60 FRIEND_TEST_ALL_PREFIXES(PhoneNumberTest, Matcher); | 59 FRIEND_TEST_ALL_PREFIXES(PhoneNumberTest, Matcher); |
| 61 | 60 |
| 62 void operator=(const PhoneNumber& phone_number); | |
| 63 | |
| 64 const string16& country_code() const { return country_code_; } | 61 const string16& country_code() const { return country_code_; } |
| 65 const string16& city_code() const { return city_code_; } | 62 const string16& city_code() const { return city_code_; } |
| 66 const string16& number() const { return number_; } | 63 const string16& number() const { return number_; } |
| 67 const string16& extension() const { return extension_; } | 64 const string16& extension() const { return extension_; } |
| 68 string16 CityAndNumber() const { return city_code_ + number_; } | 65 string16 CityAndNumber() const { return city_code_ + number_; } |
| 69 | 66 |
| 70 // Returns the entire phone number as a string, without punctuation. | 67 // Returns the entire phone number as a string, without punctuation. |
| 71 virtual string16 WholeNumber() const; | 68 virtual string16 WholeNumber() const; |
| 72 | 69 |
| 73 void set_country_code(const string16& country_code) { | 70 void set_country_code(const string16& country_code) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 99 static void StripPunctuation(string16* number); | 96 static void StripPunctuation(string16* number); |
| 100 | 97 |
| 101 // The pieces of the phone number. | 98 // The pieces of the phone number. |
| 102 string16 country_code_; | 99 string16 country_code_; |
| 103 string16 city_code_; // city or area code. | 100 string16 city_code_; // city or area code. |
| 104 string16 number_; | 101 string16 number_; |
| 105 string16 extension_; | 102 string16 extension_; |
| 106 }; | 103 }; |
| 107 | 104 |
| 108 #endif // CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_H_ | 105 #endif // CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_H_ |
| OLD | NEW |