| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 CHROME_BROWSER_WEBDATA_AUTOFILL_CHANGE_H__ | |
| 6 #define CHROME_BROWSER_WEBDATA_AUTOFILL_CHANGE_H__ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "chrome/browser/webdata/autofill_entry.h" | |
| 11 | |
| 12 class AutofillProfile; | |
| 13 class CreditCard; | |
| 14 | |
| 15 // For classic Autofill form fields, the KeyType is AutofillKey. | |
| 16 // Autofill++ types such as AutofillProfile and CreditCard simply use an int. | |
| 17 template <typename KeyType> | |
| 18 class GenericAutofillChange { | |
| 19 public: | |
| 20 typedef enum { | |
| 21 ADD, | |
| 22 UPDATE, | |
| 23 REMOVE | |
| 24 } Type; | |
| 25 | |
| 26 virtual ~GenericAutofillChange() {} | |
| 27 | |
| 28 Type type() const { return type_; } | |
| 29 const KeyType& key() const { return key_; } | |
| 30 | |
| 31 protected: | |
| 32 GenericAutofillChange(Type type, const KeyType& key) | |
| 33 : type_(type), | |
| 34 key_(key) {} | |
| 35 private: | |
| 36 Type type_; | |
| 37 KeyType key_; | |
| 38 }; | |
| 39 | |
| 40 class AutofillChange : public GenericAutofillChange<AutofillKey> { | |
| 41 public: | |
| 42 AutofillChange(Type type, const AutofillKey& key); | |
| 43 virtual ~AutofillChange(); | |
| 44 bool operator==(const AutofillChange& change) const { | |
| 45 return type() == change.type() && key() == change.key(); | |
| 46 } | |
| 47 }; | |
| 48 | |
| 49 typedef std::vector<AutofillChange> AutofillChangeList; | |
| 50 | |
| 51 // Change notification details for Autofill profile changes. | |
| 52 class AutofillProfileChange : public GenericAutofillChange<std::string> { | |
| 53 public: | |
| 54 // The |type| input specifies the change type. The |key| input is the key, | |
| 55 // which is expected to be the GUID identifying the |profile|. | |
| 56 // When |type| == ADD, |profile| should be non-NULL. | |
| 57 // When |type| == UPDATE, |profile| should be non-NULL. | |
| 58 // When |type| == REMOVE, |profile| should be NULL. | |
| 59 AutofillProfileChange(Type type, | |
| 60 const std::string& key, | |
| 61 const AutofillProfile* profile); | |
| 62 virtual ~AutofillProfileChange(); | |
| 63 | |
| 64 const AutofillProfile* profile() const { return profile_; } | |
| 65 bool operator==(const AutofillProfileChange& change) const; | |
| 66 | |
| 67 private: | |
| 68 // Weak reference, can be NULL. | |
| 69 const AutofillProfile* profile_; | |
| 70 }; | |
| 71 | |
| 72 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_CHANGE_H__ | |
| OLD | NEW |