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

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

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
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 #ifndef CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ 5 #ifndef CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_
6 #define CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ 6 #define CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/hash_tables.h" 14 #include "base/hash_tables.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/prefs/public/pref_change_registrar.h" 17 #include "base/prefs/public/pref_change_registrar.h"
18 #include "base/prefs/public/pref_observer.h"
18 #include "chrome/common/extensions/matcher/url_matcher.h" 19 #include "chrome/common/extensions/matcher/url_matcher.h"
19 #include "content/public/browser/notification_observer.h"
20 20
21 class GURL; 21 class GURL;
22 class PrefService; 22 class PrefService;
23 23
24 namespace base { 24 namespace base {
25 class ListValue; 25 class ListValue;
26 } 26 }
27 27
28 namespace policy { 28 namespace policy {
29 29
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // the prefs listeners. 106 // the prefs listeners.
107 // 107 //
108 // ShutdownOnUIThread must be called from UI before destruction, to release 108 // ShutdownOnUIThread must be called from UI before destruction, to release
109 // the prefs listeners on the UI thread. This is done from ProfileIOData. 109 // the prefs listeners on the UI thread. This is done from ProfileIOData.
110 // 110 //
111 // Update tasks from the UI thread can post safely to the IO thread, since the 111 // Update tasks from the UI thread can post safely to the IO thread, since the
112 // destruction order of Profile and ProfileIOData guarantees that if this 112 // destruction order of Profile and ProfileIOData guarantees that if this
113 // exists in UI, then a potential destruction on IO will come after any task 113 // exists in UI, then a potential destruction on IO will come after any task
114 // posted to IO from that method on UI. This is used to go through IO before 114 // posted to IO from that method on UI. This is used to go through IO before
115 // the actual update starts, and grab a WeakPtr. 115 // the actual update starts, and grab a WeakPtr.
116 class URLBlacklistManager : public content::NotificationObserver { 116 class URLBlacklistManager : public PrefObserver {
117 public: 117 public:
118 // Must be constructed on the UI thread. 118 // Must be constructed on the UI thread.
119 explicit URLBlacklistManager(PrefService* pref_service); 119 explicit URLBlacklistManager(PrefService* pref_service);
120 virtual ~URLBlacklistManager(); 120 virtual ~URLBlacklistManager();
121 121
122 // Must be called on the UI thread, before destruction. 122 // Must be called on the UI thread, before destruction.
123 void ShutdownOnUIThread(); 123 void ShutdownOnUIThread();
124 124
125 // Returns true if |url| is blocked by the current blacklist. Must be called 125 // Returns true if |url| is blocked by the current blacklist. Must be called
126 // from the IO thread. 126 // from the IO thread.
(...skipping 14 matching lines...) Expand all
141 // Updates the blacklist using the current preference values. 141 // Updates the blacklist using the current preference values.
142 // Virtual for testing. 142 // Virtual for testing.
143 virtual void Update(); 143 virtual void Update();
144 144
145 // Starts the blacklist update on the IO thread, using the filters in 145 // Starts the blacklist update on the IO thread, using the filters in
146 // |block| and |allow|. Protected for testing. 146 // |block| and |allow|. Protected for testing.
147 void UpdateOnIO(scoped_ptr<base::ListValue> block, 147 void UpdateOnIO(scoped_ptr<base::ListValue> block,
148 scoped_ptr<base::ListValue> allow); 148 scoped_ptr<base::ListValue> allow);
149 149
150 private: 150 private:
151 virtual void Observe(int type, 151 virtual void OnPreferenceChanged(PrefServiceBase* service,
152 const content::NotificationSource& source, 152 const std::string& pref_name) OVERRIDE;
153 const content::NotificationDetails& details) OVERRIDE;
154 153
155 // --------- 154 // ---------
156 // UI thread 155 // UI thread
157 // --------- 156 // ---------
158 157
159 // Used to post update tasks to the UI thread. 158 // Used to post update tasks to the UI thread.
160 base::WeakPtrFactory<URLBlacklistManager> ui_weak_ptr_factory_; 159 base::WeakPtrFactory<URLBlacklistManager> ui_weak_ptr_factory_;
161 160
162 // Used to track the policies and update the blacklist on changes. 161 // Used to track the policies and update the blacklist on changes.
163 PrefChangeRegistrar pref_change_registrar_; 162 PrefChangeRegistrar pref_change_registrar_;
164 PrefService* pref_service_; // Weak. 163 PrefService* pref_service_; // Weak.
165 164
166 // --------- 165 // ---------
167 // IO thread 166 // IO thread
168 // --------- 167 // ---------
169 168
170 // Used to get |weak_ptr_| to self on the IO thread. 169 // Used to get |weak_ptr_| to self on the IO thread.
171 base::WeakPtrFactory<URLBlacklistManager> io_weak_ptr_factory_; 170 base::WeakPtrFactory<URLBlacklistManager> io_weak_ptr_factory_;
172 171
173 // The current blacklist. 172 // The current blacklist.
174 scoped_ptr<URLBlacklist> blacklist_; 173 scoped_ptr<URLBlacklist> blacklist_;
175 174
176 DISALLOW_COPY_AND_ASSIGN(URLBlacklistManager); 175 DISALLOW_COPY_AND_ASSIGN(URLBlacklistManager);
177 }; 176 };
178 177
179 } // namespace policy 178 } // namespace policy
180 179
181 #endif // CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ 180 #endif // CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_subsystem.cc ('k') | chrome/browser/policy/url_blacklist_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698