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
15namespace autofill {
16
17// A form group that stores name information.
18class 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 |given_|, |middle_| and |family_| names,
27  // ignoring their case differences.
28  bool ParsedNamesAreEqual(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  virtual base::string16 GetInfo(const AutofillType& type,
35                                 const std::string& app_locale) const OVERRIDE;
36  virtual bool SetInfo(const AutofillType& type,
37                       const base::string16& value,
38                       const std::string& app_locale) OVERRIDE;
39
40 private:
41  // FormGroup:
42  virtual void GetSupportedTypes(
43      ServerFieldTypeSet* supported_types) const OVERRIDE;
44
45  // Returns the full name, which is either |full_|, or if |full_| is empty,
46  // is composed of given, middle and family.
47  base::string16 FullName() const;
48
49  // Returns the middle initial if |middle_| is non-empty.  Returns an empty
50  // string otherwise.
51  base::string16 MiddleInitial() const;
52
53  // Sets |given_|, |middle_|, and |family_| to the tokenized |full|.
54  void SetFullName(const base::string16& full);
55
56  base::string16 given_;
57  base::string16 middle_;
58  base::string16 family_;
59  base::string16 full_;
60};
61
62class EmailInfo : public FormGroup {
63 public:
64  EmailInfo();
65  EmailInfo(const EmailInfo& info);
66  virtual ~EmailInfo();
67
68  EmailInfo& operator=(const EmailInfo& info);
69
70  // FormGroup:
71  virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
72  virtual void SetRawInfo(ServerFieldType type,
73                          const base::string16& value) OVERRIDE;
74
75 private:
76  // FormGroup:
77  virtual void GetSupportedTypes(
78      ServerFieldTypeSet* supported_types) const OVERRIDE;
79
80  base::string16 email_;
81};
82
83class CompanyInfo : public FormGroup {
84 public:
85  CompanyInfo();
86  CompanyInfo(const CompanyInfo& info);
87  virtual ~CompanyInfo();
88
89  CompanyInfo& operator=(const CompanyInfo& info);
90
91  // FormGroup:
92  virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
93  virtual void SetRawInfo(ServerFieldType type,
94                          const base::string16& value) OVERRIDE;
95
96 private:
97  // FormGroup:
98  virtual void GetSupportedTypes(
99      ServerFieldTypeSet* supported_types) const OVERRIDE;
100
101  base::string16 company_name_;
102};
103
104}  // namespace autofill
105
106#endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_CONTACT_INFO_H_
107