summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/autofill_type.h
blob: 20911539b924e7d309b110456035f3dcb659e0be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// 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_AUTOFILL_TYPE_H_
#define CHROME_BROWSER_AUTOFILL_AUTOFILL_TYPE_H_
#pragma once

#include <map>
#include <set>

#include "base/string16.h"
#include "chrome/browser/autofill/field_types.h"

// The high-level description of AutoFill types, used to categorize form fields
// and for associating form fields with form values in the Web Database.
class AutoFillType {
 public:
  enum FieldTypeGroup {
    NO_GROUP,
    CONTACT_INFO,
    ADDRESS_HOME,
    ADDRESS_BILLING,
    PHONE_HOME,
    PHONE_FAX,
    CREDIT_CARD,
  };

  enum FieldTypeSubGroup {
    NO_SUBGROUP,
    // Address subgroups.
    ADDRESS_LINE1,
    ADDRESS_LINE2,
    ADDRESS_APT_NUM,
    ADDRESS_CITY,
    ADDRESS_STATE,
    ADDRESS_ZIP,
    ADDRESS_COUNTRY,

    // Phone subgroups.
    PHONE_NUMBER,
    PHONE_CITY_CODE,
    PHONE_COUNTRY_CODE,
    PHONE_CITY_AND_NUMBER,
    PHONE_WHOLE_NUMBER
  };

  struct AutoFillTypeDefinition {
    FieldTypeGroup group;
    FieldTypeSubGroup subgroup;
  };

  explicit AutoFillType(AutoFillFieldType field_type);
  AutoFillType(const AutoFillType& autofill_type);
  AutoFillType& operator=(const AutoFillType& autofill_type);

  AutoFillFieldType field_type() const;
  FieldTypeGroup group() const;
  FieldTypeSubGroup subgroup() const;

 private:
  AutoFillFieldType field_type_;
};

typedef AutoFillType::FieldTypeGroup FieldTypeGroup;
typedef AutoFillType::FieldTypeSubGroup FieldTypeSubGroup;
typedef std::set<AutoFillFieldType> FieldTypeSet;
typedef std::map<string16, AutoFillFieldType> FieldTypeMap;

#endif  // CHROME_BROWSER_AUTOFILL_AUTOFILL_TYPE_H_