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

Side by Side Diff: chrome/browser/policy/url_blacklist_manager.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 years, 1 month 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
« no previous file with comments | « chrome/browser/policy/url_blacklist_manager.h ('k') | chrome/browser/prefs/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/policy/url_blacklist_manager.h" 5 #include "chrome/browser/policy/url_blacklist_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 void URLBlacklistManager::ShutdownOnUIThread() { 290 void URLBlacklistManager::ShutdownOnUIThread() {
291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
292 // Cancel any pending updates, and stop listening for pref change updates. 292 // Cancel any pending updates, and stop listening for pref change updates.
293 ui_weak_ptr_factory_.InvalidateWeakPtrs(); 293 ui_weak_ptr_factory_.InvalidateWeakPtrs();
294 pref_change_registrar_.RemoveAll(); 294 pref_change_registrar_.RemoveAll();
295 } 295 }
296 296
297 URLBlacklistManager::~URLBlacklistManager() { 297 URLBlacklistManager::~URLBlacklistManager() {
298 } 298 }
299 299
300 void URLBlacklistManager::Observe(int type, 300 void URLBlacklistManager::OnPreferenceChanged(PrefServiceBase* prefs,
301 const content::NotificationSource& source, 301 const std::string& pref_name) {
302 const content::NotificationDetails& details) {
303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
304 DCHECK(type == chrome::NOTIFICATION_PREF_CHANGED);
305 PrefService* prefs = content::Source<PrefService>(source).ptr();
306 DCHECK(prefs == pref_service_); 303 DCHECK(prefs == pref_service_);
307 std::string* pref_name = content::Details<std::string>(details).ptr(); 304 DCHECK(pref_name == prefs::kUrlBlacklist ||
308 DCHECK(*pref_name == prefs::kUrlBlacklist || 305 pref_name == prefs::kUrlWhitelist);
309 *pref_name == prefs::kUrlWhitelist);
310 ScheduleUpdate(); 306 ScheduleUpdate();
311 } 307 }
312 308
313 void URLBlacklistManager::ScheduleUpdate() { 309 void URLBlacklistManager::ScheduleUpdate() {
314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 310 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
315 // Cancel pending updates, if any. This can happen if two preferences that 311 // Cancel pending updates, if any. This can happen if two preferences that
316 // change the blacklist are updated in one message loop cycle. In those cases, 312 // change the blacklist are updated in one message loop cycle. In those cases,
317 // only rebuild the blacklist after all the preference updates are processed. 313 // only rebuild the blacklist after all the preference updates are processed.
318 ui_weak_ptr_factory_.InvalidateWeakPtrs(); 314 ui_weak_ptr_factory_.InvalidateWeakPtrs();
319 MessageLoop::current()->PostTask( 315 MessageLoop::current()->PostTask(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 363
368 // static 364 // static
369 void URLBlacklistManager::RegisterPrefs(PrefService* pref_service) { 365 void URLBlacklistManager::RegisterPrefs(PrefService* pref_service) {
370 pref_service->RegisterListPref(prefs::kUrlBlacklist, 366 pref_service->RegisterListPref(prefs::kUrlBlacklist,
371 PrefService::UNSYNCABLE_PREF); 367 PrefService::UNSYNCABLE_PREF);
372 pref_service->RegisterListPref(prefs::kUrlWhitelist, 368 pref_service->RegisterListPref(prefs::kUrlWhitelist,
373 PrefService::UNSYNCABLE_PREF); 369 PrefService::UNSYNCABLE_PREF);
374 } 370 }
375 371
376 } // namespace policy 372 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/url_blacklist_manager.h ('k') | chrome/browser/prefs/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698