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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_pref_store.cc

Issue 2239753002: Added a ForceYouTubeRestrict policy and deprecated the old ForceYouTubeSafetyMode policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Inc'ed id of new policy to 346 Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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/supervised_user_pref_store.h" 5 #include "chrome/browser/supervised_user/supervised_user_pref_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/net/safe_search_util.h"
14 #include "chrome/browser/prefs/incognito_mode_prefs.h" 15 #include "chrome/browser/prefs/incognito_mode_prefs.h"
15 #include "chrome/browser/supervised_user/supervised_user_bookmarks_handler.h" 16 #include "chrome/browser/supervised_user/supervised_user_bookmarks_handler.h"
16 #include "chrome/browser/supervised_user/supervised_user_constants.h" 17 #include "chrome/browser/supervised_user/supervised_user_constants.h"
17 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" 18 #include "chrome/browser/supervised_user/supervised_user_settings_service.h"
18 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" 19 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "components/bookmarks/common/bookmark_pref_names.h" 22 #include "components/bookmarks/common/bookmark_pref_names.h"
22 #include "components/prefs/pref_value_map.h" 23 #include "components/prefs/pref_value_map.h"
23 #include "components/signin/core/common/signin_pref_names.h" 24 #include "components/signin/core/common/signin_pref_names.h"
(...skipping 20 matching lines...) Expand all
44 prefs::kSupervisedUserManualHosts, 45 prefs::kSupervisedUserManualHosts,
45 }, 46 },
46 { 47 {
47 supervised_users::kContentPackManualBehaviorURLs, 48 supervised_users::kContentPackManualBehaviorURLs,
48 prefs::kSupervisedUserManualURLs, 49 prefs::kSupervisedUserManualURLs,
49 }, 50 },
50 { 51 {
51 supervised_users::kForceSafeSearch, prefs::kForceGoogleSafeSearch, 52 supervised_users::kForceSafeSearch, prefs::kForceGoogleSafeSearch,
52 }, 53 },
53 { 54 {
54 supervised_users::kForceSafeSearch, prefs::kForceYouTubeSafetyMode,
55 },
56 {
57 supervised_users::kSafeSitesEnabled, prefs::kSupervisedUserSafeSites, 55 supervised_users::kSafeSitesEnabled, prefs::kSupervisedUserSafeSites,
58 }, 56 },
59 { 57 {
60 supervised_users::kSigninAllowed, prefs::kSigninAllowed, 58 supervised_users::kSigninAllowed, prefs::kSigninAllowed,
61 }, 59 },
62 { 60 {
63 supervised_users::kUserName, prefs::kProfileName, 61 supervised_users::kUserName, prefs::kProfileName,
64 }, 62 },
65 }; 63 };
66 64
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 107
110 void SupervisedUserPrefStore::OnNewSettingsAvailable( 108 void SupervisedUserPrefStore::OnNewSettingsAvailable(
111 const base::DictionaryValue* settings) { 109 const base::DictionaryValue* settings) {
112 std::unique_ptr<PrefValueMap> old_prefs = std::move(prefs_); 110 std::unique_ptr<PrefValueMap> old_prefs = std::move(prefs_);
113 prefs_.reset(new PrefValueMap); 111 prefs_.reset(new PrefValueMap);
114 if (settings) { 112 if (settings) {
115 // Set hardcoded prefs and defaults. 113 // Set hardcoded prefs and defaults.
116 prefs_->SetInteger(prefs::kDefaultSupervisedUserFilteringBehavior, 114 prefs_->SetInteger(prefs::kDefaultSupervisedUserFilteringBehavior,
117 SupervisedUserURLFilter::ALLOW); 115 SupervisedUserURLFilter::ALLOW);
118 prefs_->SetBoolean(prefs::kForceGoogleSafeSearch, true); 116 prefs_->SetBoolean(prefs::kForceGoogleSafeSearch, true);
119 prefs_->SetBoolean(prefs::kForceYouTubeSafetyMode, true); 117 prefs_->SetInteger(prefs::kForceYouTubeRestrict,
118 safe_search_util::YOUTUBE_MODERATE);
120 prefs_->SetBoolean(prefs::kHideWebStoreIcon, true); 119 prefs_->SetBoolean(prefs::kHideWebStoreIcon, true);
121 prefs_->SetBoolean(prefs::kSigninAllowed, false); 120 prefs_->SetBoolean(prefs::kSigninAllowed, false);
122 121
123 // Copy supervised user settings to prefs. 122 // Copy supervised user settings to prefs.
124 for (const auto& entry : kSupervisedUserSettingsPrefMapping) { 123 for (const auto& entry : kSupervisedUserSettingsPrefMapping) {
125 const base::Value* value = NULL; 124 const base::Value* value = NULL;
126 if (settings->GetWithoutPathExpansion(entry.settings_name, &value)) 125 if (settings->GetWithoutPathExpansion(entry.settings_name, &value))
127 prefs_->SetValue(entry.pref_name, value->CreateDeepCopy()); 126 prefs_->SetValue(entry.pref_name, value->CreateDeepCopy());
128 } 127 }
129 128
130 // Manually set preferences that aren't direct copies of the settings value. 129 // Manually set preferences that aren't direct copies of the settings value.
130 {
131 bool record_history = true;
132 settings->GetBoolean(supervised_users::kRecordHistory, &record_history);
133 prefs_->SetBoolean(prefs::kAllowDeletingBrowserHistory, !record_history);
134 prefs_->SetInteger(prefs::kIncognitoModeAvailability,
135 record_history ? IncognitoModePrefs::DISABLED
136 : IncognitoModePrefs::ENABLED);
131 137
132 bool record_history = true; 138 bool record_history_includes_session_sync = true;
133 settings->GetBoolean(supervised_users::kRecordHistory, &record_history); 139 settings->GetBoolean(supervised_users::kRecordHistoryIncludesSessionSync,
134 prefs_->SetBoolean(prefs::kAllowDeletingBrowserHistory, !record_history); 140 &record_history_includes_session_sync);
135 prefs_->SetInteger(prefs::kIncognitoModeAvailability, 141 prefs_->SetBoolean(
136 record_history ? IncognitoModePrefs::DISABLED 142 prefs::kForceSessionSync,
137 : IncognitoModePrefs::ENABLED); 143 record_history && record_history_includes_session_sync);
144 }
138 145
139 bool record_history_includes_session_sync = true; 146 {
140 settings->GetBoolean(supervised_users::kRecordHistoryIncludesSessionSync, 147 bool force_safe_search = true;
Marc Treib 2016/09/05 09:58:10 Maybe add a comment that prefs::kForceGoogleSafeSe
ljusten (tachyonic) 2016/09/05 15:24:32 Done.
141 &record_history_includes_session_sync); 148 settings->GetBoolean(supervised_users::kForceSafeSearch,
142 prefs_->SetBoolean(prefs::kForceSessionSync, 149 &force_safe_search);
143 record_history && record_history_includes_session_sync); 150 prefs_->SetInteger(prefs::kForceYouTubeRestrict,
151 force_safe_search ? safe_search_util::YOUTUBE_MODERATE
152 : safe_search_util::YOUTUBE_OFF);
153 }
144 154
145 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 155 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
146 switches::kEnableSupervisedUserManagedBookmarksFolder)) { 156 switches::kEnableSupervisedUserManagedBookmarksFolder)) {
147 // Reconstruct bookmarks from split settings. 157 // Reconstruct bookmarks from split settings.
148 prefs_->SetValue( 158 prefs_->SetValue(
149 bookmarks::prefs::kSupervisedBookmarks, 159 bookmarks::prefs::kSupervisedBookmarks,
150 SupervisedUserBookmarksHandler::BuildBookmarksTree(*settings)); 160 SupervisedUserBookmarksHandler::BuildBookmarksTree(*settings));
151 } 161 }
152 } 162 }
153 163
(...skipping 12 matching lines...) Expand all
166 } 176 }
167 177
168 // Callback to unsubscribe from the supervised user settings service. 178 // Callback to unsubscribe from the supervised user settings service.
169 void SupervisedUserPrefStore::Observe( 179 void SupervisedUserPrefStore::Observe(
170 int type, 180 int type,
171 const content::NotificationSource& src, 181 const content::NotificationSource& src,
172 const content::NotificationDetails& details) { 182 const content::NotificationDetails& details) {
173 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 183 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
174 user_settings_subscription_.reset(); 184 user_settings_subscription_.reset();
175 } 185 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698