blob: 8ddbfb3b8a5eda161b7fa25d4bfd039f6ef21a12 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2020 The Chromium Authors
James Cook3bd49ab2020-04-02 23:47:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/supervised_user/supervised_user_test_util.h"
6
7#include "chrome/browser/profiles/profile.h"
Nohemi Fernandezdfc72df62023-03-22 13:08:198#include "chrome/browser/profiles/profile_key.h"
9#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
James Cook3bd49ab2020-04-02 23:47:5510#include "components/prefs/pref_service.h"
Nohemi Fernandezdfc72df62023-03-22 13:08:1911#include "components/supervised_user/core/browser/supervised_user_settings_service.h"
[email protected]f1a9899c2023-01-26 16:48:2412#include "components/supervised_user/core/common/pref_names.h"
Nohemi Fernandezdfc72df62023-03-22 13:08:1913#include "components/supervised_user/core/common/supervised_user_constants.h"
James Cook3bd49ab2020-04-02 23:47:5514
15namespace supervised_user_test_util {
16
17void AddCustodians(Profile* profile) {
Nohemi Fernandez1ee7df12021-12-06 10:34:0518 DCHECK(profile->IsChild());
James Cook3bd49ab2020-04-02 23:47:5519 PrefService* prefs = profile->GetPrefs();
20 prefs->SetString(prefs::kSupervisedUserCustodianEmail,
21 "[email protected]");
22 prefs->SetString(prefs::kSupervisedUserCustodianObfuscatedGaiaId,
23 "239029320");
24
25 prefs->SetString(prefs::kSupervisedUserSecondCustodianEmail,
26 "[email protected]");
27 prefs->SetString(prefs::kSupervisedUserSecondCustodianObfuscatedGaiaId,
28 "85948533");
29}
30
Nohemi Fernandezdfc72df62023-03-22 13:08:1931void SetSupervisedUserExtensionsMayRequestPermissionsPref(Profile* profile,
32 bool enabled) {
33 // TODO(crbug/1024646): kSupervisedUserExtensionsMayRequestPermissions is
34 // currently set indirectly by setting geolocation requests. Update Kids
35 // Management server to set a new bit for extension permissions and update
36 // this setter function.
37 supervised_user::SupervisedUserSettingsService* settings_service =
38 SupervisedUserSettingsServiceFactory::GetInstance()->GetForKey(
39 profile->GetProfileKey());
40 settings_service->SetLocalSetting(supervised_user::kGeolocationDisabled,
41 base::Value(!enabled));
42 profile->GetPrefs()->SetBoolean(
43 prefs::kSupervisedUserExtensionsMayRequestPermissions, enabled);
44}
45
James Cook3bd49ab2020-04-02 23:47:5546} // namespace supervised_user_test_util