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

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

Issue 11414083: Remove PrefObserver usage, batch 9. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to sort-of good revision (r169014). 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"
19 #include "chrome/common/extensions/matcher/url_matcher.h" 18 #include "chrome/common/extensions/matcher/url_matcher.h"
20 19
21 class GURL; 20 class GURL;
22 class PrefService; 21 class PrefService;
23 22
24 namespace base { 23 namespace base {
25 class ListValue; 24 class ListValue;
26 } 25 }
27 26
28 namespace policy { 27 namespace policy {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // the prefs listeners. 105 // the prefs listeners.
107 // 106 //
108 // ShutdownOnUIThread must be called from UI before destruction, to release 107 // ShutdownOnUIThread must be called from UI before destruction, to release
109 // the prefs listeners on the UI thread. This is done from ProfileIOData. 108 // the prefs listeners on the UI thread. This is done from ProfileIOData.
110 // 109 //
111 // Update tasks from the UI thread can post safely to the IO thread, since the 110 // 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 111 // 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 112 // 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 113 // 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. 114 // the actual update starts, and grab a WeakPtr.
116 class URLBlacklistManager : public PrefObserver { 115 class URLBlacklistManager {
117 public: 116 public:
118 // Must be constructed on the UI thread. 117 // Must be constructed on the UI thread.
119 explicit URLBlacklistManager(PrefService* pref_service); 118 explicit URLBlacklistManager(PrefService* pref_service);
120 virtual ~URLBlacklistManager(); 119 virtual ~URLBlacklistManager();
121 120
122 // Must be called on the UI thread, before destruction. 121 // Must be called on the UI thread, before destruction.
123 void ShutdownOnUIThread(); 122 void ShutdownOnUIThread();
124 123
125 // Returns true if |url| is blocked by the current blacklist. Must be called 124 // Returns true if |url| is blocked by the current blacklist. Must be called
126 // from the IO thread. 125 // from the IO thread.
(...skipping 14 matching lines...) Expand all
141 // Updates the blacklist using the current preference values. 140 // Updates the blacklist using the current preference values.
142 // Virtual for testing. 141 // Virtual for testing.
143 virtual void Update(); 142 virtual void Update();
144 143
145 // Starts the blacklist update on the IO thread, using the filters in 144 // Starts the blacklist update on the IO thread, using the filters in
146 // |block| and |allow|. Protected for testing. 145 // |block| and |allow|. Protected for testing.
147 void UpdateOnIO(scoped_ptr<base::ListValue> block, 146 void UpdateOnIO(scoped_ptr<base::ListValue> block,
148 scoped_ptr<base::ListValue> allow); 147 scoped_ptr<base::ListValue> allow);
149 148
150 private: 149 private:
151 virtual void OnPreferenceChanged(PrefServiceBase* service,
152 const std::string& pref_name) OVERRIDE;
153
154 // --------- 150 // ---------
155 // UI thread 151 // UI thread
156 // --------- 152 // ---------
157 153
158 // Used to post update tasks to the UI thread. 154 // Used to post update tasks to the UI thread.
159 base::WeakPtrFactory<URLBlacklistManager> ui_weak_ptr_factory_; 155 base::WeakPtrFactory<URLBlacklistManager> ui_weak_ptr_factory_;
160 156
161 // Used to track the policies and update the blacklist on changes. 157 // Used to track the policies and update the blacklist on changes.
162 PrefChangeRegistrar pref_change_registrar_; 158 PrefChangeRegistrar pref_change_registrar_;
163 PrefService* pref_service_; // Weak. 159 PrefService* pref_service_; // Weak.
164 160
165 // --------- 161 // ---------
166 // IO thread 162 // IO thread
167 // --------- 163 // ---------
168 164
169 // Used to get |weak_ptr_| to self on the IO thread. 165 // Used to get |weak_ptr_| to self on the IO thread.
170 base::WeakPtrFactory<URLBlacklistManager> io_weak_ptr_factory_; 166 base::WeakPtrFactory<URLBlacklistManager> io_weak_ptr_factory_;
171 167
172 // The current blacklist. 168 // The current blacklist.
173 scoped_ptr<URLBlacklist> blacklist_; 169 scoped_ptr<URLBlacklist> blacklist_;
174 170
175 DISALLOW_COPY_AND_ASSIGN(URLBlacklistManager); 171 DISALLOW_COPY_AND_ASSIGN(URLBlacklistManager);
176 }; 172 };
177 173
178 } // namespace policy 174 } // namespace policy
179 175
180 #endif // CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ 176 #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