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

Side by Side Diff: chrome/browser/content_settings/policy_content_settings_provider.cc

Issue 6410022: Add content_settings::PrefProvider to HostContentSettingsMap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/content_settings/policy_content_settings_provider.h" 5 #include "chrome/browser/content_settings/policy_content_settings_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/browser/browser_thread.h" 10 #include "chrome/browser/browser_thread.h"
11 #include "chrome/browser/content_settings/content_settings_details.h" 11 #include "chrome/browser/content_settings/content_settings_details.h"
12 #include "chrome/browser/content_settings/content_settings_pattern.h" 12 #include "chrome/browser/content_settings/content_settings_pattern.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/prefs/scoped_pref_update.h" 14 #include "chrome/browser/prefs/scoped_pref_update.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/notification_details.h" 16 #include "chrome/common/notification_details.h"
17 #include "chrome/common/notification_service.h" 17 #include "chrome/common/notification_service.h"
18 #include "chrome/common/notification_source.h" 18 #include "chrome/common/notification_source.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 20
21 namespace { 21 namespace content_settings {
jochen (gone - plz use gerrit) 2011/02/04 08:38:43 this should stay an anonymous namespace
markusheintz_ 2011/02/04 10:08:03 Uuups sry. Done
22 22
23 // Base pref path of the prefs that contain the managed default content 23 // Base pref path of the prefs that contain the managed default content
24 // settings values. 24 // settings values.
25 const std::string kManagedSettings = 25 const std::string kManagedSettings =
26 "profile.managed_default_content_settings"; 26 "profile.managed_default_content_settings";
27 27
28 // The preferences used to manage ContentSettingsTypes. 28 // The preferences used to manage ContentSettingsTypes.
29 const char* kPrefToManageType[CONTENT_SETTINGS_NUM_TYPES] = { 29 const char* kPrefToManageType[CONTENT_SETTINGS_NUM_TYPES] = {
30 prefs::kManagedDefaultCookiesSetting, 30 prefs::kManagedDefaultCookiesSetting,
31 prefs::kManagedDefaultImagesSetting, 31 prefs::kManagedDefaultImagesSetting,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 UpdateManagedDefaultSetting(ContentSettingsType(type)); 162 UpdateManagedDefaultSetting(ContentSettingsType(type));
163 } 163 }
164 } 164 }
165 165
166 void PolicyDefaultProvider::UpdateManagedDefaultSetting( 166 void PolicyDefaultProvider::UpdateManagedDefaultSetting(
167 ContentSettingsType type) { 167 ContentSettingsType type) {
168 // If a pref to manage a default-content-setting was not set (NOTICE: 168 // If a pref to manage a default-content-setting was not set (NOTICE:
169 // "HasPrefPath" returns false if no value was set for a registered pref) then 169 // "HasPrefPath" returns false if no value was set for a registered pref) then
170 // the default value of the preference is used. The default value of a 170 // the default value of the preference is used. The default value of a
171 // preference to manage a default-content-settings is 171 // preference to manage a default-content-settings is CONTENT_SETTING_DEFAULT.
172 // CONTENT_SETTING_DEFAULT. This indicates that no managed value is set. If a 172 // This indicates that no managed value is set. If a pref was set, than it
173 // pref was set, than it MUST be managed. 173 // MUST be managed.
174 PrefService* prefs = profile_->GetPrefs(); 174 PrefService* prefs = profile_->GetPrefs();
175 DCHECK(!prefs->HasPrefPath(kPrefToManageType[type]) || 175 DCHECK(!prefs->HasPrefPath(kPrefToManageType[type]) ||
176 prefs->IsManagedPreference(kPrefToManageType[type])); 176 prefs->IsManagedPreference(kPrefToManageType[type]));
177 base::AutoLock auto_lock(lock_); 177 base::AutoLock auto_lock(lock_);
178 managed_default_content_settings_.settings[type] = IntToContentSetting( 178 managed_default_content_settings_.settings[type] = IntToContentSetting(
179 prefs->GetInteger(kPrefToManageType[type])); 179 prefs->GetInteger(kPrefToManageType[type]));
180 } 180 }
181 181
182 // static 182 // static
183 void PolicyDefaultProvider::RegisterUserPrefs(PrefService* prefs) { 183 void PolicyDefaultProvider::RegisterUserPrefs(PrefService* prefs) {
184 // Preferences for default content setting policies. A policy is not set of 184 // Preferences for default content setting policies. A policy is not set of
185 // the corresponding preferences below is set to CONTENT_SETTING_DEFAULT. 185 // the corresponding preferences below is set to CONTENT_SETTING_DEFAULT.
186 prefs->RegisterIntegerPref(prefs::kManagedDefaultCookiesSetting, 186 prefs->RegisterIntegerPref(prefs::kManagedDefaultCookiesSetting,
187 CONTENT_SETTING_DEFAULT); 187 CONTENT_SETTING_DEFAULT);
188 prefs->RegisterIntegerPref(prefs::kManagedDefaultImagesSetting, 188 prefs->RegisterIntegerPref(prefs::kManagedDefaultImagesSetting,
189 CONTENT_SETTING_DEFAULT); 189 CONTENT_SETTING_DEFAULT);
190 prefs->RegisterIntegerPref(prefs::kManagedDefaultJavaScriptSetting, 190 prefs->RegisterIntegerPref(prefs::kManagedDefaultJavaScriptSetting,
191 CONTENT_SETTING_DEFAULT); 191 CONTENT_SETTING_DEFAULT);
192 prefs->RegisterIntegerPref(prefs::kManagedDefaultPluginsSetting, 192 prefs->RegisterIntegerPref(prefs::kManagedDefaultPluginsSetting,
193 CONTENT_SETTING_DEFAULT); 193 CONTENT_SETTING_DEFAULT);
194 prefs->RegisterIntegerPref(prefs::kManagedDefaultPopupsSetting, 194 prefs->RegisterIntegerPref(prefs::kManagedDefaultPopupsSetting,
195 CONTENT_SETTING_DEFAULT); 195 CONTENT_SETTING_DEFAULT);
196 } 196 }
197 197
198 } // namespace content_settings 198 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698