| 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 "base/compiler_specific.h" |
| 12 #include "chrome/browser/autofill/autofill_profile.h" | |
| 13 #include "chrome/browser/autofill/credit_card.h" | |
| 14 #include "chrome/browser/autofill/personal_data_manager.h" | |
| 15 #include "chrome/browser/sync/glue/change_processor.h" | 12 #include "chrome/browser/sync/glue/change_processor.h" |
| 16 #include "chrome/browser/sync/glue/sync_backend_host.h" | 13 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 17 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" | 14 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" |
| 18 #include "chrome/browser/webdata/web_data_service.h" | 15 #include "chrome/browser/webdata/web_data_service.h" |
| 19 #include "content/common/notification_observer.h" | 16 #include "content/common/notification_observer.h" |
| 20 #include "content/common/notification_registrar.h" | 17 #include "content/common/notification_registrar.h" |
| 21 | 18 |
| 22 class AutofillCreditCardChange; | |
| 23 class AutofillEntry; | 19 class AutofillEntry; |
| 24 class AutofillProfileChange; | 20 class AutofillProfileChange; |
| 25 class PersonalDataManager; | |
| 26 class WebDatabase; | 21 class WebDatabase; |
| 27 | 22 |
| 28 namespace sync_api { | 23 namespace sync_api { |
| 29 class ReadNode; | 24 class ReadNode; |
| 30 class WriteNode; | 25 class WriteNode; |
| 31 class WriteTransaction; | 26 class WriteTransaction; |
| 32 } // namespace sync_api | 27 } // namespace sync_api |
| 33 | 28 |
| 34 namespace browser_sync { | 29 namespace browser_sync { |
| 35 | 30 |
| 36 class AutofillModelAssociator; | 31 class AutofillModelAssociator; |
| 37 class UnrecoverableErrorHandler; | 32 class UnrecoverableErrorHandler; |
| 38 | 33 |
| 39 // This class is responsible for taking changes from the web data service and | 34 // This class is responsible for taking changes from the web data service and |
| 40 // applying them to the sync_api 'syncable' model, and vice versa. All | 35 // applying them to the sync_api 'syncable' model, and vice versa. All |
| 41 // operations and use of this class are from the DB thread. | 36 // operations and use of this class are from the DB thread. |
| 42 class AutofillChangeProcessor : public ChangeProcessor, | 37 class AutofillChangeProcessor : public ChangeProcessor, |
| 43 public NotificationObserver { | 38 public NotificationObserver { |
| 44 public: | 39 public: |
| 45 AutofillChangeProcessor(AutofillModelAssociator* model_associator, | 40 AutofillChangeProcessor(AutofillModelAssociator* model_associator, |
| 46 WebDatabase* web_database, | 41 WebDatabase* web_database, |
| 47 PersonalDataManager* personal_data, | 42 Profile* profile, |
| 48 UnrecoverableErrorHandler* error_handler); | 43 UnrecoverableErrorHandler* error_handler); |
| 49 virtual ~AutofillChangeProcessor(); | 44 virtual ~AutofillChangeProcessor(); |
| 50 | 45 |
| 51 // NotificationObserver implementation. | 46 // NotificationObserver implementation. |
| 52 // WebDataService -> sync_api model change application. | 47 // WebDataService -> sync_api model change application. |
| 53 virtual void Observe(int type, | 48 virtual void Observe(int type, |
| 54 const NotificationSource& source, | 49 const NotificationSource& source, |
| 55 const NotificationDetails& details) OVERRIDE; | 50 const NotificationDetails& details) OVERRIDE; |
| 56 | 51 |
| 57 // sync_api model -> WebDataService change application. | 52 // sync_api model -> WebDataService change application. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 sync_api::ChangeRecord::Action action, | 96 sync_api::ChangeRecord::Action action, |
| 102 const sync_pb::AutofillProfileSpecifics& profile, | 97 const sync_pb::AutofillProfileSpecifics& profile, |
| 103 int64 sync_id); | 98 int64 sync_id); |
| 104 | 99 |
| 105 // Delete is a special case of change application. | 100 // Delete is a special case of change application. |
| 106 void ApplySyncAutofillEntryDelete( | 101 void ApplySyncAutofillEntryDelete( |
| 107 const sync_pb::AutofillSpecifics& autofill); | 102 const sync_pb::AutofillSpecifics& autofill); |
| 108 void ApplySyncAutofillProfileDelete( | 103 void ApplySyncAutofillProfileDelete( |
| 109 int64 sync_id); | 104 int64 sync_id); |
| 110 | 105 |
| 111 // Helper to post a task to the UI loop to inform the PersonalDataManager | |
| 112 // it needs to refresh itself. | |
| 113 void PostOptimisticRefreshTask(); | |
| 114 | |
| 115 // Called to see if we need to upgrade to the new autofill2 profile. | 106 // Called to see if we need to upgrade to the new autofill2 profile. |
| 116 bool HasNotMigratedYet(const sync_api::BaseTransaction* trans); | 107 bool HasNotMigratedYet(const sync_api::BaseTransaction* trans); |
| 117 | 108 |
| 118 // The two models should be associated according to this ModelAssociator. | 109 // The two models should be associated according to this ModelAssociator. |
| 119 AutofillModelAssociator* model_associator_; | 110 AutofillModelAssociator* model_associator_; |
| 120 | 111 |
| 121 // The model we are processing changes from. This is owned by the | 112 // The model we are processing changes from. This is owned by the |
| 122 // WebDataService which is kept alive by our data type controller | 113 // WebDataService which is kept alive by our data type controller |
| 123 // holding a reference. | 114 // holding a reference. |
| 124 WebDatabase* web_database_; | 115 WebDatabase* web_database_; |
| 125 | 116 |
| 126 // We periodically tell the PersonalDataManager to refresh as we make | 117 // The profile we are syncing for. This is used to notify listeners of |
| 127 // changes to the autofill data in the WebDatabase. | 118 // the changes made. |
| 128 PersonalDataManager* personal_data_; | 119 Profile* profile_; |
| 129 | 120 |
| 130 NotificationRegistrar notification_registrar_; | 121 NotificationRegistrar notification_registrar_; |
| 131 | 122 |
| 132 bool observing_; | 123 bool observing_; |
| 133 | 124 |
| 134 // Record of changes from ApplyChangesFromSyncModel. These are then processed | 125 // Record of changes from ApplyChangesFromSyncModel. These are then processed |
| 135 // in CommitChangesFromSyncModel. | 126 // in CommitChangesFromSyncModel. |
| 136 struct AutofillChangeRecord; | 127 struct AutofillChangeRecord; |
| 137 std::vector<AutofillChangeRecord> autofill_changes_; | 128 std::vector<AutofillChangeRecord> autofill_changes_; |
| 138 | 129 |
| 139 DISALLOW_COPY_AND_ASSIGN(AutofillChangeProcessor); | 130 DISALLOW_COPY_AND_ASSIGN(AutofillChangeProcessor); |
| 140 }; | 131 }; |
| 141 | 132 |
| 142 } // namespace browser_sync | 133 } // namespace browser_sync |
| 143 | 134 |
| 144 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_CHANGE_PROCESSOR_H_ | 135 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_CHANGE_PROCESSOR_H_ |
| OLD | NEW |