autofill_type.h revision 3240926e260ce088908e02ac07a6cf7b0c0cbf44
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_AUTOFILL_TYPE_H_
6#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TYPE_H_
7
8#include <string>
9
10#include "components/autofill/core/browser/field_types.h"
11
12namespace autofill {
13
14// The high-level description of Autofill types, used to categorize form fields
15// and for associating form fields with form values in the Web Database.
16class AutofillType {
17 public:
18  explicit AutofillType(ServerFieldType field_type);
19  AutofillType(const AutofillType& autofill_type);
20  AutofillType& operator=(const AutofillType& autofill_type);
21
22  // TODO(isherman): Audit all uses of this method.
23  ServerFieldType server_type() const { return server_type_; }
24  FieldTypeGroup group() const;
25
26  // Maps |field_type| to a field type that can be directly stored in a profile
27  // (in the sense that it makes sense to call |AutofillProfile::SetInfo()| with
28  // the returned field type as the first parameter).
29  static ServerFieldType GetEquivalentFieldType(ServerFieldType field_type);
30
31  // Maps |field_type| to a field type from ADDRESS_BILLING FieldTypeGroup if
32  // field type is an Address type.
33  static ServerFieldType GetEquivalentBillingFieldType(
34      ServerFieldType field_type);
35
36  // Utilities for serializing and deserializing a |ServerFieldType|.
37  // TODO(isherman): This should probably serialize an HTML type as well.
38  //                 Audit all uses of these functions.
39  static std::string FieldTypeToString(ServerFieldType field_type);
40  static ServerFieldType StringToFieldType(const std::string& str);
41
42 private:
43  ServerFieldType server_type_;
44};
45
46}  // namespace autofill
47
48#endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TYPE_H_
49