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

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

Issue 769153007: Managed bookmarks for supervised users (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h"
10 #include "base/prefs/pref_value_map.h" 11 #include "base/prefs/pref_value_map.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/prefs/incognito_mode_prefs.h" 13 #include "chrome/browser/prefs/incognito_mode_prefs.h"
14 #include "chrome/browser/supervised_user/supervised_user_bookmarks_handler.h"
13 #include "chrome/browser/supervised_user/supervised_user_constants.h" 15 #include "chrome/browser/supervised_user/supervised_user_constants.h"
14 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" 16 #include "chrome/browser/supervised_user/supervised_user_settings_service.h"
15 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" 17 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
18 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
17 20 #include "components/bookmarks/common/bookmark_pref_names.h"
18 using base::FundamentalValue;
19 21
20 namespace { 22 namespace {
21 23
22 struct SupervisedUserSettingsPrefMappingEntry { 24 struct SupervisedUserSettingsPrefMappingEntry {
23 const char* settings_name; 25 const char* settings_name;
24 const char* pref_name; 26 const char* pref_name;
25 }; 27 };
26 28
27 SupervisedUserSettingsPrefMappingEntry kSupervisedUserSettingsPrefMapping[] = { 29 SupervisedUserSettingsPrefMappingEntry kSupervisedUserSettingsPrefMapping[] = {
28 { 30 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 113
112 // Manually set preferences that aren't direct copies of the settings value. 114 // Manually set preferences that aren't direct copies of the settings value.
113 bool record_history; 115 bool record_history;
114 if (settings->GetBoolean(supervised_users::kRecordHistory, 116 if (settings->GetBoolean(supervised_users::kRecordHistory,
115 &record_history)) { 117 &record_history)) {
116 prefs_->SetBoolean(prefs::kAllowDeletingBrowserHistory, !record_history); 118 prefs_->SetBoolean(prefs::kAllowDeletingBrowserHistory, !record_history);
117 prefs_->SetInteger(prefs::kIncognitoModeAvailability, 119 prefs_->SetInteger(prefs::kIncognitoModeAvailability,
118 record_history ? IncognitoModePrefs::DISABLED 120 record_history ? IncognitoModePrefs::DISABLED
119 : IncognitoModePrefs::ENABLED); 121 : IncognitoModePrefs::ENABLED);
120 } 122 }
123
124 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
125 switches::kEnableSupervisedUserManagedBookmarksFolder)) {
126 // Reconstruct bookmarks from split settings.
127 prefs_->SetValue(
128 bookmarks::prefs::kSupervisedBookmarks,
129 SupervisedUserBookmarksHandler::BuildBookmarksTree(*settings)
130 .release());
131 }
121 } 132 }
122 133
123 if (!old_prefs) { 134 if (!old_prefs) {
124 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true)); 135 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true));
125 return; 136 return;
126 } 137 }
127 138
128 std::vector<std::string> changed_prefs; 139 std::vector<std::string> changed_prefs;
129 prefs_->GetDifferingKeys(old_prefs.get(), &changed_prefs); 140 prefs_->GetDifferingKeys(old_prefs.get(), &changed_prefs);
130 141
131 // Send out change notifications. 142 // Send out change notifications.
132 for (const std::string& pref : changed_prefs) { 143 for (const std::string& pref : changed_prefs) {
133 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(pref)); 144 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(pref));
134 } 145 }
135 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698