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_DATA_MODEL_H_
6#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_MODEL_H_
7
8#include <string>
9
10#include "base/strings/string16.h"
11#include "components/autofill/core/browser/form_group.h"
12
13namespace autofill {
14
15class AutofillType;
16
17// This class is an interface for the primary data models that back Autofill.
18// The information in objects of this class is managed by the
19// PersonalDataManager.
20class AutofillDataModel : public FormGroup {
21 public:
22  AutofillDataModel(const std::string& guid, const std::string& origin);
23  virtual ~AutofillDataModel();
24
25  // Returns the string that should be auto-filled into a text field given the
26  // |type| of that field, localized to the given |app_locale| if appropriate.
27  // If the data model supports multiple values for the given |type|, returns
28  // the |variant|th value for the |type|.
29  virtual base::string16 GetInfoForVariant(const AutofillType& type,
30                                           size_t variant,
31                                           const std::string& app_locale) const;
32
33  // Returns true if the data in this model was entered directly by the user,
34  // rather than automatically aggregated.
35  bool IsVerified() const;
36
37  std::string guid() const { return guid_; }
38  void set_guid(const std::string& guid) { guid_ = guid; }
39
40  std::string origin() const { return origin_; }
41  void set_origin(const std::string& origin) { origin_ = origin; }
42
43 private:
44  // A globally unique ID for this object.
45  std::string guid_;
46
47  // The origin of this data.  This should be
48  //   (a) a web URL for the domain of the form from which the data was
49  //       automatically aggregated, e.g. https://www.example.com/register,
50  //   (b) some other non-empty string, which cannot be interpreted as a web
51  //       URL, identifying the origin for non-aggregated data, or
52  //   (c) an empty string, indicating that the origin for this data is unknown.
53  std::string origin_;
54};
55
56}  // namespace autofill
57
58#endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_MODEL_H_
59