OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/prefs/pref_change_registrar.h" | 14 #include "base/prefs/pref_change_registrar.h" |
15 #include "base/scoped_observer.h" | 15 #include "base/scoped_observer.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "chrome/browser/supervised_user/prototype/supervised_user_blacklist.h" |
17 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 18 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
18 #include "chrome/browser/supervised_user/supervised_users.h" | 19 #include "chrome/browser/supervised_user/supervised_users.h" |
19 #include "chrome/browser/sync/profile_sync_service_observer.h" | 20 #include "chrome/browser/sync/profile_sync_service_observer.h" |
20 #include "chrome/browser/sync/sync_type_preference_provider.h" | 21 #include "chrome/browser/sync/sync_type_preference_provider.h" |
21 #include "chrome/browser/ui/browser_list_observer.h" | 22 #include "chrome/browser/ui/browser_list_observer.h" |
22 #include "components/keyed_service/core/keyed_service.h" | 23 #include "components/keyed_service/core/keyed_service.h" |
23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
24 | 25 |
25 #if defined(ENABLE_EXTENSIONS) | 26 #if defined(ENABLE_EXTENSIONS) |
26 #include "extensions/browser/extension_registry_observer.h" | 27 #include "extensions/browser/extension_registry_observer.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 public: | 196 public: |
196 URLFilterContext(); | 197 URLFilterContext(); |
197 ~URLFilterContext(); | 198 ~URLFilterContext(); |
198 | 199 |
199 SupervisedUserURLFilter* ui_url_filter() const; | 200 SupervisedUserURLFilter* ui_url_filter() const; |
200 SupervisedUserURLFilter* io_url_filter() const; | 201 SupervisedUserURLFilter* io_url_filter() const; |
201 | 202 |
202 void SetDefaultFilteringBehavior( | 203 void SetDefaultFilteringBehavior( |
203 SupervisedUserURLFilter::FilteringBehavior behavior); | 204 SupervisedUserURLFilter::FilteringBehavior behavior); |
204 void LoadWhitelists(ScopedVector<SupervisedUserSiteList> site_lists); | 205 void LoadWhitelists(ScopedVector<SupervisedUserSiteList> site_lists); |
| 206 void LoadBlacklist(const base::FilePath& path); |
205 void SetManualHosts(scoped_ptr<std::map<std::string, bool> > host_map); | 207 void SetManualHosts(scoped_ptr<std::map<std::string, bool> > host_map); |
206 void SetManualURLs(scoped_ptr<std::map<GURL, bool> > url_map); | 208 void SetManualURLs(scoped_ptr<std::map<GURL, bool> > url_map); |
207 | 209 |
208 private: | 210 private: |
| 211 void OnBlacklistLoaded(); |
| 212 |
209 // SupervisedUserURLFilter is refcounted because the IO thread filter is | 213 // SupervisedUserURLFilter is refcounted because the IO thread filter is |
210 // used both by ProfileImplIOData and OffTheRecordProfileIOData (to filter | 214 // used both by ProfileImplIOData and OffTheRecordProfileIOData (to filter |
211 // network requests), so they both keep a reference to it. | 215 // network requests), so they both keep a reference to it. |
212 // Clients should not keep references to the UI thread filter, however | 216 // Clients should not keep references to the UI thread filter, however |
213 // (the filter will live as long as the profile lives, and afterwards it | 217 // (the filter will live as long as the profile lives, and afterwards it |
214 // should not be used anymore either). | 218 // should not be used anymore either). |
215 scoped_refptr<SupervisedUserURLFilter> ui_url_filter_; | 219 scoped_refptr<SupervisedUserURLFilter> ui_url_filter_; |
216 scoped_refptr<SupervisedUserURLFilter> io_url_filter_; | 220 scoped_refptr<SupervisedUserURLFilter> io_url_filter_; |
217 | 221 |
| 222 SupervisedUserBlacklist blacklist_; |
| 223 |
218 DISALLOW_COPY_AND_ASSIGN(URLFilterContext); | 224 DISALLOW_COPY_AND_ASSIGN(URLFilterContext); |
219 }; | 225 }; |
220 | 226 |
221 // Use |SupervisedUserServiceFactory::GetForProfile(..)| to get | 227 // Use |SupervisedUserServiceFactory::GetForProfile(..)| to get |
222 // an instance of this service. | 228 // an instance of this service. |
223 explicit SupervisedUserService(Profile* profile); | 229 explicit SupervisedUserService(Profile* profile); |
224 | 230 |
225 void SetActive(bool active); | 231 void SetActive(bool active); |
226 | 232 |
227 void OnCustodianProfileDownloaded(const base::string16& full_name); | 233 void OnCustodianProfileDownloaded(const base::string16& full_name); |
(...skipping 26 matching lines...) Expand all Loading... |
254 #endif | 260 #endif |
255 | 261 |
256 SupervisedUserSettingsService* GetSettingsService(); | 262 SupervisedUserSettingsService* GetSettingsService(); |
257 | 263 |
258 void OnSupervisedUserIdChanged(); | 264 void OnSupervisedUserIdChanged(); |
259 | 265 |
260 void OnDefaultFilteringBehaviorChanged(); | 266 void OnDefaultFilteringBehaviorChanged(); |
261 | 267 |
262 void UpdateSiteLists(); | 268 void UpdateSiteLists(); |
263 | 269 |
| 270 // Asynchronously loads a static blacklist from a binary file at |path| and |
| 271 // applies it to the URL filters. |
| 272 void LoadBlacklist(const base::FilePath& path); |
| 273 |
264 // Updates the manual overrides for hosts in the URL filters when the | 274 // Updates the manual overrides for hosts in the URL filters when the |
265 // corresponding preference is changed. | 275 // corresponding preference is changed. |
266 void UpdateManualHosts(); | 276 void UpdateManualHosts(); |
267 | 277 |
268 // Updates the manual overrides for URLs in the URL filters when the | 278 // Updates the manual overrides for URLs in the URL filters when the |
269 // corresponding preference is changed. | 279 // corresponding preference is changed. |
270 void UpdateManualURLs(); | 280 void UpdateManualURLs(); |
271 | 281 |
272 // Returns the human readable name of the supervised user. | 282 // Returns the human readable name of the supervised user. |
273 std::string GetSupervisedUserName() const; | 283 std::string GetSupervisedUserName() const; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // Used to create permission requests. | 317 // Used to create permission requests. |
308 scoped_ptr<PermissionRequestCreator> permissions_creator_; | 318 scoped_ptr<PermissionRequestCreator> permissions_creator_; |
309 | 319 |
310 // True iff we are waiting for a permission request to be issued. | 320 // True iff we are waiting for a permission request to be issued. |
311 bool waiting_for_permissions_; | 321 bool waiting_for_permissions_; |
312 | 322 |
313 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; | 323 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; |
314 }; | 324 }; |
315 | 325 |
316 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 326 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
OLD | NEW |