Commit 1f351f00 authored by fhorschig's avatar fhorschig Committed by Commit bot

Stopping the history recording for a supervised user

The custodian will soon be able to stop history recording for each of his supervised users. Reenabling the history for existing supervised user accounts relies on another sync commit of the supervised user (e.g. permission request; alternatively new setup of the supervised user).

BUG=232316

Review URL: https://codereview.chromium.org/480513004

Cr-Commit-Position: refs/heads/master@{#297411}
parent bb156a04
...@@ -320,6 +320,10 @@ void ProfileImpl::RegisterProfilePrefs( ...@@ -320,6 +320,10 @@ void ProfileImpl::RegisterProfilePrefs(
prefs::kForceSafeSearch, prefs::kForceSafeSearch,
false, false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kRecordHistory,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterIntegerPref( registry->RegisterIntegerPref(
prefs::kProfileAvatarIndex, prefs::kProfileAvatarIndex,
-1, -1,
......
...@@ -11,6 +11,7 @@ const char kContentPackDefaultFilteringBehavior[] = ...@@ -11,6 +11,7 @@ const char kContentPackDefaultFilteringBehavior[] =
const char kContentPackManualBehaviorHosts[] = "ContentPackManualBehaviorHosts"; const char kContentPackManualBehaviorHosts[] = "ContentPackManualBehaviorHosts";
const char kContentPackManualBehaviorURLs[] = "ContentPackManualBehaviorURLs"; const char kContentPackManualBehaviorURLs[] = "ContentPackManualBehaviorURLs";
const char kForceSafeSearch[] = "ForceSafeSearch"; const char kForceSafeSearch[] = "ForceSafeSearch";
const char kRecordHistory[] = "RecordHistory";
const char kSigninAllowed[] = "SigninAllowed"; const char kSigninAllowed[] = "SigninAllowed";
const char kUserName[] = "UserName"; const char kUserName[] = "UserName";
......
...@@ -13,6 +13,7 @@ extern const char kContentPackDefaultFilteringBehavior[]; ...@@ -13,6 +13,7 @@ extern const char kContentPackDefaultFilteringBehavior[];
extern const char kContentPackManualBehaviorHosts[]; extern const char kContentPackManualBehaviorHosts[];
extern const char kContentPackManualBehaviorURLs[]; extern const char kContentPackManualBehaviorURLs[];
extern const char kForceSafeSearch[]; extern const char kForceSafeSearch[];
extern const char kRecordHistory[];
extern const char kSigninAllowed[]; extern const char kSigninAllowed[];
extern const char kUserName[]; extern const char kUserName[];
......
...@@ -36,16 +36,16 @@ SupervisedUserSettingsPrefMappingEntry kSupervisedUserSettingsPrefMapping[] = { ...@@ -36,16 +36,16 @@ SupervisedUserSettingsPrefMappingEntry kSupervisedUserSettingsPrefMapping[] = {
prefs::kSupervisedUserManualURLs, prefs::kSupervisedUserManualURLs,
}, },
{ {
supervised_users::kForceSafeSearch, supervised_users::kForceSafeSearch, prefs::kForceSafeSearch,
prefs::kForceSafeSearch,
}, },
{ {
supervised_users::kSigninAllowed, supervised_users::kRecordHistory, prefs::kRecordHistory,
prefs::kSigninAllowed,
}, },
{ {
supervised_users::kUserName, supervised_users::kSigninAllowed, prefs::kSigninAllowed,
prefs::kProfileName, },
{
supervised_users::kUserName, prefs::kProfileName,
}, },
}; };
...@@ -95,6 +95,7 @@ void SupervisedUserPrefStore::OnNewSettingsAvailable( ...@@ -95,6 +95,7 @@ void SupervisedUserPrefStore::OnNewSettingsAvailable(
prefs_->SetValue(prefs::kDefaultSupervisedUserFilteringBehavior, prefs_->SetValue(prefs::kDefaultSupervisedUserFilteringBehavior,
new FundamentalValue(SupervisedUserURLFilter::ALLOW)); new FundamentalValue(SupervisedUserURLFilter::ALLOW));
prefs_->SetValue(prefs::kForceSafeSearch, new FundamentalValue(true)); prefs_->SetValue(prefs::kForceSafeSearch, new FundamentalValue(true));
prefs_->SetValue(prefs::kRecordHistory, new FundamentalValue(true));
prefs_->SetValue(prefs::kHideWebStoreIcon, new FundamentalValue(true)); prefs_->SetValue(prefs::kHideWebStoreIcon, new FundamentalValue(true));
prefs_->SetValue(prefs::kIncognitoModeAvailability, prefs_->SetValue(prefs::kIncognitoModeAvailability,
new FundamentalValue(IncognitoModePrefs::DISABLED)); new FundamentalValue(IncognitoModePrefs::DISABLED));
......
...@@ -156,7 +156,8 @@ void SupervisedUserService::URLFilterContext::OnBlacklistLoaded() { ...@@ -156,7 +156,8 @@ void SupervisedUserService::URLFilterContext::OnBlacklistLoaded() {
} }
SupervisedUserService::SupervisedUserService(Profile* profile) SupervisedUserService::SupervisedUserService(Profile* profile)
: profile_(profile), : includes_sync_sessions_type_(true),
profile_(profile),
active_(false), active_(false),
delegate_(NULL), delegate_(NULL),
#if defined(ENABLE_EXTENSIONS) #if defined(ENABLE_EXTENSIONS)
...@@ -400,7 +401,8 @@ syncer::ModelTypeSet SupervisedUserService::GetPreferredDataTypes() const { ...@@ -400,7 +401,8 @@ syncer::ModelTypeSet SupervisedUserService::GetPreferredDataTypes() const {
return syncer::ModelTypeSet(); return syncer::ModelTypeSet();
syncer::ModelTypeSet result; syncer::ModelTypeSet result;
result.Put(syncer::SESSIONS); if (IncludesSyncSessionsType())
result.Put(syncer::SESSIONS);
result.Put(syncer::EXTENSIONS); result.Put(syncer::EXTENSIONS);
result.Put(syncer::EXTENSION_SETTINGS); result.Put(syncer::EXTENSION_SETTINGS);
result.Put(syncer::APPS); result.Put(syncer::APPS);
...@@ -410,6 +412,17 @@ syncer::ModelTypeSet SupervisedUserService::GetPreferredDataTypes() const { ...@@ -410,6 +412,17 @@ syncer::ModelTypeSet SupervisedUserService::GetPreferredDataTypes() const {
return result; return result;
} }
void SupervisedUserService::OnHistoryRecordingStateChanged() {
includes_sync_sessions_type_ =
profile_->GetPrefs()->GetBoolean(prefs::kRecordHistory);
ProfileSyncServiceFactory::GetForProfile(profile_)
->ReconfigureDatatypeManager();
}
bool SupervisedUserService::IncludesSyncSessionsType() const {
return includes_sync_sessions_type_;
}
void SupervisedUserService::OnStateChanged() { void SupervisedUserService::OnStateChanged() {
ProfileSyncService* service = ProfileSyncService* service =
ProfileSyncServiceFactory::GetForProfile(profile_); ProfileSyncServiceFactory::GetForProfile(profile_);
...@@ -680,6 +693,10 @@ void SupervisedUserService::Init() { ...@@ -680,6 +693,10 @@ void SupervisedUserService::Init() {
prefs::kSupervisedUserId, prefs::kSupervisedUserId,
base::Bind(&SupervisedUserService::OnSupervisedUserIdChanged, base::Bind(&SupervisedUserService::OnSupervisedUserIdChanged,
base::Unretained(this))); base::Unretained(this)));
pref_change_registrar_.Add(
prefs::kRecordHistory,
base::Bind(&SupervisedUserService::OnHistoryRecordingStateChanged,
base::Unretained(this)));
ProfileSyncService* sync_service = ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetForProfile(profile_); ProfileSyncServiceFactory::GetForProfile(profile_);
......
...@@ -206,7 +206,10 @@ class SupervisedUserService : public KeyedService, ...@@ -206,7 +206,10 @@ class SupervisedUserService : public KeyedService,
friend class SupervisedUserServiceExtensionTestBase; friend class SupervisedUserServiceExtensionTestBase;
friend class SupervisedUserServiceFactory; friend class SupervisedUserServiceFactory;
FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration);
FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest,
ChangesIncludedSessionOnChangedSettings);
FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest,
ChangesSyncSessionStateOnChangedSettings);
// A bridge from the UI thread to the SupervisedUserURLFilters, one of which // A bridge from the UI thread to the SupervisedUserURLFilters, one of which
// lives on the IO thread. This class mediates access to them and makes sure // lives on the IO thread. This class mediates access to them and makes sure
// they are kept in sync. // they are kept in sync.
...@@ -309,6 +312,19 @@ class SupervisedUserService : public KeyedService, ...@@ -309,6 +312,19 @@ class SupervisedUserService : public KeyedService,
// Returns the human readable name of the supervised user. // Returns the human readable name of the supervised user.
std::string GetSupervisedUserName() const; std::string GetSupervisedUserName() const;
// Subscribes to the SupervisedUserPrefStore, refreshes
// |includes_sync_sessions_type_| and triggers reconfiguring the
// ProfileSyncService.
void OnHistoryRecordingStateChanged();
// Returns true if the syncer::SESSIONS type should be included in Sync.
bool IncludesSyncSessionsType() const;
// The option a custodian sets to either record or prevent recording the
// supervised user's history. Set by |FetchNewSessionSyncState()| and
// defaults to true.
bool includes_sync_sessions_type_;
// Owns us via the KeyedService mechanism. // Owns us via the KeyedService mechanism.
Profile* profile_; Profile* profile_;
......
...@@ -154,6 +154,13 @@ TEST_F(SupervisedUserServiceTest, GetManualExceptionsForHost) { ...@@ -154,6 +154,13 @@ TEST_F(SupervisedUserServiceTest, GetManualExceptionsForHost) {
supervised_user_service_->GetManualBehaviorForURL(kMooseURL)); supervised_user_service_->GetManualBehaviorForURL(kMooseURL));
} }
TEST_F(SupervisedUserServiceTest, ChangesIncludedSessionOnChangedSettings) {
supervised_user_service_->Init();
EXPECT_TRUE(supervised_user_service_->IncludesSyncSessionsType());
profile_->GetPrefs()->SetBoolean(prefs::kRecordHistory, false);
EXPECT_FALSE(supervised_user_service_->IncludesSyncSessionsType());
}
// Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no
// DCHECK is hit when the service is destroyed, this test passed. // DCHECK is hit when the service is destroyed, this test passed.
TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) {
......
...@@ -478,9 +478,19 @@ class ProfileSyncService : public ProfileSyncServiceBase, ...@@ -478,9 +478,19 @@ class ProfileSyncService : public ProfileSyncServiceBase,
// is complete). The UI calls this as soon as any part of the signin wizard is // is complete). The UI calls this as soon as any part of the signin wizard is
// displayed (even just the login UI). // displayed (even just the login UI).
// If |setup_in_progress| is false, this also kicks the sync engine to ensure // If |setup_in_progress| is false, this also kicks the sync engine to ensure
// that data download starts. // that data download starts. In this case, |ReconfigureDatatypeManager| will
// get triggered.
virtual void SetSetupInProgress(bool setup_in_progress); virtual void SetSetupInProgress(bool setup_in_progress);
// Reconfigures the data type manager with the latest enabled types.
// Note: Does not initialize the backend if it is not already initialized.
// This function needs to be called only after sync has been initialized
// (i.e.,only for reconfigurations). The reason we don't initialize the
// backend is because if we had encountered an unrecoverable error we don't
// want to startup once more.
// This function is called by |SetSetupInProgress|.
virtual void ReconfigureDatatypeManager();
// Returns true if the SyncBackendHost has told us it's ready to accept // Returns true if the SyncBackendHost has told us it's ready to accept
// changes. // changes.
// [REMARK] - it is safe to call this function only from the ui thread. // [REMARK] - it is safe to call this function only from the ui thread.
...@@ -911,14 +921,6 @@ class ProfileSyncService : public ProfileSyncServiceBase, ...@@ -911,14 +921,6 @@ class ProfileSyncService : public ProfileSyncServiceBase,
// Create and register a new datatype controller. // Create and register a new datatype controller.
void RegisterNewDataType(syncer::ModelType data_type); void RegisterNewDataType(syncer::ModelType data_type);
// Reconfigures the data type manager with the latest enabled types.
// Note: Does not initialize the backend if it is not already initialized.
// This function needs to be called only after sync has been initialized
// (i.e.,only for reconfigurations). The reason we don't initialize the
// backend is because if we had encountered an unrecoverable error we don't
// want to startup once more.
virtual void ReconfigureDatatypeManager();
// Collects preferred sync data types from |preference_providers_|. // Collects preferred sync data types from |preference_providers_|.
syncer::ModelTypeSet GetDataTypesFromPreferenceProviders() const; syncer::ModelTypeSet GetDataTypesFromPreferenceProviders() const;
......
...@@ -891,6 +891,10 @@ const char kAllowDeletingBrowserHistory[] = "history.deleting_enabled"; ...@@ -891,6 +891,10 @@ const char kAllowDeletingBrowserHistory[] = "history.deleting_enabled";
// Boolean controlling whether SafeSearch is mandatory for Google Web Searches. // Boolean controlling whether SafeSearch is mandatory for Google Web Searches.
const char kForceSafeSearch[] = "settings.force_safesearch"; const char kForceSafeSearch[] = "settings.force_safesearch";
// Boolean controlling whether History is recorded and synced for
// supervised users.
const char kRecordHistory[] = "settings.history_recorded";
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// Linux specific preference on whether we should match the system theme. // Linux specific preference on whether we should match the system theme.
const char kUsesSystemTheme[] = "extensions.theme.use_system"; const char kUsesSystemTheme[] = "extensions.theme.use_system";
......
...@@ -287,6 +287,7 @@ extern const char kEnableAutoSpellCorrect[]; ...@@ -287,6 +287,7 @@ extern const char kEnableAutoSpellCorrect[];
extern const char kSavingBrowserHistoryDisabled[]; extern const char kSavingBrowserHistoryDisabled[];
extern const char kAllowDeletingBrowserHistory[]; extern const char kAllowDeletingBrowserHistory[];
extern const char kForceSafeSearch[]; extern const char kForceSafeSearch[];
extern const char kRecordHistory[];
extern const char kDeleteTimePeriod[]; extern const char kDeleteTimePeriod[];
extern const char kLastClearBrowsingDataTime[]; extern const char kLastClearBrowsingDataTime[];
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment