• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_CONTACT_INFO_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_CONTACT_INFO_H_
7 
8 #include <vector>
9 
10 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h"
12 #include "base/strings/string16.h"
13 #include "components/autofill/core/browser/form_group.h"
14 
15 namespace autofill {
16 
17 // A form group that stores name information.
18 class NameInfo : public FormGroup {
19  public:
20   NameInfo();
21   NameInfo(const NameInfo& info);
22   virtual ~NameInfo();
23 
24   NameInfo& operator=(const NameInfo& info);
25 
26   // Compares |NameInfo| objects for |first_|, |middle_| and |last_| names,
27   // ignoring their case differences.
28   bool EqualsIgnoreCase(const NameInfo& info);
29 
30   // FormGroup:
31   virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
32   virtual void SetRawInfo(ServerFieldType type,
33                           const base::string16& value) OVERRIDE;
34 
35  private:
36   // FormGroup:
37   virtual void GetSupportedTypes(
38       ServerFieldTypeSet* supported_types) const OVERRIDE;
39 
40   // Returns the full name, which is either |full_|, or if |full_| is empty,
41   // is composed of given, middle and family.
42   base::string16 FullName() const;
43 
44   // Returns the middle initial if |middle_| is non-empty.  Returns an empty
45   // string otherwise.
46   base::string16 MiddleInitial() const;
47 
48   // Sets |given_|, |middle_|, and |family_| to the tokenized |full|.
49   void SetFullName(const base::string16& full);
50 
51   base::string16 given_;
52   base::string16 middle_;
53   base::string16 family_;
54   base::string16 full_;
55 };
56 
57 class EmailInfo : public FormGroup {
58  public:
59   EmailInfo();
60   EmailInfo(const EmailInfo& info);
61   virtual ~EmailInfo();
62 
63   EmailInfo& operator=(const EmailInfo& info);
64 
65   // FormGroup:
66   virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
67   virtual void SetRawInfo(ServerFieldType type,
68                           const base::string16& value) OVERRIDE;
69 
70  private:
71   // FormGroup:
72   virtual void GetSupportedTypes(
73       ServerFieldTypeSet* supported_types) const OVERRIDE;
74 
75   base::string16 email_;
76 };
77 
78 class CompanyInfo : public FormGroup {
79  public:
80   CompanyInfo();
81   CompanyInfo(const CompanyInfo& info);
82   virtual ~CompanyInfo();
83 
84   CompanyInfo& operator=(const CompanyInfo& info);
85 
86   // FormGroup:
87   virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
88   virtual void SetRawInfo(ServerFieldType type,
89                           const base::string16& value) OVERRIDE;
90 
91  private:
92   // FormGroup:
93   virtual void GetSupportedTypes(
94       ServerFieldTypeSet* supported_types) const OVERRIDE;
95 
96   base::string16 company_name_;
97 };
98 
99 }  // namespace autofill
100 
101 #endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_CONTACT_INFO_H_
102