OLD | NEW |
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/prefs/pref_service.h" | 5 #include "chrome/browser/prefs/pref_service.h" |
6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
7 #include "chrome/browser/protector/base_prefs_change.h" | 7 #include "chrome/browser/protector/base_prefs_change.h" |
8 #include "chrome/browser/protector/protected_prefs_watcher.h" | 8 #include "chrome/browser/protector/protected_prefs_watcher.h" |
9 #include "chrome/browser/protector/protector_service.h" | 9 #include "chrome/browser/protector/protector_service.h" |
10 #include "chrome/browser/protector/protector_service_factory.h" | 10 #include "chrome/browser/protector/protector_service_factory.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 void BasePrefsChange::DismissOnPrefChange(const std::string& pref_name) { | 37 void BasePrefsChange::DismissOnPrefChange(const std::string& pref_name) { |
38 DCHECK(!pref_observer_.IsObserved(pref_name)); | 38 DCHECK(!pref_observer_.IsObserved(pref_name)); |
39 pref_observer_.Add(pref_name.c_str(), this); | 39 pref_observer_.Add(pref_name.c_str(), this); |
40 } | 40 } |
41 | 41 |
42 void BasePrefsChange::IgnorePrefChanges() { | 42 void BasePrefsChange::IgnorePrefChanges() { |
43 pref_observer_.RemoveAll(); | 43 pref_observer_.RemoveAll(); |
44 } | 44 } |
45 | 45 |
46 void BasePrefsChange::Observe(int type, | 46 void BasePrefsChange::OnPreferenceChanged(PrefServiceBase* service, |
47 const content::NotificationSource& source, | 47 const std::string& pref_name) { |
48 const content::NotificationDetails& details) { | 48 DCHECK(pref_observer_.IsObserved(pref_name)); |
49 DCHECK(type == chrome::NOTIFICATION_PREF_CHANGED); | |
50 const std::string* pref_name = content::Details<std::string>(details).ptr(); | |
51 DCHECK(pref_name && pref_observer_.IsObserved(*pref_name)); | |
52 // Will delete this instance. | 49 // Will delete this instance. |
53 ProtectorServiceFactory::GetForProfile(profile())->DismissChange(this); | 50 ProtectorServiceFactory::GetForProfile(profile())->DismissChange(this); |
54 } | 51 } |
55 | 52 |
56 } // namespace protector | 53 } // namespace protector |
OLD | NEW |