| 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 #include "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
| 38 #include "chrome/browser/signin/about_signin_internals_factory.h" | 38 #include "chrome/browser/signin/about_signin_internals_factory.h" |
| 39 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 39 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 40 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 40 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 41 #include "chrome/browser/signin/signin_manager_factory.h" | 41 #include "chrome/browser/signin/signin_manager_factory.h" |
| 42 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" | 42 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" |
| 43 #include "chrome/browser/sync/glue/sync_backend_host.h" | 43 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 44 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" | 44 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" |
| 45 #include "chrome/browser/sync/glue/sync_start_util.h" | 45 #include "chrome/browser/sync/glue/sync_start_util.h" |
| 46 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" | 46 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" |
| 47 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | |
| 48 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" | 47 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" |
| 49 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 48 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
| 50 #include "chrome/browser/sync/sync_type_preference_provider.h" | 49 #include "chrome/browser/sync/sync_type_preference_provider.h" |
| 51 #include "chrome/browser/ui/browser.h" | 50 #include "chrome/browser/ui/browser.h" |
| 52 #include "chrome/browser/ui/browser_list.h" | 51 #include "chrome/browser/ui/browser_list.h" |
| 53 #include "chrome/browser/ui/browser_window.h" | 52 #include "chrome/browser/ui/browser_window.h" |
| 54 #include "chrome/browser/ui/global_error/global_error_service.h" | 53 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 55 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 54 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 56 #include "chrome/common/chrome_switches.h" | 55 #include "chrome/common/chrome_switches.h" |
| 57 #include "chrome/common/pref_names.h" | 56 #include "chrome/common/pref_names.h" |
| 58 #include "chrome/common/sync_util.h" | 57 #include "chrome/common/sync_util.h" |
| 59 #include "chrome/common/url_constants.h" | 58 #include "chrome/common/url_constants.h" |
| 60 #include "chrome/grit/generated_resources.h" | 59 #include "chrome/grit/generated_resources.h" |
| 61 #include "components/autofill/core/common/autofill_pref_names.h" | 60 #include "components/autofill/core/common/autofill_pref_names.h" |
| 62 #include "components/invalidation/impl/profile_invalidation_provider.h" | 61 #include "components/invalidation/impl/profile_invalidation_provider.h" |
| 63 #include "components/invalidation/public/invalidation_service.h" | 62 #include "components/invalidation/public/invalidation_service.h" |
| 64 #include "components/password_manager/core/browser/password_store.h" | 63 #include "components/password_manager/core/browser/password_store.h" |
| 65 #include "components/pref_registry/pref_registry_syncable.h" | 64 #include "components/pref_registry/pref_registry_syncable.h" |
| 66 #include "components/signin/core/browser/about_signin_internals.h" | 65 #include "components/signin/core/browser/about_signin_internals.h" |
| 67 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 66 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 68 #include "components/signin/core/browser/signin_manager.h" | 67 #include "components/signin/core/browser/signin_manager.h" |
| 69 #include "components/signin/core/browser/signin_metrics.h" | 68 #include "components/signin/core/browser/signin_metrics.h" |
| 70 #include "components/sync_driver/backend_migrator.h" | 69 #include "components/sync_driver/backend_migrator.h" |
| 71 #include "components/sync_driver/change_processor.h" | 70 #include "components/sync_driver/change_processor.h" |
| 72 #include "components/sync_driver/data_type_controller.h" | 71 #include "components/sync_driver/data_type_controller.h" |
| 73 #include "components/sync_driver/device_info.h" | 72 #include "components/sync_driver/device_info.h" |
| 74 #include "components/sync_driver/favicon_cache.h" | 73 #include "components/sync_driver/favicon_cache.h" |
| 75 #include "components/sync_driver/pref_names.h" | 74 #include "components/sync_driver/pref_names.h" |
| 75 #include "components/sync_driver/sync_api_component_factory.h" |
| 76 #include "components/sync_driver/sync_error_controller.h" | 76 #include "components/sync_driver/sync_error_controller.h" |
| 77 #include "components/sync_driver/sync_stopped_reporter.h" | 77 #include "components/sync_driver/sync_stopped_reporter.h" |
| 78 #include "components/sync_driver/system_encryptor.h" | 78 #include "components/sync_driver/system_encryptor.h" |
| 79 #include "components/sync_driver/user_selectable_sync_type.h" | 79 #include "components/sync_driver/user_selectable_sync_type.h" |
| 80 #include "components/version_info/version_info_values.h" | 80 #include "components/version_info/version_info_values.h" |
| 81 #include "content/public/browser/browser_thread.h" | 81 #include "content/public/browser/browser_thread.h" |
| 82 #include "content/public/browser/notification_details.h" | 82 #include "content/public/browser/notification_details.h" |
| 83 #include "content/public/browser/notification_service.h" | 83 #include "content/public/browser/notification_service.h" |
| 84 #include "content/public/browser/notification_source.h" | 84 #include "content/public/browser/notification_source.h" |
| 85 #include "net/cookies/cookie_monster.h" | 85 #include "net/cookies/cookie_monster.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } // anonymous namespace | 197 } // anonymous namespace |
| 198 | 198 |
| 199 bool ShouldShowActionOnUI( | 199 bool ShouldShowActionOnUI( |
| 200 const syncer::SyncProtocolError& error) { | 200 const syncer::SyncProtocolError& error) { |
| 201 return (error.action != syncer::UNKNOWN_ACTION && | 201 return (error.action != syncer::UNKNOWN_ACTION && |
| 202 error.action != syncer::DISABLE_SYNC_ON_CLIENT && | 202 error.action != syncer::DISABLE_SYNC_ON_CLIENT && |
| 203 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT); | 203 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT); |
| 204 } | 204 } |
| 205 | 205 |
| 206 ProfileSyncService::ProfileSyncService( | 206 ProfileSyncService::ProfileSyncService( |
| 207 scoped_ptr<ProfileSyncComponentsFactory> factory, | 207 scoped_ptr<sync_driver::SyncApiComponentFactory> factory, |
| 208 Profile* profile, | 208 Profile* profile, |
| 209 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, | 209 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, |
| 210 ProfileOAuth2TokenService* oauth2_token_service, | 210 ProfileOAuth2TokenService* oauth2_token_service, |
| 211 ProfileSyncServiceStartBehavior start_behavior) | 211 ProfileSyncServiceStartBehavior start_behavior) |
| 212 : OAuth2TokenService::Consumer("sync"), | 212 : OAuth2TokenService::Consumer("sync"), |
| 213 last_auth_error_(AuthError::AuthErrorNone()), | 213 last_auth_error_(AuthError::AuthErrorNone()), |
| 214 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), | 214 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), |
| 215 factory_(factory.Pass()), | 215 factory_(factory.Pass()), |
| 216 profile_(profile), | 216 profile_(profile), |
| 217 sync_prefs_(profile_->GetPrefs()), | 217 sync_prefs_(profile_->GetPrefs()), |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 signin()->AddObserver(this); | 426 signin()->AddObserver(this); |
| 427 } | 427 } |
| 428 | 428 |
| 429 void ProfileSyncService::UnregisterAuthNotifications() { | 429 void ProfileSyncService::UnregisterAuthNotifications() { |
| 430 if (signin()) | 430 if (signin()) |
| 431 signin()->RemoveObserver(this); | 431 signin()->RemoveObserver(this); |
| 432 oauth2_token_service_->RemoveObserver(this); | 432 oauth2_token_service_->RemoveObserver(this); |
| 433 } | 433 } |
| 434 | 434 |
| 435 void ProfileSyncService::RegisterDataTypeController( | 435 void ProfileSyncService::RegisterDataTypeController( |
| 436 DataTypeController* data_type_controller) { | 436 sync_driver::DataTypeController* data_type_controller) { |
| 437 DCHECK_EQ( | 437 DCHECK_EQ( |
| 438 directory_data_type_controllers_.count(data_type_controller->type()), | 438 directory_data_type_controllers_.count(data_type_controller->type()), |
| 439 0U); | 439 0U); |
| 440 DCHECK(!GetRegisteredNonBlockingDataTypes().Has( | 440 DCHECK(!GetRegisteredNonBlockingDataTypes().Has( |
| 441 data_type_controller->type())); | 441 data_type_controller->type())); |
| 442 directory_data_type_controllers_[data_type_controller->type()] = | 442 directory_data_type_controllers_[data_type_controller->type()] = |
| 443 data_type_controller; | 443 data_type_controller; |
| 444 } | 444 } |
| 445 | 445 |
| 446 void ProfileSyncService::RegisterNonBlockingType(syncer::ModelType type) { | 446 void ProfileSyncService::RegisterNonBlockingType(syncer::ModelType type) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 ProfileSyncService::GetSyncedWindowDelegatesGetter() const { | 485 ProfileSyncService::GetSyncedWindowDelegatesGetter() const { |
| 486 return sessions_sync_manager_->GetSyncedWindowDelegatesGetter(); | 486 return sessions_sync_manager_->GetSyncedWindowDelegatesGetter(); |
| 487 } | 487 } |
| 488 | 488 |
| 489 sync_driver::DeviceInfoTracker* ProfileSyncService::GetDeviceInfoTracker() | 489 sync_driver::DeviceInfoTracker* ProfileSyncService::GetDeviceInfoTracker() |
| 490 const { | 490 const { |
| 491 return device_info_sync_service_.get(); | 491 return device_info_sync_service_.get(); |
| 492 } | 492 } |
| 493 | 493 |
| 494 sync_driver::LocalDeviceInfoProvider* | 494 sync_driver::LocalDeviceInfoProvider* |
| 495 ProfileSyncService::GetLocalDeviceInfoProvider() { | 495 ProfileSyncService::GetLocalDeviceInfoProvider() const { |
| 496 return local_device_.get(); | 496 return local_device_.get(); |
| 497 } | 497 } |
| 498 | 498 |
| 499 void ProfileSyncService::GetDataTypeControllerStates( | 499 void ProfileSyncService::GetDataTypeControllerStates( |
| 500 DataTypeController::StateMap* state_map) const { | 500 DataTypeController::StateMap* state_map) const { |
| 501 for (DataTypeController::TypeMap::const_iterator iter = | 501 for (DataTypeController::TypeMap::const_iterator iter = |
| 502 directory_data_type_controllers_.begin(); | 502 directory_data_type_controllers_.begin(); |
| 503 iter != directory_data_type_controllers_.end(); | 503 iter != directory_data_type_controllers_.end(); |
| 504 ++iter) | 504 ++iter) |
| 505 (*state_map)[iter->first] = iter->second.get()->state(); | 505 (*state_map)[iter->first] = iter->second.get()->state(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 profile_); | 703 profile_); |
| 704 if (provider) | 704 if (provider) |
| 705 invalidator = provider->GetInvalidationService(); | 705 invalidator = provider->GetInvalidationService(); |
| 706 } | 706 } |
| 707 | 707 |
| 708 directory_path_ = profile_->GetPath().Append(sync_folder); | 708 directory_path_ = profile_->GetPath().Append(sync_folder); |
| 709 | 709 |
| 710 backend_.reset( | 710 backend_.reset( |
| 711 factory_->CreateSyncBackendHost( | 711 factory_->CreateSyncBackendHost( |
| 712 profile_->GetDebugName(), | 712 profile_->GetDebugName(), |
| 713 profile_, | |
| 714 invalidator, | 713 invalidator, |
| 715 sync_prefs_.AsWeakPtr(), | 714 sync_prefs_.AsWeakPtr(), |
| 716 sync_folder)); | 715 sync_folder)); |
| 717 | 716 |
| 718 // Initialize the backend. Every time we start up a new SyncBackendHost, | 717 // Initialize the backend. Every time we start up a new SyncBackendHost, |
| 719 // we'll want to start from a fresh SyncDB, so delete any old one that might | 718 // we'll want to start from a fresh SyncDB, so delete any old one that might |
| 720 // be there. | 719 // be there. |
| 721 InitializeBackend(ShouldDeleteSyncFolder()); | 720 InitializeBackend(ShouldDeleteSyncFolder()); |
| 722 | 721 |
| 723 UpdateFirstSyncTimePref(); | 722 UpdateFirstSyncTimePref(); |
| (...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2793 } else { | 2792 } else { |
| 2794 UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCleanShutdown", | 2793 UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCleanShutdown", |
| 2795 warning_received); | 2794 warning_received); |
| 2796 } | 2795 } |
| 2797 } | 2796 } |
| 2798 sync_prefs_.SetMemoryPressureWarningCount(0); | 2797 sync_prefs_.SetMemoryPressureWarningCount(0); |
| 2799 // Will set to true during a clean shutdown, so crash or something else will | 2798 // Will set to true during a clean shutdown, so crash or something else will |
| 2800 // remain this as false. | 2799 // remain this as false. |
| 2801 sync_prefs_.SetCleanShutdown(false); | 2800 sync_prefs_.SetCleanShutdown(false); |
| 2802 } | 2801 } |
| OLD | NEW |