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

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

Issue 2401733002: Revert "Added a ForceYouTubeRestrict policy and deprecated the old ForceYouTubeSafetyMode policy" (Closed)
Patch Set: Created 4 years, 2 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"
15 #include "chrome/browser/prefs/incognito_mode_prefs.h" 14 #include "chrome/browser/prefs/incognito_mode_prefs.h"
16 #include "chrome/browser/supervised_user/supervised_user_bookmarks_handler.h" 15 #include "chrome/browser/supervised_user/supervised_user_bookmarks_handler.h"
17 #include "chrome/browser/supervised_user/supervised_user_constants.h" 16 #include "chrome/browser/supervised_user/supervised_user_constants.h"
18 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" 17 #include "chrome/browser/supervised_user/supervised_user_settings_service.h"
19 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" 18 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
20 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
22 #include "components/bookmarks/common/bookmark_pref_names.h" 21 #include "components/bookmarks/common/bookmark_pref_names.h"
23 #include "components/prefs/pref_value_map.h" 22 #include "components/prefs/pref_value_map.h"
24 #include "components/signin/core/common/signin_pref_names.h" 23 #include "components/signin/core/common/signin_pref_names.h"
(...skipping 20 matching lines...) Expand all
45 prefs::kSupervisedUserManualHosts, 44 prefs::kSupervisedUserManualHosts,
46 }, 45 },
47 { 46 {
48 supervised_users::kContentPackManualBehaviorURLs, 47 supervised_users::kContentPackManualBehaviorURLs,
49 prefs::kSupervisedUserManualURLs, 48 prefs::kSupervisedUserManualURLs,
50 }, 49 },
51 { 50 {
52 supervised_users::kForceSafeSearch, prefs::kForceGoogleSafeSearch, 51 supervised_users::kForceSafeSearch, prefs::kForceGoogleSafeSearch,
53 }, 52 },
54 { 53 {
54 supervised_users::kForceSafeSearch, prefs::kForceYouTubeSafetyMode,
55 },
56 {
55 supervised_users::kSafeSitesEnabled, prefs::kSupervisedUserSafeSites, 57 supervised_users::kSafeSitesEnabled, prefs::kSupervisedUserSafeSites,
56 }, 58 },
57 { 59 {
58 supervised_users::kSigninAllowed, prefs::kSigninAllowed, 60 supervised_users::kSigninAllowed, prefs::kSigninAllowed,
59 }, 61 },
60 { 62 {
61 supervised_users::kUserName, prefs::kProfileName, 63 supervised_users::kUserName, prefs::kProfileName,
62 }, 64 },
63 }; 65 };
64 66
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 109
108 void SupervisedUserPrefStore::OnNewSettingsAvailable( 110 void SupervisedUserPrefStore::OnNewSettingsAvailable(
109 const base::DictionaryValue* settings) { 111 const base::DictionaryValue* settings) {
110 std::unique_ptr<PrefValueMap> old_prefs = std::move(prefs_); 112 std::unique_ptr<PrefValueMap> old_prefs = std::move(prefs_);
111 prefs_.reset(new PrefValueMap); 113 prefs_.reset(new PrefValueMap);
112 if (settings) { 114 if (settings) {
113 // Set hardcoded prefs and defaults. 115 // Set hardcoded prefs and defaults.
114 prefs_->SetInteger(prefs::kDefaultSupervisedUserFilteringBehavior, 116 prefs_->SetInteger(prefs::kDefaultSupervisedUserFilteringBehavior,
115 SupervisedUserURLFilter::ALLOW); 117 SupervisedUserURLFilter::ALLOW);
116 prefs_->SetBoolean(prefs::kForceGoogleSafeSearch, true); 118 prefs_->SetBoolean(prefs::kForceGoogleSafeSearch, true);
117 prefs_->SetInteger(prefs::kForceYouTubeRestrict, 119 prefs_->SetBoolean(prefs::kForceYouTubeSafetyMode, true);
118 safe_search_util::YOUTUBE_RESTRICT_MODERATE);
119 prefs_->SetBoolean(prefs::kHideWebStoreIcon, true); 120 prefs_->SetBoolean(prefs::kHideWebStoreIcon, true);
120 prefs_->SetBoolean(prefs::kSigninAllowed, false); 121 prefs_->SetBoolean(prefs::kSigninAllowed, false);
121 122
122 // Copy supervised user settings to prefs. 123 // Copy supervised user settings to prefs.
123 for (const auto& entry : kSupervisedUserSettingsPrefMapping) { 124 for (const auto& entry : kSupervisedUserSettingsPrefMapping) {
124 const base::Value* value = NULL; 125 const base::Value* value = NULL;
125 if (settings->GetWithoutPathExpansion(entry.settings_name, &value)) 126 if (settings->GetWithoutPathExpansion(entry.settings_name, &value))
126 prefs_->SetValue(entry.pref_name, value->CreateDeepCopy()); 127 prefs_->SetValue(entry.pref_name, value->CreateDeepCopy());
127 } 128 }
128 129
129 // Manually set preferences that aren't direct copies of the settings value. 130 // 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);
137 131
138 bool record_history_includes_session_sync = true; 132 bool record_history = true;
139 settings->GetBoolean(supervised_users::kRecordHistoryIncludesSessionSync, 133 settings->GetBoolean(supervised_users::kRecordHistory, &record_history);
140 &record_history_includes_session_sync); 134 prefs_->SetBoolean(prefs::kAllowDeletingBrowserHistory, !record_history);
141 prefs_->SetBoolean( 135 prefs_->SetInteger(prefs::kIncognitoModeAvailability,
142 prefs::kForceSessionSync, 136 record_history ? IncognitoModePrefs::DISABLED
143 record_history && record_history_includes_session_sync); 137 : IncognitoModePrefs::ENABLED);
144 }
145 138
146 { 139 bool record_history_includes_session_sync = true;
147 // Note that |prefs::kForceGoogleSafeSearch| is set automatically as part 140 settings->GetBoolean(supervised_users::kRecordHistoryIncludesSessionSync,
148 // of |kSupervisedUserSettingsPrefMapping|, but this can't be done for 141 &record_history_includes_session_sync);
149 // |prefs::kForceYouTubeRestrict| because it is an int, not a bool. 142 prefs_->SetBoolean(prefs::kForceSessionSync,
150 bool force_safe_search = true; 143 record_history && record_history_includes_session_sync);
151 settings->GetBoolean(supervised_users::kForceSafeSearch,
152 &force_safe_search);
153 prefs_->SetInteger(
154 prefs::kForceYouTubeRestrict,
155 force_safe_search ? safe_search_util::YOUTUBE_RESTRICT_MODERATE
156 : safe_search_util::YOUTUBE_RESTRICT_OFF);
157 }
158 144
159 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 145 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
160 switches::kEnableSupervisedUserManagedBookmarksFolder)) { 146 switches::kEnableSupervisedUserManagedBookmarksFolder)) {
161 // Reconstruct bookmarks from split settings. 147 // Reconstruct bookmarks from split settings.
162 prefs_->SetValue( 148 prefs_->SetValue(
163 bookmarks::prefs::kSupervisedBookmarks, 149 bookmarks::prefs::kSupervisedBookmarks,
164 SupervisedUserBookmarksHandler::BuildBookmarksTree(*settings)); 150 SupervisedUserBookmarksHandler::BuildBookmarksTree(*settings));
165 } 151 }
166 } 152 }
167 153
(...skipping 12 matching lines...) Expand all
180 } 166 }
181 167
182 // Callback to unsubscribe from the supervised user settings service. 168 // Callback to unsubscribe from the supervised user settings service.
183 void SupervisedUserPrefStore::Observe( 169 void SupervisedUserPrefStore::Observe(
184 int type, 170 int type,
185 const content::NotificationSource& src, 171 const content::NotificationSource& src,
186 const content::NotificationDetails& details) { 172 const content::NotificationDetails& details) {
187 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 173 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
188 user_settings_subscription_.reset(); 174 user_settings_subscription_.reset();
189 } 175 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.cc ('k') | chrome/browser/supervised_user/supervised_user_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698