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

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

Issue 8198007: Remove PrefService::ScheduleSavePersistentPrefs and SavePersistentPrefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 12 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/content_settings_pref_provider.h" 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 resource_identifier); 194 resource_identifier);
195 } 195 }
196 } 196 }
197 // Update the content settings preference. 197 // Update the content settings preference.
198 if (!is_incognito_) { 198 if (!is_incognito_) {
199 UpdatePref(primary_pattern, 199 UpdatePref(primary_pattern,
200 secondary_pattern, 200 secondary_pattern,
201 content_type, 201 content_type,
202 resource_identifier, 202 resource_identifier,
203 value.get()); 203 value.get());
204 prefs_->ScheduleSavePersistentPrefs();
205 } 204 }
206 205
207 NotifyObservers( 206 NotifyObservers(
208 primary_pattern, secondary_pattern, content_type, resource_identifier); 207 primary_pattern, secondary_pattern, content_type, resource_identifier);
209 208
210 return true; 209 return true;
211 } 210 }
212 211
213 void PrefProvider::ClearAllContentSettingsRules( 212 void PrefProvider::ClearAllContentSettingsRules(
214 ContentSettingsType content_type) { 213 ContentSettingsType content_type) {
215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
216 DCHECK(prefs_); 215 DCHECK(prefs_);
217 216
218 OriginIdentifierValueMap* map_to_modify = &incognito_value_map_; 217 OriginIdentifierValueMap* map_to_modify = &incognito_value_map_;
219 if (!is_incognito_) 218 if (!is_incognito_)
220 map_to_modify = &value_map_; 219 map_to_modify = &value_map_;
221 220
222 std::vector<Rule> rules_to_delete; 221 std::vector<Rule> rules_to_delete;
223 { 222 {
224 base::AutoLock auto_lock(lock_); 223 base::AutoLock auto_lock(lock_);
225 scoped_ptr<RuleIterator> rule_iterator( 224 scoped_ptr<RuleIterator> rule_iterator(
226 map_to_modify->GetRuleIterator(content_type, "", NULL)); 225 map_to_modify->GetRuleIterator(content_type, "", NULL));
227 // Copy the rules; we cannot call |UpdatePref| while holding |lock_|. 226 // Copy the rules; we cannot call |UpdatePref| while holding |lock_|.
228 while (rule_iterator->HasNext()) 227 while (rule_iterator->HasNext())
229 rules_to_delete.push_back(rule_iterator->Next()); 228 rules_to_delete.push_back(rule_iterator->Next());
230 229
231 map_to_modify->DeleteValues(content_type, ""); 230 map_to_modify->DeleteValues(content_type, "");
232 prefs_->ScheduleSavePersistentPrefs();
233 } 231 }
234 232
235 for (std::vector<Rule>::const_iterator it = rules_to_delete.begin(); 233 for (std::vector<Rule>::const_iterator it = rules_to_delete.begin();
236 it != rules_to_delete.end(); ++it) { 234 it != rules_to_delete.end(); ++it) {
237 UpdatePref( 235 UpdatePref(
238 it->primary_pattern, 236 it->primary_pattern,
239 it->secondary_pattern, 237 it->secondary_pattern,
240 content_type, 238 content_type,
241 "", 239 "",
242 NULL); 240 NULL);
(...skipping 26 matching lines...) Expand all
269 } else if (*name == prefs::kGeolocationContentSettings) { 267 } else if (*name == prefs::kGeolocationContentSettings) {
270 MigrateObsoleteGeolocationPref(); 268 MigrateObsoleteGeolocationPref();
271 } else if (*name == prefs::kDesktopNotificationAllowedOrigins || 269 } else if (*name == prefs::kDesktopNotificationAllowedOrigins ||
272 *name == prefs::kDesktopNotificationDeniedOrigins) { 270 *name == prefs::kDesktopNotificationDeniedOrigins) {
273 MigrateObsoleteNotificationsPrefs(); 271 MigrateObsoleteNotificationsPrefs();
274 } else { 272 } else {
275 NOTREACHED() << "Unexpected preference observed"; 273 NOTREACHED() << "Unexpected preference observed";
276 return; 274 return;
277 } 275 }
278 } 276 }
279 prefs_->ScheduleSavePersistentPrefs();
280 ReadContentSettingsFromPref(true); 277 ReadContentSettingsFromPref(true);
281 278
282 NotifyObservers(ContentSettingsPattern(), 279 NotifyObservers(ContentSettingsPattern(),
283 ContentSettingsPattern(), 280 ContentSettingsPattern(),
284 CONTENT_SETTINGS_TYPE_DEFAULT, 281 CONTENT_SETTINGS_TYPE_DEFAULT,
285 std::string()); 282 std::string());
286 } else { 283 } else {
287 NOTREACHED() << "Unexpected notification"; 284 NOTREACHED() << "Unexpected notification";
288 } 285 }
289 } 286 }
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 1109
1113 void PrefProvider::AssertLockNotHeld() const { 1110 void PrefProvider::AssertLockNotHeld() const {
1114 #if !defined(NDEBUG) 1111 #if !defined(NDEBUG)
1115 // |Lock::Acquire()| will assert if the lock is held by this thread. 1112 // |Lock::Acquire()| will assert if the lock is held by this thread.
1116 lock_.Acquire(); 1113 lock_.Acquire();
1117 lock_.Release(); 1114 lock_.Release();
1118 #endif 1115 #endif
1119 } 1116 }
1120 1117
1121 } // namespace content_settings 1118 } // namespace content_settings
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/status/input_method_menu.cc ('k') | chrome/browser/custom_handlers/protocol_handler_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698