Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4595)

Unified Diff: chrome/browser/supervised_user/supervised_user_service.cc

Issue 480513004: Stopping the history recording for a supervised user (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..27c45f62f3a2700fb6661b75c25dc2fabf94b56a 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),
+ : may_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 (MaySyncSessions())
+ 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) {
Marc Treib 2014/08/19 14:00:27 Indent 4 spaces only. You can also try "git cl for
+ bool has_session_sync_state_changed = FetchNewSessionSyncState(settings);
+ if (has_session_sync_state_changed) {
+ ReinitializeProfileSyncService();
+ }
+}
+
+bool SupervisedUserService::FetchNewSessionSyncState(
+ const base::DictionaryValue* settings) {
Marc Treib 2014/08/19 14:00:27 ^^
+ bool old_may_session_sync_ = may_session_sync_;
Marc Treib 2014/08/19 14:00:27 No trailing underscore on local variable.
+ const base::Value* value = NULL;
+ if (settings &&
Marc Treib 2014/08/19 14:00:27 Can settings be null here? If so, please add a com
+ settings->GetWithoutPathExpansion(supervised_users::kRecordHistory,
+ &value))
+ value->GetAsBoolean(&may_session_sync_);
+ return old_may_session_sync_ != may_session_sync_;
+}
+
+void SupervisedUserService::ReinitializeProfileSyncService() {
+ ProfileSyncService* sync_service =
+ ProfileSyncServiceFactory::GetForProfile(profile_);
+ if (!sync_service->sync_initialized())
Marc Treib 2014/08/19 14:00:27 Also check sync_service->setup_in_progress() ?
+ return;
+ // The following lines force the ProfileSyncService to reload its changed data
+ sync_service->SetSetupInProgress(true);
+ sync_service->SetSetupInProgress(false);
+}
+
+bool SupervisedUserService::MaySyncSessions() const {
+ return may_session_sync_;
+}
+
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,
+ weak_ptr_factory_.GetWeakPtr()));
+
#if defined(ENABLE_EXTENSIONS)
SetExtensionsActive();
#endif

Powered by Google App Engine
This is Rietveld 408576698