ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / components / autofill / core / browser / webdata / autofill_change.h
blob0e856570f94d66efa173cfb37dacb385df5051eb
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_WEBDATA_AUTOFILL_CHANGE_H__
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_CHANGE_H__
8 #include <vector>
10 #include "components/autofill/core/browser/webdata/autofill_entry.h"
12 namespace autofill {
14 class AutofillProfile;
16 // For classic Autofill form fields, the KeyType is AutofillKey.
17 // Autofill++ types such as AutofillProfile and CreditCard simply use an int.
18 template <typename KeyType>
19 class GenericAutofillChange {
20 public:
21 enum Type {
22 ADD,
23 UPDATE,
24 REMOVE
27 virtual ~GenericAutofillChange() {}
29 Type type() const { return type_; }
30 const KeyType& key() const { return key_; }
32 protected:
33 GenericAutofillChange(Type type, const KeyType& key)
34 : type_(type),
35 key_(key) {}
36 private:
37 Type type_;
38 KeyType key_;
41 class AutofillChange : public GenericAutofillChange<AutofillKey> {
42 public:
43 AutofillChange(Type type, const AutofillKey& key);
44 ~AutofillChange() override;
45 bool operator==(const AutofillChange& change) const {
46 return type() == change.type() && key() == change.key();
50 typedef std::vector<AutofillChange> AutofillChangeList;
52 // Change notification details for Autofill profile changes.
53 class AutofillProfileChange : public GenericAutofillChange<std::string> {
54 public:
55 // The |type| input specifies the change type. The |key| input is the key,
56 // which is expected to be the GUID identifying the |profile|.
57 // When |type| == ADD, |profile| should be non-NULL.
58 // When |type| == UPDATE, |profile| should be non-NULL.
59 // When |type| == REMOVE, |profile| should be NULL.
60 AutofillProfileChange(Type type,
61 const std::string& key,
62 const AutofillProfile* profile);
63 ~AutofillProfileChange() override;
65 const AutofillProfile* profile() const { return profile_; }
66 bool operator==(const AutofillProfileChange& change) const;
68 private:
69 // Weak reference, can be NULL.
70 const AutofillProfile* profile_;
73 } // namespace autofill
75 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_CHANGE_H__