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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_service.h

Issue 2776493005: Convert SupervisedUserResourceThrottle to a NavigationThrottle. (Closed)
Patch Set: Response to comments Created 3 years, 8 months 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
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 ~SupervisedUserService() override; 100 ~SupervisedUserService() override;
101 101
102 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 102 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
103 103
104 // Initializes this object. 104 // Initializes this object.
105 void Init(); 105 void Init();
106 106
107 void SetDelegate(Delegate* delegate); 107 void SetDelegate(Delegate* delegate);
108 108
109 // Returns the URL filter for the IO thread, for filtering network requests 109 // Returns the URL filter for filtering navigations and classifying sites in
110 // (in SupervisedUserResourceThrottle). 110 // the history view. Both this method and the returned filter may only be used
111 scoped_refptr<const SupervisedUserURLFilter> GetURLFilterForIOThread(); 111 // on the UI thread.
112 112 SupervisedUserURLFilter* GetURLFilter();
113 // Returns the URL filter for the UI thread, for filtering navigations and
114 // classifying sites in the history view.
115 SupervisedUserURLFilter* GetURLFilterForUIThread();
116 113
117 // Returns the whitelist service. 114 // Returns the whitelist service.
118 SupervisedUserWhitelistService* GetWhitelistService(); 115 SupervisedUserWhitelistService* GetWhitelistService();
119 116
120 const std::vector<scoped_refptr<SupervisedUserSiteList>>& whitelists() const { 117 const std::vector<scoped_refptr<SupervisedUserSiteList>>& whitelists() const {
121 return whitelists_; 118 return whitelists_;
122 } 119 }
123 120
124 // Whether the user can request to get access to blocked URLs or to new 121 // Whether the user can request to get access to blocked URLs or to new
125 // extensions. 122 // extensions.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 FRIEND_TEST_ALL_PREFIXES( 229 FRIEND_TEST_ALL_PREFIXES(
233 SupervisedUserServiceExtensionTest, 230 SupervisedUserServiceExtensionTest,
234 ExtensionManagementPolicyProviderWithoutSUInitiatedInstalls); 231 ExtensionManagementPolicyProviderWithoutSUInitiatedInstalls);
235 FRIEND_TEST_ALL_PREFIXES( 232 FRIEND_TEST_ALL_PREFIXES(
236 SupervisedUserServiceExtensionTest, 233 SupervisedUserServiceExtensionTest,
237 ExtensionManagementPolicyProviderWithSUInitiatedInstalls); 234 ExtensionManagementPolicyProviderWithSUInitiatedInstalls);
238 235
239 using CreatePermissionRequestCallback = 236 using CreatePermissionRequestCallback =
240 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>; 237 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>;
241 238
242 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which
243 // lives on the IO thread. This class mediates access to them and makes sure
244 // they are kept in sync.
245 class URLFilterContext {
246 public:
247 URLFilterContext();
248 ~URLFilterContext();
249
250 SupervisedUserURLFilter* ui_url_filter() const;
251 SupervisedUserURLFilter* io_url_filter() const;
252
253 void SetDefaultFilteringBehavior(
254 SupervisedUserURLFilter::FilteringBehavior behavior);
255 void LoadWhitelists(
256 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists);
257 // TODO(treib): Make SupervisedUserBlacklist refcounted, so the IO thread
258 // will retain a reference to the blacklist.
259 void SetBlacklist(const SupervisedUserBlacklist* blacklist);
260 bool HasBlacklist() const;
261 void SetManualHosts(std::unique_ptr<std::map<std::string, bool>> host_map);
262 void SetManualURLs(std::unique_ptr<std::map<GURL, bool>> url_map);
263
264 void InitAsyncURLChecker(
265 const scoped_refptr<net::URLRequestContextGetter>& context);
266 bool HasAsyncURLChecker() const;
267 void ClearAsyncURLChecker();
268
269 void Clear();
270
271 private:
272 void OnBlacklistLoaded(const base::Closure& callback);
273
274 // SupervisedUserURLFilter is refcounted because the IO thread filter is
275 // used both by ProfileImplIOData and OffTheRecordProfileIOData (to filter
276 // network requests), so they both keep a reference to it.
277 // Clients should not keep references to the UI thread filter, however
278 // (the filter will live as long as the profile lives, and afterwards it
279 // should not be used anymore either).
280 scoped_refptr<SupervisedUserURLFilter> ui_url_filter_;
281 scoped_refptr<SupervisedUserURLFilter> io_url_filter_;
282
283 DISALLOW_COPY_AND_ASSIGN(URLFilterContext);
284 };
285
286 // Use |SupervisedUserServiceFactory::GetForProfile(..)| to get 239 // Use |SupervisedUserServiceFactory::GetForProfile(..)| to get
287 // an instance of this service. 240 // an instance of this service.
288 explicit SupervisedUserService(Profile* profile); 241 explicit SupervisedUserService(Profile* profile);
289 242
290 void SetActive(bool active); 243 void SetActive(bool active);
291 244
292 #if !defined(OS_ANDROID) 245 #if !defined(OS_ANDROID)
293 void OnCustodianProfileDownloaded(const base::string16& full_name); 246 void OnCustodianProfileDownloaded(const base::string16& full_name);
294 247
295 void OnSupervisedUserRegistered(const AuthErrorCallback& callback, 248 void OnSupervisedUserRegistered(const AuthErrorCallback& callback,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 bool is_profile_active_; 384 bool is_profile_active_;
432 385
433 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; 386 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_;
434 387
435 // True only when |Init()| method has been called. 388 // True only when |Init()| method has been called.
436 bool did_init_; 389 bool did_init_;
437 390
438 // True only when |Shutdown()| method has been called. 391 // True only when |Shutdown()| method has been called.
439 bool did_shutdown_; 392 bool did_shutdown_;
440 393
441 URLFilterContext url_filter_context_; 394 SupervisedUserURLFilter url_filter_;
442 395
443 // Stores a map from extension_id -> approved version by the custodian. 396 // Stores a map from extension_id -> approved version by the custodian.
444 // It is only relevant for SU-initiated installs. 397 // It is only relevant for SU-initiated installs.
445 std::map<std::string, base::Version> approved_extensions_map_; 398 std::map<std::string, base::Version> approved_extensions_map_;
446 399
447 enum class BlacklistLoadState { 400 enum class BlacklistLoadState {
448 NOT_LOADED, 401 NOT_LOADED,
449 LOAD_STARTED, 402 LOAD_STARTED,
450 LOADED 403 LOADED
451 } blacklist_state_; 404 } blacklist_state_;
(...skipping 19 matching lines...) Expand all
471 424
472 base::ObserverList<SupervisedUserServiceObserver> observer_list_; 425 base::ObserverList<SupervisedUserServiceObserver> observer_list_;
473 426
474 // Prevents Sync from running until configuration is complete. 427 // Prevents Sync from running until configuration is complete.
475 std::unique_ptr<syncer::SyncSetupInProgressHandle> sync_blocker_; 428 std::unique_ptr<syncer::SyncSetupInProgressHandle> sync_blocker_;
476 429
477 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; 430 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_;
478 }; 431 };
479 432
480 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ 433 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698