Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: chrome/browser/autofill/contact_info.h

Issue 6650014: Autofill extend profiles to include multi-valued fields, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string16.h" 12 #include "base/string16.h"
12 #include "chrome/browser/autofill/form_group.h" 13 #include "chrome/browser/autofill/form_group.h"
13 14
14 typedef std::vector<string16> NameTokens; 15 // A form group that stores name information.
16 class NameInfo : public FormGroup {
17 public:
18 NameInfo();
19 explicit NameInfo(const NameInfo& info);
20 virtual ~NameInfo();
15 21
16 // A form group that stores contact information. 22 NameInfo& operator=(const NameInfo& info);
17 class ContactInfo : public FormGroup {
18 public:
19 ContactInfo();
20 virtual ~ContactInfo();
21 23
22 // FormGroup implementation: 24 // FormGroup:
23 virtual FormGroup* Clone() const;
24 virtual void GetPossibleFieldTypes(const string16& text, 25 virtual void GetPossibleFieldTypes(const string16& text,
25 FieldTypeSet* possible_types) const; 26 FieldTypeSet* possible_types) const;
26 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; 27 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const;
27 virtual void FindInfoMatches(const AutofillType& type, 28 virtual void FindInfoMatches(const AutofillType& type,
28 const string16& info, 29 const string16& info,
29 std::vector<string16>* matched_text) const; 30 std::vector<string16>* matched_text) const;
30 virtual string16 GetFieldText(const AutofillType& type) const; 31 virtual string16 GetFieldText(const AutofillType& type) const;
31 virtual void SetInfo(const AutofillType& type, const string16& value); 32 virtual void SetInfo(const AutofillType& type, const string16& value);
32 33
33 private: 34 private:
34 friend class ContactInfoTest; 35 FRIEND_TEST_ALL_PREFIXES(NameInfoTest, TestSetFullName);
35 explicit ContactInfo(const ContactInfo& contact_info);
36 void operator=(const ContactInfo& info);
37 36
38 // Returns the full name, which can include up to the first, middle, middle 37 // Returns the full name, which can include up to the first, middle, and last
39 // initial, last name, and suffix. 38 // name.
40 string16 FullName() const; 39 string16 FullName() const;
41 40
42 // 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
43 // string otherwise. 42 // string otherwise.
44 string16 MiddleInitial() const; 43 string16 MiddleInitial() const;
45 44
46 const string16& first() const { return first_; } 45 const string16& first() const { return first_; }
47 const string16& middle() const { return middle_; } 46 const string16& middle() const { return middle_; }
48 const string16& last() const { return last_; } 47 const string16& last() const { return last_; }
49 const string16& suffix() const { return suffix_; }
50 const string16& email() const { return email_; }
51 const string16& company_name() const { return company_name_; }
52 48
53 // A helper function for FindInfoMatches that only handles matching the info 49 // A helper function for FindInfoMatches that only handles matching the info
54 // with the requested field type. 50 // with the requested field type.
55 bool FindInfoMatchesHelper(const AutofillFieldType& field_type, 51 bool FindInfoMatchesHelper(const AutofillFieldType& field_type,
56 const string16& info, 52 const string16& info,
57 string16* matched_text) const; 53 string16* matched_text) const;
58 54
59 // Returns true if |text| is the first name. 55 // Returns true if |text| is the first name.
60 bool IsFirstName(const string16& text) const; 56 bool IsFirstName(const string16& text) const;
61 57
62 // Returns true if |text| is the middle name. 58 // Returns true if |text| is the middle name.
63 bool IsMiddleName(const string16& text) const; 59 bool IsMiddleName(const string16& text) const;
64 60
65 // Returns true if |text| is the last name. 61 // Returns true if |text| is the last name.
66 bool IsLastName(const string16& text) const; 62 bool IsLastName(const string16& text) const;
67 63
68 // Returns true if |text| is the suffix.
69 bool IsSuffix(const string16& text) const;
70
71 // Returns true if |text| is the middle initial. 64 // Returns true if |text| is the middle initial.
72 bool IsMiddleInitial(const string16& text) const; 65 bool IsMiddleInitial(const string16& text) const;
73 66
74 // Returns true if |text| is the last name. 67 // Returns true if |text| is the last name.
75 bool IsFullName(const string16& text) const; 68 bool IsFullName(const string16& text) const;
76 69
77 // Returns true if all of the tokens in |text| match the tokens in 70 // Returns true if all of the tokens in |text| match the tokens in
78 // |name_tokens|. 71 // |name_tokens|.
79 bool IsNameMatch(const string16& text, const NameTokens& name_tokens) const; 72 bool IsNameMatch(const string16& text,
73 const std::vector<string16>& name_tokens) const;
80 74
81 // Returns true if |word| is one of the tokens in |name_tokens|. 75 // Returns true if |word| is one of the tokens in |name_tokens|.
82 bool IsWordInName(const string16& word, const NameTokens& name_tokens) const; 76 bool IsWordInName(const string16& word,
77 const std::vector<string16>& name_tokens) const;
83 78
84 // Sets |first_| to |first| and |first_tokens_| to the set of tokens in 79 // Sets |first_| to |first| and |first_tokens_| to the set of tokens in
85 // |first|, made lowercase. 80 // |first|, made lowercase.
86 void SetFirst(const string16& first); 81 void SetFirst(const string16& first);
87 82
88 // Sets |middle_| to |middle| and |middle_tokens_| to the set of tokens in 83 // Sets |middle_| to |middle| and |middle_tokens_| to the set of tokens in
89 // |middle|, made lowercase. 84 // |middle|, made lowercase.
90 void SetMiddle(const string16& middle); 85 void SetMiddle(const string16& middle);
91 86
92 // Sets |last_| to |last| and |last_tokens_| to the set of tokens in |last|, 87 // Sets |last_| to |last| and |last_tokens_| to the set of tokens in |last|,
93 // made lowercase. 88 // made lowercase.
94 void SetLast(const string16& last); 89 void SetLast(const string16& last);
95 90
96 // Sets |first_|, |middle_|, |last_| and |*_tokens_| to the tokenized 91 // Sets |first_|, |middle_|, |last_| and |*_tokens_| to the tokenized
97 // |full|. It is tokenized on a space only. 92 // |full|. It is tokenized on a space only.
98 void SetFullName(const string16& full); 93 void SetFullName(const string16& full);
99 94
100 void set_suffix(const string16& suffix) { suffix_ = suffix; } 95 // List of tokens in each part of the name.
96 std::vector<string16> first_tokens_;
97 std::vector<string16> middle_tokens_;
98 std::vector<string16> last_tokens_;
101 99
102 // List of tokens in each part of the name.
103 NameTokens first_tokens_;
104 NameTokens middle_tokens_;
105 NameTokens last_tokens_;
106
107 // Contact information data.
108 string16 first_; 100 string16 first_;
109 string16 middle_; 101 string16 middle_;
110 string16 last_; 102 string16 last_;
111 string16 suffix_; 103 };
104
105 class EmailInfo : public FormGroup {
106 public:
107 EmailInfo();
108 explicit EmailInfo(const EmailInfo& info);
109 virtual ~EmailInfo();
110
111 EmailInfo& operator=(const EmailInfo& info);
112
113 // FormGroup:
114 virtual void GetPossibleFieldTypes(const string16& text,
115 FieldTypeSet* possible_types) const;
116 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const;
117 virtual void FindInfoMatches(const AutofillType& type,
118 const string16& info,
119 std::vector<string16>* matched_text) const;
120 virtual string16 GetFieldText(const AutofillType& type) const;
121 virtual void SetInfo(const AutofillType& type, const string16& value);
122
123 private:
112 string16 email_; 124 string16 email_;
125 };
126
127 class CompanyInfo : public FormGroup {
128 public:
129 CompanyInfo();
130 explicit CompanyInfo(const CompanyInfo& info);
131 virtual ~CompanyInfo();
132
133 CompanyInfo& operator=(const CompanyInfo& info);
134
135 // FormGroup:
136 virtual void GetPossibleFieldTypes(const string16& text,
137 FieldTypeSet* possible_types) const;
138 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const;
139 virtual void FindInfoMatches(const AutofillType& type,
140 const string16& info,
141 std::vector<string16>* matched_text) const;
142 virtual string16 GetFieldText(const AutofillType& type) const;
143 virtual void SetInfo(const AutofillType& type, const string16& value);
144
145 private:
113 string16 company_name_; 146 string16 company_name_;
114 }; 147 };
115 148
116 #endif // CHROME_BROWSER_AUTOFILL_CONTACT_INFO_H_ 149 #endif // CHROME_BROWSER_AUTOFILL_CONTACT_INFO_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_type_unittest.cc ('k') | chrome/browser/autofill/contact_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698