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 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // Sync server URL for dev channel users | 268 // Sync server URL for dev channel users |
269 static const char* kDevServerUrl; | 269 static const char* kDevServerUrl; |
270 | 270 |
271 // Takes ownership of |factory| and |signin_wrapper|. | 271 // Takes ownership of |factory| and |signin_wrapper|. |
272 ProfileSyncService( | 272 ProfileSyncService( |
273 scoped_ptr<ProfileSyncComponentsFactory> factory, | 273 scoped_ptr<ProfileSyncComponentsFactory> factory, |
274 Profile* profile, | 274 Profile* profile, |
275 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, | 275 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, |
276 ProfileOAuth2TokenService* oauth2_token_service, | 276 ProfileOAuth2TokenService* oauth2_token_service, |
277 browser_sync::ProfileSyncServiceStartBehavior start_behavior); | 277 browser_sync::ProfileSyncServiceStartBehavior start_behavior); |
278 virtual ~ProfileSyncService(); | 278 ~ProfileSyncService() override; |
279 | 279 |
280 // Initializes the object. This must be called at most once, and | 280 // Initializes the object. This must be called at most once, and |
281 // immediately after an object of this class is constructed. | 281 // immediately after an object of this class is constructed. |
282 void Initialize(); | 282 void Initialize(); |
283 | 283 |
284 virtual void SetSyncSetupCompleted(); | 284 virtual void SetSyncSetupCompleted(); |
285 | 285 |
286 // ProfileSyncServiceBase implementation. | 286 // ProfileSyncServiceBase implementation. |
287 virtual bool HasSyncSetupCompleted() const override; | 287 bool HasSyncSetupCompleted() const override; |
288 virtual bool SyncActive() const override; | 288 bool SyncActive() const override; |
289 virtual syncer::ModelTypeSet GetActiveDataTypes() const override; | 289 syncer::ModelTypeSet GetActiveDataTypes() const override; |
290 virtual void AddObserver(ProfileSyncServiceBase::Observer* observer) override; | 290 void AddObserver(ProfileSyncServiceBase::Observer* observer) override; |
291 virtual void RemoveObserver( | 291 void RemoveObserver(ProfileSyncServiceBase::Observer* observer) override; |
292 ProfileSyncServiceBase::Observer* observer) override; | 292 bool HasObserver(ProfileSyncServiceBase::Observer* observer) const override; |
293 virtual bool HasObserver( | |
294 ProfileSyncServiceBase::Observer* observer) const override; | |
295 | 293 |
296 void AddProtocolEventObserver(browser_sync::ProtocolEventObserver* observer); | 294 void AddProtocolEventObserver(browser_sync::ProtocolEventObserver* observer); |
297 void RemoveProtocolEventObserver( | 295 void RemoveProtocolEventObserver( |
298 browser_sync::ProtocolEventObserver* observer); | 296 browser_sync::ProtocolEventObserver* observer); |
299 | 297 |
300 void AddTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); | 298 void AddTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); |
301 void RemoveTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); | 299 void RemoveTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); |
302 | 300 |
303 // Add a sync type preference provider. Each provider may only be added once. | 301 // Add a sync type preference provider. Each provider may only be added once. |
304 void AddPreferenceProvider(SyncTypePreferenceProvider* provider); | 302 void AddPreferenceProvider(SyncTypePreferenceProvider* provider); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 void GetDataTypeControllerStates( | 384 void GetDataTypeControllerStates( |
387 sync_driver::DataTypeController::StateMap* state_map) const; | 385 sync_driver::DataTypeController::StateMap* state_map) const; |
388 | 386 |
389 // Disables sync for user. Use ShowLoginDialog to enable. | 387 // Disables sync for user. Use ShowLoginDialog to enable. |
390 virtual void DisableForUser(); | 388 virtual void DisableForUser(); |
391 | 389 |
392 // Disables sync for the user and prevents it from starting on next restart. | 390 // Disables sync for the user and prevents it from starting on next restart. |
393 virtual void StopSyncingPermanently(); | 391 virtual void StopSyncingPermanently(); |
394 | 392 |
395 // SyncFrontend implementation. | 393 // SyncFrontend implementation. |
396 virtual void OnBackendInitialized( | 394 void OnBackendInitialized( |
397 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 395 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
398 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 396 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
399 debug_info_listener, | 397 debug_info_listener, |
400 const std::string& cache_guid, | 398 const std::string& cache_guid, |
401 bool success) override; | 399 bool success) override; |
402 virtual void OnSyncCycleCompleted() override; | 400 void OnSyncCycleCompleted() override; |
403 virtual void OnProtocolEvent(const syncer::ProtocolEvent& event) override; | 401 void OnProtocolEvent(const syncer::ProtocolEvent& event) override; |
404 virtual void OnDirectoryTypeCommitCounterUpdated( | 402 void OnDirectoryTypeCommitCounterUpdated( |
405 syncer::ModelType type, | 403 syncer::ModelType type, |
406 const syncer::CommitCounters& counters) override; | 404 const syncer::CommitCounters& counters) override; |
407 virtual void OnDirectoryTypeUpdateCounterUpdated( | 405 void OnDirectoryTypeUpdateCounterUpdated( |
408 syncer::ModelType type, | 406 syncer::ModelType type, |
409 const syncer::UpdateCounters& counters) override; | 407 const syncer::UpdateCounters& counters) override; |
410 virtual void OnDirectoryTypeStatusCounterUpdated( | 408 void OnDirectoryTypeStatusCounterUpdated( |
411 syncer::ModelType type, | 409 syncer::ModelType type, |
412 const syncer::StatusCounters& counters) override; | 410 const syncer::StatusCounters& counters) override; |
413 virtual void OnConnectionStatusChange( | 411 void OnConnectionStatusChange(syncer::ConnectionStatus status) override; |
414 syncer::ConnectionStatus status) override; | 412 void OnPassphraseRequired( |
415 virtual void OnPassphraseRequired( | |
416 syncer::PassphraseRequiredReason reason, | 413 syncer::PassphraseRequiredReason reason, |
417 const sync_pb::EncryptedData& pending_keys) override; | 414 const sync_pb::EncryptedData& pending_keys) override; |
418 virtual void OnPassphraseAccepted() override; | 415 void OnPassphraseAccepted() override; |
419 virtual void OnEncryptedTypesChanged( | 416 void OnEncryptedTypesChanged(syncer::ModelTypeSet encrypted_types, |
420 syncer::ModelTypeSet encrypted_types, | 417 bool encrypt_everything) override; |
421 bool encrypt_everything) override; | 418 void OnEncryptionComplete() override; |
422 virtual void OnEncryptionComplete() override; | 419 void OnMigrationNeededForTypes(syncer::ModelTypeSet types) override; |
423 virtual void OnMigrationNeededForTypes( | 420 void OnExperimentsChanged(const syncer::Experiments& experiments) override; |
424 syncer::ModelTypeSet types) override; | 421 void OnActionableError(const syncer::SyncProtocolError& error) override; |
425 virtual void OnExperimentsChanged( | |
426 const syncer::Experiments& experiments) override; | |
427 virtual void OnActionableError( | |
428 const syncer::SyncProtocolError& error) override; | |
429 | 422 |
430 // DataTypeManagerObserver implementation. | 423 // DataTypeManagerObserver implementation. |
431 virtual void OnConfigureDone( | 424 void OnConfigureDone( |
432 const sync_driver::DataTypeManager::ConfigureResult& result) override; | 425 const sync_driver::DataTypeManager::ConfigureResult& result) override; |
433 virtual void OnConfigureStart() override; | 426 void OnConfigureStart() override; |
434 | 427 |
435 // DataTypeEncryptionHandler implementation. | 428 // DataTypeEncryptionHandler implementation. |
436 virtual bool IsPassphraseRequired() const override; | 429 bool IsPassphraseRequired() const override; |
437 virtual syncer::ModelTypeSet GetEncryptedDataTypes() const override; | 430 syncer::ModelTypeSet GetEncryptedDataTypes() const override; |
438 | 431 |
439 // SigninManagerBase::Observer implementation. | 432 // SigninManagerBase::Observer implementation. |
440 virtual void GoogleSigninSucceeded(const std::string& account_id, | 433 void GoogleSigninSucceeded(const std::string& account_id, |
441 const std::string& username, | 434 const std::string& username, |
442 const std::string& password) override; | 435 const std::string& password) override; |
443 virtual void GoogleSignedOut(const std::string& account_id, | 436 void GoogleSignedOut(const std::string& account_id, |
444 const std::string& username) override; | 437 const std::string& username) override; |
445 | 438 |
446 // Called when a user chooses which data types to sync as part of the sync | 439 // Called when a user chooses which data types to sync as part of the sync |
447 // setup wizard. |sync_everything| represents whether they chose the | 440 // setup wizard. |sync_everything| represents whether they chose the |
448 // "keep everything synced" option; if true, |chosen_types| will be ignored | 441 // "keep everything synced" option; if true, |chosen_types| will be ignored |
449 // and all data types will be synced. |sync_everything| means "sync all | 442 // and all data types will be synced. |sync_everything| means "sync all |
450 // current and future data types." | 443 // current and future data types." |
451 virtual void OnUserChoseDatatypes(bool sync_everything, | 444 virtual void OnUserChoseDatatypes(bool sync_everything, |
452 syncer::ModelTypeSet chosen_types); | 445 syncer::ModelTypeSet chosen_types); |
453 | 446 |
454 // Get the sync status code. | 447 // Get the sync status code. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 // Profile::IsSyncAccessible() is probably a better signal than this function. | 527 // Profile::IsSyncAccessible() is probably a better signal than this function. |
535 // This function can be called from any thread, and the implementation doesn't | 528 // This function can be called from any thread, and the implementation doesn't |
536 // assume it's running on the UI thread. | 529 // assume it's running on the UI thread. |
537 static bool IsSyncEnabled(); | 530 static bool IsSyncEnabled(); |
538 | 531 |
539 // Returns whether sync is managed, i.e. controlled by configuration | 532 // Returns whether sync is managed, i.e. controlled by configuration |
540 // management. If so, the user is not allowed to configure sync. | 533 // management. If so, the user is not allowed to configure sync. |
541 virtual bool IsManaged() const; | 534 virtual bool IsManaged() const; |
542 | 535 |
543 // syncer::UnrecoverableErrorHandler implementation. | 536 // syncer::UnrecoverableErrorHandler implementation. |
544 virtual void OnUnrecoverableError( | 537 void OnUnrecoverableError(const tracked_objects::Location& from_here, |
545 const tracked_objects::Location& from_here, | 538 const std::string& message) override; |
546 const std::string& message) override; | |
547 | 539 |
548 // Called to re-enable a type disabled by DisableDatatype(..). Note, this does | 540 // Called to re-enable a type disabled by DisableDatatype(..). Note, this does |
549 // not change the preferred state of a datatype, and is not persisted across | 541 // not change the preferred state of a datatype, and is not persisted across |
550 // restarts. | 542 // restarts. |
551 void ReenableDatatype(syncer::ModelType type); | 543 void ReenableDatatype(syncer::ModelType type); |
552 | 544 |
553 // The functions below (until ActivateDataType()) should only be | 545 // The functions below (until ActivateDataType()) should only be |
554 // called if backend_initialized() is true. | 546 // called if backend_initialized() is true. |
555 | 547 |
556 // TODO(akalin): This is called mostly by ModelAssociators and | 548 // TODO(akalin): This is called mostly by ModelAssociators and |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 // This function is used by about_sync_util.cc to help populate the about:sync | 586 // This function is used by about_sync_util.cc to help populate the about:sync |
595 // page. It returns a ListValue rather than a DictionaryValue in part to make | 587 // page. It returns a ListValue rather than a DictionaryValue in part to make |
596 // it easier to iterate over its elements when constructing that page. | 588 // it easier to iterate over its elements when constructing that page. |
597 base::Value* GetTypeStatusMap() const; | 589 base::Value* GetTypeStatusMap() const; |
598 | 590 |
599 // Overridden by tests. | 591 // Overridden by tests. |
600 // TODO(zea): Remove these and have the dtc's call directly into the SBH. | 592 // TODO(zea): Remove these and have the dtc's call directly into the SBH. |
601 virtual void DeactivateDataType(syncer::ModelType type); | 593 virtual void DeactivateDataType(syncer::ModelType type); |
602 | 594 |
603 // SyncPrefObserver implementation. | 595 // SyncPrefObserver implementation. |
604 virtual void OnSyncManagedPrefChange(bool is_sync_managed) override; | 596 void OnSyncManagedPrefChange(bool is_sync_managed) override; |
605 | 597 |
606 // Changes which data types we're going to be syncing to |preferred_types|. | 598 // Changes which data types we're going to be syncing to |preferred_types|. |
607 // If it is running, the DataTypeManager will be instructed to reconfigure | 599 // If it is running, the DataTypeManager will be instructed to reconfigure |
608 // the sync backend so that exactly these datatypes are actively synced. See | 600 // the sync backend so that exactly these datatypes are actively synced. See |
609 // class comment for more on what it means for a datatype to be Preferred. | 601 // class comment for more on what it means for a datatype to be Preferred. |
610 virtual void ChangePreferredDataTypes( | 602 virtual void ChangePreferredDataTypes( |
611 syncer::ModelTypeSet preferred_types); | 603 syncer::ModelTypeSet preferred_types); |
612 | 604 |
613 // Returns the set of types which are preferred for enabling. This is a | 605 // Returns the set of types which are preferred for enabling. This is a |
614 // superset of the active types (see GetActiveDataTypes()). | 606 // superset of the active types (see GetActiveDataTypes()). |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 // succeeded, and is waiting for initialization to complete. This is used by | 712 // succeeded, and is waiting for initialization to complete. This is used by |
721 // the UI to differentiate between a new auth error (encountered as part of | 713 // the UI to differentiate between a new auth error (encountered as part of |
722 // the initialization process) and a pre-existing auth error that just hasn't | 714 // the initialization process) and a pre-existing auth error that just hasn't |
723 // been cleared yet. Virtual for testing purposes. | 715 // been cleared yet. Virtual for testing purposes. |
724 virtual bool waiting_for_auth() const; | 716 virtual bool waiting_for_auth() const; |
725 | 717 |
726 // The set of currently enabled sync experiments. | 718 // The set of currently enabled sync experiments. |
727 const syncer::Experiments& current_experiments() const; | 719 const syncer::Experiments& current_experiments() const; |
728 | 720 |
729 // OAuth2TokenService::Consumer implementation. | 721 // OAuth2TokenService::Consumer implementation. |
730 virtual void OnGetTokenSuccess( | 722 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
731 const OAuth2TokenService::Request* request, | 723 const std::string& access_token, |
732 const std::string& access_token, | 724 const base::Time& expiration_time) override; |
733 const base::Time& expiration_time) override; | 725 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
734 virtual void OnGetTokenFailure( | 726 const GoogleServiceAuthError& error) override; |
735 const OAuth2TokenService::Request* request, | |
736 const GoogleServiceAuthError& error) override; | |
737 | 727 |
738 // OAuth2TokenService::Observer implementation. | 728 // OAuth2TokenService::Observer implementation. |
739 virtual void OnRefreshTokenAvailable(const std::string& account_id) override; | 729 void OnRefreshTokenAvailable(const std::string& account_id) override; |
740 virtual void OnRefreshTokenRevoked(const std::string& account_id) override; | 730 void OnRefreshTokenRevoked(const std::string& account_id) override; |
741 virtual void OnRefreshTokensLoaded() override; | 731 void OnRefreshTokensLoaded() override; |
742 | 732 |
743 // KeyedService implementation. This must be called exactly | 733 // KeyedService implementation. This must be called exactly |
744 // once (before this object is destroyed). | 734 // once (before this object is destroyed). |
745 virtual void Shutdown() override; | 735 void Shutdown() override; |
746 | 736 |
747 // Called when a datatype (SyncableService) has a need for sync to start | 737 // Called when a datatype (SyncableService) has a need for sync to start |
748 // ASAP, presumably because a local change event has occurred but we're | 738 // ASAP, presumably because a local change event has occurred but we're |
749 // still in deferred start mode, meaning the SyncableService hasn't been | 739 // still in deferred start mode, meaning the SyncableService hasn't been |
750 // told to MergeDataAndStartSyncing yet. | 740 // told to MergeDataAndStartSyncing yet. |
751 void OnDataTypeRequestsSyncStartup(syncer::ModelType type); | 741 void OnDataTypeRequestsSyncStartup(syncer::ModelType type); |
752 | 742 |
753 // Return sync token status. | 743 // Return sync token status. |
754 SyncTokenStatus GetSyncTokenStatus() const; | 744 SyncTokenStatus GetSyncTokenStatus() const; |
755 | 745 |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 BrowsingDataRemover::Observer* browsing_data_remover_observer_; | 1151 BrowsingDataRemover::Observer* browsing_data_remover_observer_; |
1162 | 1152 |
1163 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1153 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
1164 }; | 1154 }; |
1165 | 1155 |
1166 bool ShouldShowActionOnUI( | 1156 bool ShouldShowActionOnUI( |
1167 const syncer::SyncProtocolError& error); | 1157 const syncer::SyncProtocolError& error); |
1168 | 1158 |
1169 | 1159 |
1170 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 1160 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |