| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 CANCEL_DURING_CONFIGURE = 12, // Cancelled before choosing data | 135 CANCEL_DURING_CONFIGURE = 12, // Cancelled before choosing data |
| 136 // types and clicking OK. | 136 // types and clicking OK. |
| 137 // Events resulting in the stoppage of sync service. | 137 // Events resulting in the stoppage of sync service. |
| 138 STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options. | 138 STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options. |
| 139 | 139 |
| 140 // Miscellaneous events caused by sync service. | 140 // Miscellaneous events caused by sync service. |
| 141 | 141 |
| 142 MAX_SYNC_EVENT_CODE | 142 MAX_SYNC_EVENT_CODE |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 // Keep track of where we are when clearing server data. | |
| 146 enum ClearServerDataState { | |
| 147 CLEAR_NOT_STARTED = 1, | |
| 148 CLEAR_CLEARING = 2, | |
| 149 CLEAR_FAILED = 3, | |
| 150 CLEAR_SUCCEEDED = 4, | |
| 151 }; | |
| 152 | |
| 153 enum StartBehavior { | 145 enum StartBehavior { |
| 154 AUTO_START, | 146 AUTO_START, |
| 155 MANUAL_START, | 147 MANUAL_START, |
| 156 }; | 148 }; |
| 157 | 149 |
| 158 // Used to specify the kind of passphrase with which sync data is encrypted. | 150 // Used to specify the kind of passphrase with which sync data is encrypted. |
| 159 enum PassphraseType { | 151 enum PassphraseType { |
| 160 IMPLICIT, // The user did not provide a custom passphrase for encryption. | 152 IMPLICIT, // The user did not provide a custom passphrase for encryption. |
| 161 // We implicitly use the GAIA password in such cases. | 153 // We implicitly use the GAIA password in such cases. |
| 162 EXPLICIT, // The user selected the "use custom passphrase" radio button | 154 EXPLICIT, // The user selected the "use custom passphrase" radio button |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // enable or activate the synchronization of the data type (see | 189 // enable or activate the synchronization of the data type (see |
| 198 // ActivateDataType). Takes ownership of the pointer. | 190 // ActivateDataType). Takes ownership of the pointer. |
| 199 void RegisterDataTypeController( | 191 void RegisterDataTypeController( |
| 200 browser_sync::DataTypeController* data_type_controller); | 192 browser_sync::DataTypeController* data_type_controller); |
| 201 | 193 |
| 202 // Returns the session model associator associated with this type, but only if | 194 // Returns the session model associator associated with this type, but only if |
| 203 // the associator is running. If it is doing anything else, it will return | 195 // the associator is running. If it is doing anything else, it will return |
| 204 // null. | 196 // null. |
| 205 browser_sync::SessionModelAssociator* GetSessionModelAssociator(); | 197 browser_sync::SessionModelAssociator* GetSessionModelAssociator(); |
| 206 | 198 |
| 207 // Maintain state of where we are in a server clear operation. | |
| 208 void ResetClearServerDataState(); | |
| 209 ClearServerDataState GetClearServerDataState(); | |
| 210 | |
| 211 // Fills state_map with a map of current data types that are possible to | 199 // Fills state_map with a map of current data types that are possible to |
| 212 // sync, as well as their states. | 200 // sync, as well as their states. |
| 213 void GetDataTypeControllerStates( | 201 void GetDataTypeControllerStates( |
| 214 browser_sync::DataTypeController::StateMap* state_map) const; | 202 browser_sync::DataTypeController::StateMap* state_map) const; |
| 215 | 203 |
| 216 // Disables sync for user. Use ShowLoginDialog to enable. | 204 // Disables sync for user. Use ShowLoginDialog to enable. |
| 217 virtual void DisableForUser(); | 205 virtual void DisableForUser(); |
| 218 | 206 |
| 219 // Clears all Chromesync data from the server. | |
| 220 void ClearServerData(); | |
| 221 | |
| 222 // Whether sync is enabled by user or not. | 207 // Whether sync is enabled by user or not. |
| 223 virtual bool HasSyncSetupCompleted() const; | 208 virtual bool HasSyncSetupCompleted() const; |
| 224 virtual void SetSyncSetupCompleted(); | 209 virtual void SetSyncSetupCompleted(); |
| 225 | 210 |
| 226 // SyncFrontend implementation. | 211 // SyncFrontend implementation. |
| 227 virtual void OnBackendInitialized( | 212 virtual void OnBackendInitialized( |
| 228 const browser_sync::WeakHandle<browser_sync::JsBackend>& js_backend, | 213 const browser_sync::WeakHandle<browser_sync::JsBackend>& js_backend, |
| 229 bool success) OVERRIDE; | 214 bool success) OVERRIDE; |
| 230 virtual void OnSyncCycleCompleted() OVERRIDE; | 215 virtual void OnSyncCycleCompleted() OVERRIDE; |
| 231 virtual void OnSyncConfigureRetry() OVERRIDE; | 216 virtual void OnSyncConfigureRetry() OVERRIDE; |
| 232 virtual void OnConnectionStatusChange( | 217 virtual void OnConnectionStatusChange( |
| 233 sync_api::ConnectionStatus status) OVERRIDE; | 218 sync_api::ConnectionStatus status) OVERRIDE; |
| 234 virtual void OnStopSyncingPermanently() OVERRIDE; | 219 virtual void OnStopSyncingPermanently() OVERRIDE; |
| 235 virtual void OnClearServerDataFailed() OVERRIDE; | |
| 236 virtual void OnClearServerDataSucceeded() OVERRIDE; | |
| 237 virtual void OnPassphraseRequired( | 220 virtual void OnPassphraseRequired( |
| 238 sync_api::PassphraseRequiredReason reason, | 221 sync_api::PassphraseRequiredReason reason, |
| 239 const sync_pb::EncryptedData& pending_keys) OVERRIDE; | 222 const sync_pb::EncryptedData& pending_keys) OVERRIDE; |
| 240 virtual void OnPassphraseAccepted() OVERRIDE; | 223 virtual void OnPassphraseAccepted() OVERRIDE; |
| 241 virtual void OnEncryptedTypesChanged( | 224 virtual void OnEncryptedTypesChanged( |
| 242 syncable::ModelTypeSet encrypted_types, | 225 syncable::ModelTypeSet encrypted_types, |
| 243 bool encrypt_everything) OVERRIDE; | 226 bool encrypt_everything) OVERRIDE; |
| 244 virtual void OnEncryptionComplete() OVERRIDE; | 227 virtual void OnEncryptionComplete() OVERRIDE; |
| 245 virtual void OnMigrationNeededForTypes( | 228 virtual void OnMigrationNeededForTypes( |
| 246 syncable::ModelTypeSet types) OVERRIDE; | 229 syncable::ModelTypeSet types) OVERRIDE; |
| 247 virtual void OnExperimentsChanged( | 230 virtual void OnExperimentsChanged( |
| 248 const browser_sync::Experiments& experiments) OVERRIDE; | 231 const browser_sync::Experiments& experiments) OVERRIDE; |
| 249 virtual void OnActionableError( | 232 virtual void OnActionableError( |
| 250 const browser_sync::SyncProtocolError& error) OVERRIDE; | 233 const browser_sync::SyncProtocolError& error) OVERRIDE; |
| 251 | 234 |
| 252 void OnClearServerDataTimeout(); | |
| 253 | |
| 254 // Update the last auth error and notify observers of error state. | 235 // Update the last auth error and notify observers of error state. |
| 255 void UpdateAuthErrorState(const GoogleServiceAuthError& error); | 236 void UpdateAuthErrorState(const GoogleServiceAuthError& error); |
| 256 | 237 |
| 257 // Called when a user chooses which data types to sync as part of the sync | 238 // Called when a user chooses which data types to sync as part of the sync |
| 258 // setup wizard. |sync_everything| represents whether they chose the | 239 // setup wizard. |sync_everything| represents whether they chose the |
| 259 // "keep everything synced" option; if true, |chosen_types| will be ignored | 240 // "keep everything synced" option; if true, |chosen_types| will be ignored |
| 260 // and all data types will be synced. |sync_everything| means "sync all | 241 // and all data types will be synced. |sync_everything| means "sync all |
| 261 // current and future data types." | 242 // current and future data types." |
| 262 virtual void OnUserChoseDatatypes(bool sync_everything, | 243 virtual void OnUserChoseDatatypes(bool sync_everything, |
| 263 syncable::ModelTypeSet chosen_types); | 244 syncable::ModelTypeSet chosen_types); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 // DataTypeManager in the event that the server informed us to cease and | 694 // DataTypeManager in the event that the server informed us to cease and |
| 714 // desist syncing immediately. | 695 // desist syncing immediately. |
| 715 bool expect_sync_configuration_aborted_; | 696 bool expect_sync_configuration_aborted_; |
| 716 | 697 |
| 717 // Sometimes we need to temporarily hold on to a passphrase because we don't | 698 // Sometimes we need to temporarily hold on to a passphrase because we don't |
| 718 // yet have a backend to send it to. This happens during initialization as | 699 // yet have a backend to send it to. This happens during initialization as |
| 719 // we don't StartUp until we have a valid token, which happens after valid | 700 // we don't StartUp until we have a valid token, which happens after valid |
| 720 // credentials were provided. | 701 // credentials were provided. |
| 721 std::string cached_passphrase_; | 702 std::string cached_passphrase_; |
| 722 | 703 |
| 723 // Keep track of where we are in a server clear operation | |
| 724 ClearServerDataState clear_server_data_state_; | |
| 725 | |
| 726 // Timeout for the clear data command. This timeout is a temporary hack | |
| 727 // and is necessary because the nudge sync framework can drop nudges for | |
| 728 // a wide variety of sync-related conditions (throttling, connections issues, | |
| 729 // syncer paused, etc.). It can only be removed correctly when the framework | |
| 730 // is reworked to allow one-shot commands like clearing server data. | |
| 731 base::OneShotTimer<ProfileSyncService> clear_server_data_timer_; | |
| 732 | |
| 733 // The current set of encrypted types. Always a superset of | 704 // The current set of encrypted types. Always a superset of |
| 734 // Cryptographer::SensitiveTypes(). | 705 // Cryptographer::SensitiveTypes(). |
| 735 syncable::ModelTypeSet encrypted_types_; | 706 syncable::ModelTypeSet encrypted_types_; |
| 736 | 707 |
| 737 // Whether we want to encrypt everything. | 708 // Whether we want to encrypt everything. |
| 738 bool encrypt_everything_; | 709 bool encrypt_everything_; |
| 739 | 710 |
| 740 // Whether we're waiting for an attempt to encryption all sync data to | 711 // Whether we're waiting for an attempt to encryption all sync data to |
| 741 // complete. We track this at this layer in order to allow the user to cancel | 712 // complete. We track this at this layer in order to allow the user to cancel |
| 742 // if they e.g. don't remember their explicit passphrase. | 713 // if they e.g. don't remember their explicit passphrase. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 773 browser_sync::Experiments current_experiments; | 744 browser_sync::Experiments current_experiments; |
| 774 | 745 |
| 775 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 746 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 776 }; | 747 }; |
| 777 | 748 |
| 778 bool ShouldShowActionOnUI( | 749 bool ShouldShowActionOnUI( |
| 779 const browser_sync::SyncProtocolError& error); | 750 const browser_sync::SyncProtocolError& error); |
| 780 | 751 |
| 781 | 752 |
| 782 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 753 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |