Chromium Code Reviews| Index: chrome/browser/supervised_user/supervised_user_service.cc |
| diff --git a/chrome/browser/supervised_user/supervised_user_service.cc b/chrome/browser/supervised_user/supervised_user_service.cc |
| index 8b45a60a84a11951dcdffcfeebc45f1185df2bdc..e12c753bc5102da93f619703013ef7dc553be564 100644 |
| --- a/chrome/browser/supervised_user/supervised_user_service.cc |
| +++ b/chrome/browser/supervised_user/supervised_user_service.cc |
| @@ -132,7 +132,8 @@ void SupervisedUserService::URLFilterContext::SetManualURLs( |
| } |
| SupervisedUserService::SupervisedUserService(Profile* profile) |
| - : profile_(profile), |
| + : includes_session_sync_(true), |
| + profile_(profile), |
| active_(false), |
| delegate_(NULL), |
| #if defined(ENABLE_EXTENSIONS) |
| @@ -359,7 +360,8 @@ syncer::ModelTypeSet SupervisedUserService::GetPreferredDataTypes() const { |
| return syncer::ModelTypeSet(); |
| syncer::ModelTypeSet result; |
| - result.Put(syncer::SESSIONS); |
| + if (IncludesSyncSessions()) |
| + result.Put(syncer::SESSIONS); |
| result.Put(syncer::EXTENSIONS); |
| result.Put(syncer::EXTENSION_SETTINGS); |
| result.Put(syncer::APPS); |
| @@ -369,6 +371,39 @@ syncer::ModelTypeSet SupervisedUserService::GetPreferredDataTypes() const { |
| return result; |
| } |
| +void SupervisedUserService::OnNewSettingsAvailable( |
| + const base::DictionaryValue* settings) { |
| + bool has_session_sync_state_changed = FetchNewSessionSyncState(settings); |
| + if (has_session_sync_state_changed) { |
|
Bernhard Bauer
2014/08/19 17:11:13
Nit: braces around one-line bodies are unnecessary
fhorschig
2014/08/20 11:59:29
Done.
|
| + ReconfigureProfileSyncService(); |
| + } |
| +} |
| + |
| +bool SupervisedUserService::FetchNewSessionSyncState( |
| + const base::DictionaryValue* settings) { |
| + bool old_includes_session_sync = includes_session_sync_; |
| + const base::Value* value = NULL; |
| + if (settings && // gets NULL when settings service is destroyed |
|
Marc Treib
2014/08/19 15:28:01
How does this method get called after the settings
fhorschig
2014/08/20 11:59:29
Not after: when. Apparently, the Callback gets cal
|
| + settings->GetWithoutPathExpansion(supervised_users::kRecordHistory, |
|
Bernhard Bauer
2014/08/19 17:11:13
The "...WithoutPathExpansion" is unnecessary if th
fhorschig
2014/08/20 11:59:29
Done.
|
| + &value)) |
| + value->GetAsBoolean(&includes_session_sync_); |
| + return old_includes_session_sync != includes_session_sync_; |
| +} |
| + |
| +void SupervisedUserService::ReconfigureProfileSyncService() { |
| + ProfileSyncService* sync_service = |
| + ProfileSyncServiceFactory::GetForProfile(profile_); |
| + if (!sync_service->sync_initialized() || sync_service->setup_in_progress()) |
| + return; |
| + // The following lines force the ProfileSyncService to reload its changed data |
|
Marc Treib
2014/08/19 15:28:01
"reload its changed data" is unprecise/unclear. "T
Pam (message me for reviews)
2014/08/19 20:17:16
Also, surely there's a cleaner way to trigger the
Marc Treib
2014/08/20 10:04:55
As far as I can tell, there's currently no other w
fhorschig
2014/08/20 11:59:29
I found another method called "ReconfigureDataType
|
| + sync_service->SetSetupInProgress(true); |
| + sync_service->SetSetupInProgress(false); |
| +} |
| + |
| +bool SupervisedUserService::IncludesSyncSessions() const { |
| + return includes_session_sync_; |
|
Pam (message me for reviews)
2014/08/19 20:17:16
Please use consistent naming: either IncludesSessi
fhorschig
2014/08/20 11:59:30
Done.
|
| +} |
| + |
| void SupervisedUserService::OnStateChanged() { |
| ProfileSyncService* service = |
| ProfileSyncServiceFactory::GetForProfile(profile_); |
| @@ -657,6 +692,10 @@ void SupervisedUserService::SetActive(bool active) { |
| SupervisedUserSettingsService* settings_service = GetSettingsService(); |
| settings_service->SetActive(active_); |
| + settings_service->Subscribe( |
| + base::Bind(&SupervisedUserService::OnNewSettingsAvailable, |
|
Bernhard Bauer
2014/08/19 17:11:13
Instead of subscribing to the SU settings, you cou
|
| + weak_ptr_factory_.GetWeakPtr())); |
| + |
| #if defined(ENABLE_EXTENSIONS) |
| SetExtensionsActive(); |
| #endif |