| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised_user/child_accounts/child_account_service.h" | 5 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/signin/account_tracker_service_factory.h" | 15 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 16 #include "chrome/browser/signin/signin_manager_factory.h" | 17 #include "chrome/browser/signin/signin_manager_factory.h" |
| 17 #include "chrome/browser/supervised_user/child_accounts/permission_request_creat
or_apiary.h" | 18 #include "chrome/browser/supervised_user/child_accounts/permission_request_creat
or_apiary.h" |
| 18 #include "chrome/browser/supervised_user/experimental/safe_search_url_reporter.h
" | 19 #include "chrome/browser/supervised_user/experimental/safe_search_url_reporter.h
" |
| 19 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 20 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return true; | 143 return true; |
| 143 active_ = active; | 144 active_ = active; |
| 144 | 145 |
| 145 if (active_) { | 146 if (active_) { |
| 146 SupervisedUserSettingsService* settings_service = | 147 SupervisedUserSettingsService* settings_service = |
| 147 SupervisedUserSettingsServiceFactory::GetForProfile(profile_); | 148 SupervisedUserSettingsServiceFactory::GetForProfile(profile_); |
| 148 | 149 |
| 149 // In contrast to legacy SUs, child account SUs must sign in. | 150 // In contrast to legacy SUs, child account SUs must sign in. |
| 150 settings_service->SetLocalSetting( | 151 settings_service->SetLocalSetting( |
| 151 supervised_users::kSigninAllowed, | 152 supervised_users::kSigninAllowed, |
| 152 make_scoped_ptr(new base::FundamentalValue(true))); | 153 base::WrapUnique(new base::FundamentalValue(true))); |
| 153 | 154 |
| 154 // SafeSearch is controlled at the account level, so don't override it | 155 // SafeSearch is controlled at the account level, so don't override it |
| 155 // client-side. | 156 // client-side. |
| 156 settings_service->SetLocalSetting( | 157 settings_service->SetLocalSetting( |
| 157 supervised_users::kForceSafeSearch, | 158 supervised_users::kForceSafeSearch, |
| 158 make_scoped_ptr(new base::FundamentalValue(false))); | 159 base::WrapUnique(new base::FundamentalValue(false))); |
| 159 #if !defined(OS_CHROMEOS) | 160 #if !defined(OS_CHROMEOS) |
| 160 // This is also used by user policies (UserPolicySigninService), but since | 161 // This is also used by user policies (UserPolicySigninService), but since |
| 161 // child accounts can not also be Dasher accounts, there shouldn't be any | 162 // child accounts can not also be Dasher accounts, there shouldn't be any |
| 162 // problems. | 163 // problems. |
| 163 SigninManagerFactory::GetForProfile(profile_)->ProhibitSignout(true); | 164 SigninManagerFactory::GetForProfile(profile_)->ProhibitSignout(true); |
| 164 #endif | 165 #endif |
| 165 | 166 |
| 166 // TODO(treib): Maybe store the last update time in a pref, so we don't | 167 // TODO(treib): Maybe store the last update time in a pref, so we don't |
| 167 // have to re-fetch on every start. | 168 // have to re-fetch on every start. |
| 168 StartFetchingFamilyInfo(); | 169 StartFetchingFamilyInfo(); |
| 169 | 170 |
| 170 SupervisedUserService* service = | 171 SupervisedUserService* service = |
| 171 SupervisedUserServiceFactory::GetForProfile(profile_); | 172 SupervisedUserServiceFactory::GetForProfile(profile_); |
| 172 service->AddPermissionRequestCreator( | 173 service->AddPermissionRequestCreator( |
| 173 PermissionRequestCreatorApiary::CreateWithProfile(profile_)); | 174 PermissionRequestCreatorApiary::CreateWithProfile(profile_)); |
| 174 if (base::FeatureList::IsEnabled(features::kSafeSearchUrlReporting)) { | 175 if (base::FeatureList::IsEnabled(features::kSafeSearchUrlReporting)) { |
| 175 service->SetSafeSearchURLReporter( | 176 service->SetSafeSearchURLReporter( |
| 176 SafeSearchURLReporter::CreateWithProfile(profile_)); | 177 SafeSearchURLReporter::CreateWithProfile(profile_)); |
| 177 } | 178 } |
| 178 } else { | 179 } else { |
| 179 SupervisedUserSettingsService* settings_service = | 180 SupervisedUserSettingsService* settings_service = |
| 180 SupervisedUserSettingsServiceFactory::GetForProfile(profile_); | 181 SupervisedUserSettingsServiceFactory::GetForProfile(profile_); |
| 181 settings_service->SetLocalSetting(supervised_users::kSigninAllowed, | 182 settings_service->SetLocalSetting(supervised_users::kSigninAllowed, |
| 182 scoped_ptr<base::Value>()); | 183 std::unique_ptr<base::Value>()); |
| 183 #if !defined(OS_CHROMEOS) | 184 #if !defined(OS_CHROMEOS) |
| 184 SigninManagerFactory::GetForProfile(profile_)->ProhibitSignout(false); | 185 SigninManagerFactory::GetForProfile(profile_)->ProhibitSignout(false); |
| 185 #endif | 186 #endif |
| 186 | 187 |
| 187 CancelFetchingFamilyInfo(); | 188 CancelFetchingFamilyInfo(); |
| 188 } | 189 } |
| 189 | 190 |
| 190 // Trigger a sync reconfig to enable/disable the right SU data types. | 191 // Trigger a sync reconfig to enable/disable the right SU data types. |
| 191 // The logic to do this lives in the SupervisedUserSyncDataTypeController. | 192 // The logic to do this lives in the SupervisedUserSyncDataTypeController. |
| 192 ProfileSyncService* sync_service = | 193 ProfileSyncService* sync_service = |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } | 336 } |
| 336 | 337 |
| 337 void ChildAccountService::ClearSecondCustodianPrefs() { | 338 void ChildAccountService::ClearSecondCustodianPrefs() { |
| 338 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianName); | 339 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianName); |
| 339 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianEmail); | 340 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianEmail); |
| 340 profile_->GetPrefs()->ClearPref( | 341 profile_->GetPrefs()->ClearPref( |
| 341 prefs::kSupervisedUserSecondCustodianProfileURL); | 342 prefs::kSupervisedUserSecondCustodianProfileURL); |
| 342 profile_->GetPrefs()->ClearPref( | 343 profile_->GetPrefs()->ClearPref( |
| 343 prefs::kSupervisedUserSecondCustodianProfileImageURL); | 344 prefs::kSupervisedUserSecondCustodianProfileImageURL); |
| 344 } | 345 } |
| OLD | NEW |