| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_CHANGE_PROCESSOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_CHANGE_PROCESSOR_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_CHANGE_PROCESSOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_CHANGE_PROCESSOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" |
| 11 #include "chrome/browser/autofill/autofill_profile.h" | 12 #include "chrome/browser/autofill/autofill_profile.h" |
| 12 #include "chrome/browser/autofill/credit_card.h" | 13 #include "chrome/browser/autofill/credit_card.h" |
| 13 #include "chrome/browser/autofill/personal_data_manager.h" | 14 #include "chrome/browser/autofill/personal_data_manager.h" |
| 14 #include "chrome/browser/sync/glue/change_processor.h" | 15 #include "chrome/browser/sync/glue/change_processor.h" |
| 15 #include "chrome/browser/sync/glue/sync_backend_host.h" | 16 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 16 #include "chrome/browser/sync/internal_api/sync_manager.h" | |
| 17 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" | 17 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" |
| 18 #include "chrome/browser/webdata/web_data_service.h" | 18 #include "chrome/browser/webdata/web_data_service.h" |
| 19 #include "content/common/notification_observer.h" | 19 #include "content/common/notification_observer.h" |
| 20 #include "content/common/notification_registrar.h" | 20 #include "content/common/notification_registrar.h" |
| 21 | 21 |
| 22 class AutofillCreditCardChange; | 22 class AutofillCreditCardChange; |
| 23 class AutofillEntry; | 23 class AutofillEntry; |
| 24 class AutofillProfileChange; | 24 class AutofillProfileChange; |
| 25 class PersonalDataManager; | 25 class PersonalDataManager; |
| 26 class WebDatabase; | 26 class WebDatabase; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 45 AutofillChangeProcessor(AutofillModelAssociator* model_associator, | 45 AutofillChangeProcessor(AutofillModelAssociator* model_associator, |
| 46 WebDatabase* web_database, | 46 WebDatabase* web_database, |
| 47 PersonalDataManager* personal_data, | 47 PersonalDataManager* personal_data, |
| 48 UnrecoverableErrorHandler* error_handler); | 48 UnrecoverableErrorHandler* error_handler); |
| 49 virtual ~AutofillChangeProcessor(); | 49 virtual ~AutofillChangeProcessor(); |
| 50 | 50 |
| 51 // NotificationObserver implementation. | 51 // NotificationObserver implementation. |
| 52 // WebDataService -> sync_api model change application. | 52 // WebDataService -> sync_api model change application. |
| 53 virtual void Observe(int type, | 53 virtual void Observe(int type, |
| 54 const NotificationSource& source, | 54 const NotificationSource& source, |
| 55 const NotificationDetails& details); | 55 const NotificationDetails& details) OVERRIDE; |
| 56 | 56 |
| 57 // sync_api model -> WebDataService change application. | 57 // sync_api model -> WebDataService change application. |
| 58 virtual void ApplyChangesFromSyncModel( | 58 virtual void ApplyChangesFromSyncModel( |
| 59 const sync_api::BaseTransaction* trans, | 59 const sync_api::BaseTransaction* trans, |
| 60 const sync_api::SyncManager::ChangeRecord* changes, | 60 const sync_api::ImmutableChangeRecordList& changes) OVERRIDE; |
| 61 int change_count); | |
| 62 | 61 |
| 63 // Commit any changes from ApplyChangesFromSyncModel buffered in | 62 // Commit any changes from ApplyChangesFromSyncModel buffered in |
| 64 // autofill_changes_. | 63 // autofill_changes_. |
| 65 virtual void CommitChangesFromSyncModel(); | 64 virtual void CommitChangesFromSyncModel() OVERRIDE; |
| 66 | 65 |
| 67 // Copy the properties of the given Autofill entry into the sync | 66 // Copy the properties of the given Autofill entry into the sync |
| 68 // node. | 67 // node. |
| 69 static void WriteAutofillEntry(const AutofillEntry& entry, | 68 static void WriteAutofillEntry(const AutofillEntry& entry, |
| 70 sync_api::WriteNode* node); | 69 sync_api::WriteNode* node); |
| 71 // TODO(georgey) : add the same processing for CC info (already in protocol | 70 // TODO(georgey) : add the same processing for CC info (already in protocol |
| 72 // buffers). | 71 // buffers). |
| 73 | 72 |
| 74 protected: | 73 protected: |
| 75 virtual void StartImpl(Profile* profile); | 74 virtual void StartImpl(Profile* profile) OVERRIDE; |
| 76 virtual void StopImpl(); | 75 virtual void StopImpl() OVERRIDE; |
| 77 | 76 |
| 78 private: | 77 private: |
| 79 void StartObserving(); | 78 void StartObserving(); |
| 80 void StopObserving(); | 79 void StopObserving(); |
| 81 | 80 |
| 82 // A function to remove the sync node for an autofill entry or profile. | 81 // A function to remove the sync node for an autofill entry or profile. |
| 83 void RemoveSyncNode(const std::string& tag, | 82 void RemoveSyncNode(const std::string& tag, |
| 84 sync_api::WriteTransaction* trans); | 83 sync_api::WriteTransaction* trans); |
| 85 | 84 |
| 86 // These two methods are dispatched to by Observe depending on the type. | 85 // These two methods are dispatched to by Observe depending on the type. |
| 87 void ObserveAutofillEntriesChanged(AutofillChangeList* changes, | 86 void ObserveAutofillEntriesChanged(AutofillChangeList* changes, |
| 88 sync_api::WriteTransaction* trans, | 87 sync_api::WriteTransaction* trans, |
| 89 const sync_api::ReadNode& autofill_root); | 88 const sync_api::ReadNode& autofill_root); |
| 90 void ObserveAutofillProfileChanged(AutofillProfileChange* change, | 89 void ObserveAutofillProfileChanged(AutofillProfileChange* change, |
| 91 sync_api::WriteTransaction* trans, | 90 sync_api::WriteTransaction* trans, |
| 92 const sync_api::ReadNode& autofill_root); | 91 const sync_api::ReadNode& autofill_root); |
| 93 | 92 |
| 94 // The following methods are the implementation of ApplyChangeFromSyncModel | 93 // The following methods are the implementation of ApplyChangeFromSyncModel |
| 95 // for the respective autofill subtypes. | 94 // for the respective autofill subtypes. |
| 96 void ApplySyncAutofillEntryChange( | 95 void ApplySyncAutofillEntryChange( |
| 97 sync_api::SyncManager::ChangeRecord::Action action, | 96 sync_api::ChangeRecord::Action action, |
| 98 const sync_pb::AutofillSpecifics& autofill, | 97 const sync_pb::AutofillSpecifics& autofill, |
| 99 std::vector<AutofillEntry>* new_entries, | 98 std::vector<AutofillEntry>* new_entries, |
| 100 int64 sync_id); | 99 int64 sync_id); |
| 101 void ApplySyncAutofillProfileChange( | 100 void ApplySyncAutofillProfileChange( |
| 102 sync_api::SyncManager::ChangeRecord::Action action, | 101 sync_api::ChangeRecord::Action action, |
| 103 const sync_pb::AutofillProfileSpecifics& profile, | 102 const sync_pb::AutofillProfileSpecifics& profile, |
| 104 int64 sync_id); | 103 int64 sync_id); |
| 105 | 104 |
| 106 // Delete is a special case of change application. | 105 // Delete is a special case of change application. |
| 107 void ApplySyncAutofillEntryDelete( | 106 void ApplySyncAutofillEntryDelete( |
| 108 const sync_pb::AutofillSpecifics& autofill); | 107 const sync_pb::AutofillSpecifics& autofill); |
| 109 void ApplySyncAutofillProfileDelete( | 108 void ApplySyncAutofillProfileDelete( |
| 110 int64 sync_id); | 109 int64 sync_id); |
| 111 | 110 |
| 112 // Helper to post a task to the UI loop to inform the PersonalDataManager | 111 // Helper to post a task to the UI loop to inform the PersonalDataManager |
| (...skipping 23 matching lines...) Expand all Loading... |
| 136 // in CommitChangesFromSyncModel. | 135 // in CommitChangesFromSyncModel. |
| 137 struct AutofillChangeRecord; | 136 struct AutofillChangeRecord; |
| 138 std::vector<AutofillChangeRecord> autofill_changes_; | 137 std::vector<AutofillChangeRecord> autofill_changes_; |
| 139 | 138 |
| 140 DISALLOW_COPY_AND_ASSIGN(AutofillChangeProcessor); | 139 DISALLOW_COPY_AND_ASSIGN(AutofillChangeProcessor); |
| 141 }; | 140 }; |
| 142 | 141 |
| 143 } // namespace browser_sync | 142 } // namespace browser_sync |
| 144 | 143 |
| 145 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_CHANGE_PROCESSOR_H_ | 144 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_CHANGE_PROCESSOR_H_ |
| OLD | NEW |