autofill_type.h revision 2385ea399aae016c0806a4f9ef3c9cfe3d2a39df
13839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o// Copyright 2013 The Chromium Authors. All rights reserved. 23839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o// Use of this source code is governed by a BSD-style license that can be 3efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o// found in the LICENSE file. 43a5f8eaa9741f6f14520ddd263a996e2764dd437Theodore Ts'o 519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TYPE_H_ 619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TYPE_H_ 7543547a52a20cb7e69d74921b2f691078fd55d83Theodore Ts'o 8543547a52a20cb7e69d74921b2f691078fd55d83Theodore Ts'o#include <string> 919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 103839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "components/autofill/core/browser/field_types.h" 113839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 123839e65723771b85975f4263102dd3ceec4523cTheodore Ts'onamespace autofill { 133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 144cbe8af4b0d0c72fb28bb500c1bd8a46b00fdde3Theodore Ts'o// The high-level description of Autofill types, used to categorize form fields 153839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o// and for associating form fields with form values in the Web Database. 164cbe8af4b0d0c72fb28bb500c1bd8a46b00fdde3Theodore Ts'oclass AutofillType { 17f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o public: 18b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o explicit AutofillType(AutofillFieldType field_type); 193839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o AutofillType(const AutofillType& autofill_type); 203839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o AutofillType& operator=(const AutofillType& autofill_type); 213839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 223a5f8eaa9741f6f14520ddd263a996e2764dd437Theodore Ts'o AutofillFieldType field_type() const; 233a5f8eaa9741f6f14520ddd263a996e2764dd437Theodore Ts'o FieldTypeGroup group() const; 24e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 253839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o // Maps |field_type| to a field type that can be directly stored in a profile 263839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o // (in the sense that it makes sense to call |AutofillProfile::SetInfo()| with 273839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o // the returned field type as the first parameter). 28544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o static AutofillFieldType GetEquivalentFieldType(AutofillFieldType field_type); 29e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 30544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o // Maps |field_type| to a field type from ADDRESS_BILLING FieldTypeGroup if 31e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall // field type is an Address type. 32544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o static AutofillFieldType GetEquivalentBillingFieldType( 33544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o AutofillFieldType field_type); 343839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 35b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o // Utilities for serializing and deserializing an |AutofillFieldType|. 36e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall static std::string FieldTypeToString(AutofillFieldType field_type); 373839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o static AutofillFieldType StringToFieldType(const std::string& str); 383839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 39efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o private: 403839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o AutofillFieldType field_type_; 41e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall}; 42e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 433839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} // namespace autofill 443839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 45e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TYPE_H_ 46e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall