diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-09 03:52:11 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-09 03:52:11 +0000 |
commit | 438972438f5ac32db1aaf53e136e73f9c478d70a (patch) | |
tree | 3cd8b362998b3a30caba0d2fea57fa88bed6d1b7 /chrome/browser/autofill/contact_info.h | |
parent | 42181ca53444d50c2070241435153b6b73b5c6f9 (diff) | |
download | chromium_src-438972438f5ac32db1aaf53e136e73f9c478d70a.zip chromium_src-438972438f5ac32db1aaf53e136e73f9c478d70a.tar.gz chromium_src-438972438f5ac32db1aaf53e136e73f9c478d70a.tar.bz2 |
Autofill extend profiles to include multi-valued fields, part 2.
No functional change. This partitions the |ContactInfo| class into separate name, email, and company parts. AutoFillProfile is changed to store its component members directly instead of in a map (in preparation for multiple values). And the |Clone| operation is deprecated from the |FormGroup| class on down through the inheritance tree.
BUG=65625
TEST=All existing unit tests.
Review URL: http://codereview.chromium.org/6650014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77425 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/contact_info.h')
-rw-r--r-- | chrome/browser/autofill/contact_info.h | 89 |
1 files changed, 61 insertions, 28 deletions
diff --git a/chrome/browser/autofill/contact_info.h b/chrome/browser/autofill/contact_info.h index d743630..22c618a 100644 --- a/chrome/browser/autofill/contact_info.h +++ b/chrome/browser/autofill/contact_info.h @@ -8,19 +8,20 @@ #include <vector> +#include "base/gtest_prod_util.h" #include "base/string16.h" #include "chrome/browser/autofill/form_group.h" -typedef std::vector<string16> NameTokens; - -// A form group that stores contact information. -class ContactInfo : public FormGroup { +// A form group that stores name information. +class NameInfo : public FormGroup { public: - ContactInfo(); - virtual ~ContactInfo(); + NameInfo(); + explicit NameInfo(const NameInfo& info); + virtual ~NameInfo(); + + NameInfo& operator=(const NameInfo& info); - // FormGroup implementation: - virtual FormGroup* Clone() const; + // FormGroup: virtual void GetPossibleFieldTypes(const string16& text, FieldTypeSet* possible_types) const; virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; @@ -31,12 +32,10 @@ class ContactInfo : public FormGroup { virtual void SetInfo(const AutofillType& type, const string16& value); private: - friend class ContactInfoTest; - explicit ContactInfo(const ContactInfo& contact_info); - void operator=(const ContactInfo& info); + FRIEND_TEST_ALL_PREFIXES(NameInfoTest, TestSetFullName); - // Returns the full name, which can include up to the first, middle, middle - // initial, last name, and suffix. + // Returns the full name, which can include up to the first, middle, and last + // name. string16 FullName() const; // Returns the middle initial if |middle_| is non-empty. Returns an empty @@ -46,9 +45,6 @@ class ContactInfo : public FormGroup { const string16& first() const { return first_; } const string16& middle() const { return middle_; } const string16& last() const { return last_; } - const string16& suffix() const { return suffix_; } - const string16& email() const { return email_; } - const string16& company_name() const { return company_name_; } // A helper function for FindInfoMatches that only handles matching the info // with the requested field type. @@ -65,9 +61,6 @@ class ContactInfo : public FormGroup { // Returns true if |text| is the last name. bool IsLastName(const string16& text) const; - // Returns true if |text| is the suffix. - bool IsSuffix(const string16& text) const; - // Returns true if |text| is the middle initial. bool IsMiddleInitial(const string16& text) const; @@ -76,10 +69,12 @@ class ContactInfo : public FormGroup { // Returns true if all of the tokens in |text| match the tokens in // |name_tokens|. - bool IsNameMatch(const string16& text, const NameTokens& name_tokens) const; + bool IsNameMatch(const string16& text, + const std::vector<string16>& name_tokens) const; // Returns true if |word| is one of the tokens in |name_tokens|. - bool IsWordInName(const string16& word, const NameTokens& name_tokens) const; + bool IsWordInName(const string16& word, + const std::vector<string16>& name_tokens) const; // Sets |first_| to |first| and |first_tokens_| to the set of tokens in // |first|, made lowercase. @@ -97,19 +92,57 @@ class ContactInfo : public FormGroup { // |full|. It is tokenized on a space only. void SetFullName(const string16& full); - void set_suffix(const string16& suffix) { suffix_ = suffix; } - // List of tokens in each part of the name. - NameTokens first_tokens_; - NameTokens middle_tokens_; - NameTokens last_tokens_; + std::vector<string16> first_tokens_; + std::vector<string16> middle_tokens_; + std::vector<string16> last_tokens_; - // Contact information data. string16 first_; string16 middle_; string16 last_; - string16 suffix_; +}; + +class EmailInfo : public FormGroup { + public: + EmailInfo(); + explicit EmailInfo(const EmailInfo& info); + virtual ~EmailInfo(); + + EmailInfo& operator=(const EmailInfo& info); + + // FormGroup: + virtual void GetPossibleFieldTypes(const string16& text, + FieldTypeSet* possible_types) const; + virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; + virtual void FindInfoMatches(const AutofillType& type, + const string16& info, + std::vector<string16>* matched_text) const; + virtual string16 GetFieldText(const AutofillType& type) const; + virtual void SetInfo(const AutofillType& type, const string16& value); + + private: string16 email_; +}; + +class CompanyInfo : public FormGroup { + public: + CompanyInfo(); + explicit CompanyInfo(const CompanyInfo& info); + virtual ~CompanyInfo(); + + CompanyInfo& operator=(const CompanyInfo& info); + + // FormGroup: + virtual void GetPossibleFieldTypes(const string16& text, + FieldTypeSet* possible_types) const; + virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; + virtual void FindInfoMatches(const AutofillType& type, + const string16& info, + std::vector<string16>* matched_text) const; + virtual string16 GetFieldText(const AutofillType& type) const; + virtual void SetInfo(const AutofillType& type, const string16& value); + + private: string16 company_name_; }; |