| 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_CONTACT_INFO_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_CONTACT_INFO_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_CONTACT_INFO_H_ | 6 #define CHROME_BROWSER_AUTOFILL_CONTACT_INFO_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 name information. | 15 // A form group that stores name information. |
| 16 class NameInfo : public FormGroup { | 16 class NameInfo : public FormGroup { |
| 17 public: | 17 public: |
| 18 NameInfo(); | 18 NameInfo(); |
| 19 explicit NameInfo(const NameInfo& info); | 19 explicit NameInfo(const NameInfo& info); |
| 20 virtual ~NameInfo(); | 20 virtual ~NameInfo(); |
| 21 | 21 |
| 22 NameInfo& operator=(const NameInfo& info); | 22 NameInfo& operator=(const NameInfo& info); |
| 23 | 23 |
| 24 // FormGroup: | 24 // FormGroup: |
| 25 virtual void GetPossibleFieldTypes(const string16& text, | 25 virtual void GetPossibleFieldTypes(const string16& text, |
| 26 FieldTypeSet* possible_types) const; | 26 FieldTypeSet* possible_types) const; |
| 27 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; | 27 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; |
| 28 virtual void FindInfoMatches(const AutofillType& type, | 28 virtual void FindInfoMatches(AutofillFieldType type, |
| 29 const string16& info, | 29 const string16& info, |
| 30 std::vector<string16>* matched_text) const; | 30 std::vector<string16>* matched_text) const; |
| 31 virtual string16 GetFieldText(const AutofillType& type) const; | 31 virtual string16 GetFieldText(AutofillFieldType type) const; |
| 32 virtual void SetInfo(const AutofillType& type, const string16& value); | 32 virtual void SetInfo(AutofillFieldType type, const string16& value); |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 FRIEND_TEST_ALL_PREFIXES(NameInfoTest, TestSetFullName); | 35 FRIEND_TEST_ALL_PREFIXES(NameInfoTest, TestSetFullName); |
| 36 | 36 |
| 37 // Returns the full name, which can include up to the first, middle, and last | 37 // Returns the full name, which can include up to the first, middle, and last |
| 38 // name. | 38 // name. |
| 39 string16 FullName() const; | 39 string16 FullName() const; |
| 40 | 40 |
| 41 // Returns the middle initial if |middle_| is non-empty. Returns an empty | 41 // Returns the middle initial if |middle_| is non-empty. Returns an empty |
| 42 // string otherwise. | 42 // string otherwise. |
| 43 string16 MiddleInitial() const; | 43 string16 MiddleInitial() const; |
| 44 | 44 |
| 45 const string16& first() const { return first_; } | 45 const string16& first() const { return first_; } |
| 46 const string16& middle() const { return middle_; } | 46 const string16& middle() const { return middle_; } |
| 47 const string16& last() const { return last_; } | 47 const string16& last() const { return last_; } |
| 48 | 48 |
| 49 // A helper function for FindInfoMatches that only handles matching the info | 49 // A helper function for FindInfoMatches that only handles matching the info |
| 50 // with the requested field type. | 50 // with the requested field type. |
| 51 bool FindInfoMatchesHelper(const AutofillFieldType& field_type, | 51 bool FindInfoMatchesHelper(AutofillFieldType field_type, |
| 52 const string16& info, | 52 const string16& info, |
| 53 string16* matched_text) const; | 53 string16* matched_text) const; |
| 54 | 54 |
| 55 // Returns true if |text| is the first name. | 55 // Returns true if |text| is the first name. |
| 56 bool IsFirstName(const string16& text) const; | 56 bool IsFirstName(const string16& text) const; |
| 57 | 57 |
| 58 // Returns true if |text| is the middle name. | 58 // Returns true if |text| is the middle name. |
| 59 bool IsMiddleName(const string16& text) const; | 59 bool IsMiddleName(const string16& text) const; |
| 60 | 60 |
| 61 // Returns true if |text| is the last name. | 61 // Returns true if |text| is the last name. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 EmailInfo(); | 107 EmailInfo(); |
| 108 explicit EmailInfo(const EmailInfo& info); | 108 explicit EmailInfo(const EmailInfo& info); |
| 109 virtual ~EmailInfo(); | 109 virtual ~EmailInfo(); |
| 110 | 110 |
| 111 EmailInfo& operator=(const EmailInfo& info); | 111 EmailInfo& operator=(const EmailInfo& info); |
| 112 | 112 |
| 113 // FormGroup: | 113 // FormGroup: |
| 114 virtual void GetPossibleFieldTypes(const string16& text, | 114 virtual void GetPossibleFieldTypes(const string16& text, |
| 115 FieldTypeSet* possible_types) const; | 115 FieldTypeSet* possible_types) const; |
| 116 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; | 116 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; |
| 117 virtual void FindInfoMatches(const AutofillType& type, | 117 virtual void FindInfoMatches(AutofillFieldType type, |
| 118 const string16& info, | 118 const string16& info, |
| 119 std::vector<string16>* matched_text) const; | 119 std::vector<string16>* matched_text) const; |
| 120 virtual string16 GetFieldText(const AutofillType& type) const; | 120 virtual string16 GetFieldText(AutofillFieldType type) const; |
| 121 virtual void SetInfo(const AutofillType& type, const string16& value); | 121 virtual void SetInfo(AutofillFieldType type, const string16& value); |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 string16 email_; | 124 string16 email_; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 class CompanyInfo : public FormGroup { | 127 class CompanyInfo : public FormGroup { |
| 128 public: | 128 public: |
| 129 CompanyInfo(); | 129 CompanyInfo(); |
| 130 explicit CompanyInfo(const CompanyInfo& info); | 130 explicit CompanyInfo(const CompanyInfo& info); |
| 131 virtual ~CompanyInfo(); | 131 virtual ~CompanyInfo(); |
| 132 | 132 |
| 133 CompanyInfo& operator=(const CompanyInfo& info); | 133 CompanyInfo& operator=(const CompanyInfo& info); |
| 134 | 134 |
| 135 // FormGroup: | 135 // FormGroup: |
| 136 virtual void GetPossibleFieldTypes(const string16& text, | 136 virtual void GetPossibleFieldTypes(const string16& text, |
| 137 FieldTypeSet* possible_types) const; | 137 FieldTypeSet* possible_types) const; |
| 138 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; | 138 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; |
| 139 virtual void FindInfoMatches(const AutofillType& type, | 139 virtual void FindInfoMatches(AutofillFieldType type, |
| 140 const string16& info, | 140 const string16& info, |
| 141 std::vector<string16>* matched_text) const; | 141 std::vector<string16>* matched_text) const; |
| 142 virtual string16 GetFieldText(const AutofillType& type) const; | 142 virtual string16 GetFieldText(AutofillFieldType type) const; |
| 143 virtual void SetInfo(const AutofillType& type, const string16& value); | 143 virtual void SetInfo(AutofillFieldType type, const string16& value); |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 string16 company_name_; | 146 string16 company_name_; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 #endif // CHROME_BROWSER_AUTOFILL_CONTACT_INFO_H_ | 149 #endif // CHROME_BROWSER_AUTOFILL_CONTACT_INFO_H_ |
| OLD | NEW |