summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/contact_info.h
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-04 20:27:25 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-04 20:27:25 +0000
commit6c17851db5843c959c073b606f474434cddf5c19 (patch)
treeca18cefae8e06d37b648dd36a28e3dd2ecddfc5a /chrome/browser/autofill/contact_info.h
parent5ed7c01ee895b37c12252bc63d769af26f9093ec (diff)
downloadchromium_src-6c17851db5843c959c073b606f474434cddf5c19.zip
chromium_src-6c17851db5843c959c073b606f474434cddf5c19.tar.gz
chromium_src-6c17851db5843c959c073b606f474434cddf5c19.tar.bz2
Implement ContactInfo, the FormGroup that stores contact information.
BUG=none TEST=StringUtilTest.Tokenizer Review URL: http://codereview.chromium.org/502103 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35475 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/contact_info.h')
-rw-r--r--chrome/browser/autofill/contact_info.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/chrome/browser/autofill/contact_info.h b/chrome/browser/autofill/contact_info.h
new file mode 100644
index 0000000..957e55e
--- /dev/null
+++ b/chrome/browser/autofill/contact_info.h
@@ -0,0 +1,105 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_AUTOFILL_CONTACT_INFO_H_
+#define CHROME_BROWSER_AUTOFILL_CONTACT_INFO_H_
+
+#include <vector>
+
+#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 {
+ public:
+ ContactInfo() {}
+
+ // FormGroup implementation:
+ virtual FormGroup* Clone() const;
+ virtual void GetPossibleFieldTypes(const string16& text,
+ FieldTypeSet* possible_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);
+
+ // Returns the full name, which can include up to the first, middle, middle
+ // initial, last name, and suffix.
+ string16 FullName() const;
+
+ string16 first() const { return first_; }
+ string16 middle() const { return middle_; }
+ string16 last() const { return last_; }
+ string16 MiddleInitial() const;
+ string16 suffix() const { return suffix_; }
+ string16 email() const { return email_; }
+ string16 company_name() const { return company_name_; }
+
+ private:
+ explicit ContactInfo(const ContactInfo& contact_info);
+ void operator=(const ContactInfo& info);
+
+ // A helper function for FindInfoMatches that only handles matching the info
+ // with the requested field type.
+ bool FindInfoMatchesHelper(const AutoFillFieldType& field_type,
+ const string16& info,
+ string16* matched_text) const;
+
+ // Returns true if |text| is the first name.
+ bool IsFirstName(const string16& text) const;
+
+ // Returns true if |text| is the middle name.
+ bool IsMiddleName(const string16& text) const;
+
+ // 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;
+
+ // Returns true if |text| is the last name.
+ bool IsFullName(const string16& text) const;
+
+ // 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;
+
+ // Returns true if |word| is one of the tokens in |name_tokens|.
+ bool IsWordInName(const string16& word, const NameTokens& name_tokens) const;
+
+ // Sets |first_| to |first| and |first_tokens_| to the set of tokens in
+ // |first|, made lowercase.
+ void SetFirst(const string16& first);
+
+ // Sets |middle_| to |middle| and |middle_tokens_| to the set of tokens in
+ // |middle|, made lowercase.
+ void SetMiddle(const string16& middle);
+
+ // Sets |last_| to |last| and |last_tokens_| to the set of tokens in |last|,
+ // made lowercase.
+ void SetLast(const string16& last);
+
+ 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_;
+
+ // Contact information data.
+ string16 first_;
+ string16 middle_;
+ string16 last_;
+ string16 suffix_;
+ string16 email_;
+ string16 company_name_;
+};
+
+#endif // CHROME_BROWSER_AUTOFILL_CONTACT_INFO_H_