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

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

Issue 6142009: Upating the app, ceee, chrome, ipc, media, and net directories to use the correct lock.h file. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Unified patch updating all references to the new base/synchronization/lock.h Created 9 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 | 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/pref_content_settings_provider.h" 5 #include "chrome/browser/content_settings/pref_content_settings_provider.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/browser_thread.h" 8 #include "chrome/browser/browser_thread.h"
9 #include "chrome/browser/content_settings/content_settings_details.h" 9 #include "chrome/browser/content_settings/content_settings_details.h"
10 #include "chrome/browser/content_settings/content_settings_pattern.h" 10 #include "chrome/browser/content_settings/content_settings_pattern.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 UnregisterObservers(); 78 UnregisterObservers();
79 } 79 }
80 80
81 bool PrefContentSettingsProvider::CanProvideDefaultSetting( 81 bool PrefContentSettingsProvider::CanProvideDefaultSetting(
82 ContentSettingsType content_type) const { 82 ContentSettingsType content_type) const {
83 return true; 83 return true;
84 } 84 }
85 85
86 ContentSetting PrefContentSettingsProvider::ProvideDefaultSetting( 86 ContentSetting PrefContentSettingsProvider::ProvideDefaultSetting(
87 ContentSettingsType content_type) const { 87 ContentSettingsType content_type) const {
88 AutoLock lock(lock_); 88 base::AutoLock lock(lock_);
89 return default_content_settings_.settings[content_type]; 89 return default_content_settings_.settings[content_type];
90 } 90 }
91 91
92 void PrefContentSettingsProvider::UpdateDefaultSetting( 92 void PrefContentSettingsProvider::UpdateDefaultSetting(
93 ContentSettingsType content_type, 93 ContentSettingsType content_type,
94 ContentSetting setting) { 94 ContentSetting setting) {
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
96 DCHECK(kTypeNames[content_type] != NULL); // Don't call this for Geolocation. 96 DCHECK(kTypeNames[content_type] != NULL); // Don't call this for Geolocation.
97 DCHECK(content_type != CONTENT_SETTINGS_TYPE_PLUGINS || 97 DCHECK(content_type != CONTENT_SETTINGS_TYPE_PLUGINS ||
98 setting != CONTENT_SETTING_ASK || 98 setting != CONTENT_SETTING_ASK ||
99 CommandLine::ForCurrentProcess()->HasSwitch( 99 CommandLine::ForCurrentProcess()->HasSwitch(
100 switches::kEnableClickToPlay)); 100 switches::kEnableClickToPlay));
101 101
102 // The default settings may not be directly modified for OTR sessions. 102 // The default settings may not be directly modified for OTR sessions.
103 // Instead, they are synced to the main profile's setting. 103 // Instead, they are synced to the main profile's setting.
104 if (is_off_the_record_) 104 if (is_off_the_record_)
105 return; 105 return;
106 106
107 PrefService* prefs = profile_->GetPrefs(); 107 PrefService* prefs = profile_->GetPrefs();
108 108
109 DictionaryValue* default_settings_dictionary = 109 DictionaryValue* default_settings_dictionary =
110 prefs->GetMutableDictionary(prefs::kDefaultContentSettings); 110 prefs->GetMutableDictionary(prefs::kDefaultContentSettings);
111 std::string dictionary_path(kTypeNames[content_type]); 111 std::string dictionary_path(kTypeNames[content_type]);
112 updating_preferences_ = true; 112 updating_preferences_ = true;
113 { 113 {
114 AutoLock lock(lock_); 114 base::AutoLock lock(lock_);
115 ScopedPrefUpdate update(prefs, prefs::kDefaultContentSettings); 115 ScopedPrefUpdate update(prefs, prefs::kDefaultContentSettings);
116 if ((setting == CONTENT_SETTING_DEFAULT) || 116 if ((setting == CONTENT_SETTING_DEFAULT) ||
117 (setting == kDefaultSettings[content_type])) { 117 (setting == kDefaultSettings[content_type])) {
118 default_content_settings_.settings[content_type] = 118 default_content_settings_.settings[content_type] =
119 kDefaultSettings[content_type]; 119 kDefaultSettings[content_type];
120 default_settings_dictionary->RemoveWithoutPathExpansion(dictionary_path, 120 default_settings_dictionary->RemoveWithoutPathExpansion(dictionary_path,
121 NULL); 121 NULL);
122 } else { 122 } else {
123 default_content_settings_.settings[content_type] = setting; 123 default_content_settings_.settings[content_type] = setting;
124 default_settings_dictionary->SetWithoutPathExpansion( 124 default_settings_dictionary->SetWithoutPathExpansion(
125 dictionary_path, Value::CreateIntegerValue(setting)); 125 dictionary_path, Value::CreateIntegerValue(setting));
126 } 126 }
127 } 127 }
128 updating_preferences_ = false; 128 updating_preferences_ = false;
129 129
130 NotifyObservers( 130 NotifyObservers(
131 ContentSettingsDetails(ContentSettingsPattern(), content_type, "")); 131 ContentSettingsDetails(ContentSettingsPattern(), content_type, ""));
132 } 132 }
133 133
134 bool PrefContentSettingsProvider::DefaultSettingIsManaged( 134 bool PrefContentSettingsProvider::DefaultSettingIsManaged(
135 ContentSettingsType content_type) const { 135 ContentSettingsType content_type) const {
136 return false; 136 return false;
137 } 137 }
138 138
139 void PrefContentSettingsProvider::ResetToDefaults() { 139 void PrefContentSettingsProvider::ResetToDefaults() {
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
141 AutoLock lock(lock_); 141 base::AutoLock lock(lock_);
142 default_content_settings_ = ContentSettings(); 142 default_content_settings_ = ContentSettings();
143 ForceDefaultsToBeExplicit(); 143 ForceDefaultsToBeExplicit();
144 144
145 if (!is_off_the_record_) { 145 if (!is_off_the_record_) {
146 PrefService* prefs = profile_->GetPrefs(); 146 PrefService* prefs = profile_->GetPrefs();
147 updating_preferences_ = true; 147 updating_preferences_ = true;
148 prefs->ClearPref(prefs::kDefaultContentSettings); 148 prefs->ClearPref(prefs::kDefaultContentSettings);
149 updating_preferences_ = false; 149 updating_preferences_ = false;
150 } 150 }
151 } 151 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED, 188 notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED,
189 Source<Profile>(profile_)); 189 Source<Profile>(profile_));
190 profile_ = NULL; 190 profile_ = NULL;
191 } 191 }
192 192
193 void PrefContentSettingsProvider::ReadDefaultSettings(bool overwrite) { 193 void PrefContentSettingsProvider::ReadDefaultSettings(bool overwrite) {
194 PrefService* prefs = profile_->GetPrefs(); 194 PrefService* prefs = profile_->GetPrefs();
195 const DictionaryValue* default_settings_dictionary = 195 const DictionaryValue* default_settings_dictionary =
196 prefs->GetDictionary(prefs::kDefaultContentSettings); 196 prefs->GetDictionary(prefs::kDefaultContentSettings);
197 197
198 AutoLock lock(lock_); 198 base::AutoLock lock(lock_);
199 199
200 if (overwrite) 200 if (overwrite)
201 default_content_settings_ = ContentSettings(); 201 default_content_settings_ = ContentSettings();
202 202
203 // Careful: The returned value could be NULL if the pref has never been set. 203 // Careful: The returned value could be NULL if the pref has never been set.
204 if (default_settings_dictionary != NULL) { 204 if (default_settings_dictionary != NULL) {
205 GetSettingsFromDictionary(default_settings_dictionary, 205 GetSettingsFromDictionary(default_settings_dictionary,
206 &default_content_settings_); 206 &default_content_settings_);
207 } 207 }
208 ForceDefaultsToBeExplicit(); 208 ForceDefaultsToBeExplicit();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 NotificationType::CONTENT_SETTINGS_CHANGED, 254 NotificationType::CONTENT_SETTINGS_CHANGED,
255 Source<HostContentSettingsMap>(profile_->GetHostContentSettingsMap()), 255 Source<HostContentSettingsMap>(profile_->GetHostContentSettingsMap()),
256 Details<const ContentSettingsDetails>(&details)); 256 Details<const ContentSettingsDetails>(&details));
257 } 257 }
258 258
259 259
260 // static 260 // static
261 void PrefContentSettingsProvider::RegisterUserPrefs(PrefService* prefs) { 261 void PrefContentSettingsProvider::RegisterUserPrefs(PrefService* prefs) {
262 prefs->RegisterDictionaryPref(prefs::kDefaultContentSettings); 262 prefs->RegisterDictionaryPref(prefs::kDefaultContentSettings);
263 } 263 }
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/pref_content_settings_provider.h ('k') | chrome/browser/cross_site_request_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698