OLD | NEW |
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 #ifndef CHROME_BROWSER_PREFS_PREF_NOTIFIER_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_NOTIFIER_H_ |
6 #define CHROME_BROWSER_PREFS_PREF_NOTIFIER_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_NOTIFIER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 // Convenience method to be called when a preference is set in the | 65 // Convenience method to be called when a preference is set in the |
66 // USER_STORE. See OnPreferenceSet(). | 66 // USER_STORE. See OnPreferenceSet(). |
67 void OnUserPreferenceSet(const char* pref_name); | 67 void OnUserPreferenceSet(const char* pref_name); |
68 | 68 |
69 // For the given pref_name, fire any observer of the pref. Virtual so it can | 69 // For the given pref_name, fire any observer of the pref. Virtual so it can |
70 // be mocked for unit testing. | 70 // be mocked for unit testing. |
71 virtual void FireObservers(const char* path); | 71 virtual void FireObservers(const char* path); |
72 | 72 |
73 // If the pref at the given path changes, we call the observer's Observe | 73 // If the pref at the given path changes, we call the observer's Observe |
74 // method with NOTIFY_PREF_CHANGED. | 74 // method with PREF_CHANGED. |
75 void AddPrefObserver(const char* path, NotificationObserver* obs); | 75 void AddPrefObserver(const char* path, NotificationObserver* obs); |
76 void RemovePrefObserver(const char* path, NotificationObserver* obs); | 76 void RemovePrefObserver(const char* path, NotificationObserver* obs); |
77 | 77 |
78 protected: | 78 protected: |
79 // A map from pref names to a list of observers. Observers get fired in the | 79 // A map from pref names to a list of observers. Observers get fired in the |
80 // order they are added. These should only be accessed externally for unit | 80 // order they are added. These should only be accessed externally for unit |
81 // testing. | 81 // testing. |
82 typedef ObserverList<NotificationObserver> NotificationObserverList; | 82 typedef ObserverList<NotificationObserver> NotificationObserverList; |
83 typedef base::hash_map<std::string, NotificationObserverList*> | 83 typedef base::hash_map<std::string, NotificationObserverList*> |
84 PrefObserverMap; | 84 PrefObserverMap; |
(...skipping 19 matching lines...) Expand all Loading... |
104 | 104 |
105 // NotificationObserver methods: | 105 // NotificationObserver methods: |
106 virtual void Observe(NotificationType type, | 106 virtual void Observe(NotificationType type, |
107 const NotificationSource& source, | 107 const NotificationSource& source, |
108 const NotificationDetails& details); | 108 const NotificationDetails& details); |
109 | 109 |
110 DISALLOW_COPY_AND_ASSIGN(PrefNotifier); | 110 DISALLOW_COPY_AND_ASSIGN(PrefNotifier); |
111 }; | 111 }; |
112 | 112 |
113 #endif // CHROME_BROWSER_PREFS_PREF_NOTIFIER_H_ | 113 #endif // CHROME_BROWSER_PREFS_PREF_NOTIFIER_H_ |
OLD | NEW |