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.
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_MODEL_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_MODEL_H_
10 #include "base/strings/string16.h"
11 #include "base/time/time.h"
12 #include "components/autofill/core/browser/form_group.h"
18 // This class is an interface for the primary data models that back Autofill.
19 // The information in objects of this class is managed by the
20 // PersonalDataManager.
21 class AutofillDataModel
: public FormGroup
{
23 AutofillDataModel(const std::string
& guid
, const std::string
& origin
);
24 ~AutofillDataModel() override
;
26 // Returns the string that should be auto-filled into a text field given the
27 // |type| of that field, localized to the given |app_locale| if appropriate.
28 // If the data model supports multiple values for the given |type|, returns
29 // the |variant|th value for the |type|.
30 virtual base::string16
GetInfoForVariant(const AutofillType
& type
,
32 const std::string
& app_locale
) const;
34 // Returns true if the data in this model was entered directly by the user,
35 // rather than automatically aggregated.
36 bool IsVerified() const;
38 // Called to update |use_count_| and |use_date_| when this data model is
39 // the subject of user interaction (usually, when it's used to fill a form).
42 std::string
guid() const { return guid_
; }
43 void set_guid(const std::string
& guid
) { guid_
= guid
; }
45 std::string
origin() const { return origin_
; }
46 void set_origin(const std::string
& origin
) { origin_
= origin
; }
48 size_t use_count() const { return use_count_
; }
49 void set_use_count(size_t count
) { use_count_
= count
; }
51 const base::Time
& use_date() const { return use_date_
; }
52 void set_use_date(const base::Time
& time
) { use_date_
= time
; }
54 const base::Time
& modification_date() const { return modification_date_
; }
55 // This should only be called from database code.
56 void set_modification_date(const base::Time
& time
) {
57 modification_date_
= time
;
61 // A globally unique ID for this object.
64 // The origin of this data. This should be
65 // (a) a web URL for the domain of the form from which the data was
66 // automatically aggregated, e.g. https://www.example.com/register,
67 // (b) some other non-empty string, which cannot be interpreted as a web
68 // URL, identifying the origin for non-aggregated data, or
69 // (c) an empty string, indicating that the origin for this data is unknown.
72 // The number of times this model has been used.
75 // The last time the model was used.
78 // The last time data in the model was modified.
79 base::Time modification_date_
;
82 } // namespace autofill
84 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_MODEL_H_