blob: 81ca0d22f4ea029117ded0a522759165352c6861 [file] [log] [blame]
[email protected]cce15bb2014-06-17 13:43:511// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]0850e842013-01-19 03:44:312// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]cce15bb2014-06-17 13:43:515#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_
6#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_
[email protected]0850e842013-01-19 03:44:317
avi664c07b2015-12-26 02:18:318#include <stddef.h>
9
treib950c6e82014-09-23 13:07:2910#include <map>
dchengf624e472016-04-12 08:33:1711#include <memory>
treib950c6e82014-09-23 13:07:2912#include <string>
[email protected]0850e842013-01-19 03:44:3113#include <vector>
14
[email protected]438f7e12013-08-07 06:59:0015#include "base/callback.h"
[email protected]076ebeda2014-06-06 21:47:2616#include "base/gtest_prod_util.h"
avi664c07b2015-12-26 02:18:3117#include "base/macros.h"
thestig7790a352015-08-22 00:05:1118#include "base/memory/scoped_vector.h"
treibab0a39e2014-09-24 14:48:2819#include "base/observer_list.h"
[email protected]f2253ac2014-05-28 08:37:2120#include "base/scoped_observer.h"
[email protected]f9b294362013-06-10 20:22:3121#include "base/strings/string16.h"
avi664c07b2015-12-26 02:18:3122#include "build/build_config.h"
treibf38cc252016-04-07 14:44:1123#include "chrome/browser/net/file_downloader.h"
atanasovaac676032016-04-05 16:31:0524#include "chrome/browser/supervised_user/experimental/safe_search_url_reporter.h"
treib4edbded2014-09-05 08:43:5525#include "chrome/browser/supervised_user/experimental/supervised_user_blacklist.h"
[email protected]cce15bb2014-06-17 13:43:5126#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
27#include "chrome/browser/supervised_user/supervised_users.h"
[email protected]514fcf22013-08-13 06:37:2428#include "chrome/browser/ui/browser_list_observer.h"
[email protected]12b7af32014-03-13 05:28:2029#include "components/keyed_service/core/keyed_service.h"
brettwb1fc1b82016-02-02 00:19:0830#include "components/prefs/pref_change_registrar.h"
droger507e7e2f2015-04-03 18:56:2331#include "components/sync_driver/sync_service_observer.h"
blundell7282b512015-11-09 07:21:1132#include "components/sync_driver/sync_type_preference_provider.h"
maxbogue8e4fb452015-02-11 20:26:0933#include "net/url_request/url_request_context_getter.h"
[email protected]c14a6802014-07-11 21:51:1234
35#if defined(ENABLE_EXTENSIONS)
mamire9609642016-06-28 22:17:5436#include "extensions/browser/extension_registry_observer.h"
[email protected]301116c62013-11-26 10:37:4537#include "extensions/browser/management_policy.h"
[email protected]c14a6802014-07-11 21:51:1238#endif
[email protected]0850e842013-01-19 03:44:3139
[email protected]509ad1a92013-03-19 21:41:0640class Browser;
[email protected]acfcfbb2013-05-13 18:01:2741class GoogleServiceAuthError;
[email protected]4db65f952014-05-20 15:46:3042class PermissionRequestCreator;
[email protected]0850e842013-01-19 03:44:3143class Profile;
[email protected]cce15bb2014-06-17 13:43:5144class SupervisedUserRegistrationUtility;
treibab0a39e2014-09-24 14:48:2845class SupervisedUserServiceObserver;
[email protected]cce15bb2014-06-17 13:43:5146class SupervisedUserSettingsService;
47class SupervisedUserSiteList;
48class SupervisedUserURLFilter;
bauerb4da36132014-12-26 19:53:1349class SupervisedUserWhitelistService;
[email protected]0850e842013-01-19 03:44:3150
treibdaece84f2014-09-05 12:58:1551namespace base {
52class FilePath;
treibf832a992015-03-24 18:09:2453class Version;
treibdaece84f2014-09-05 12:58:1554}
55
treib565a0192014-12-04 13:17:3156namespace content {
57class WebContents;
58}
59
[email protected]f2253ac2014-05-28 08:37:2160namespace extensions {
61class ExtensionRegistry;
62}
63
tommyclif3a1551e2016-06-21 18:11:2364namespace sync_driver {
65class SyncSetupInProgressHandle;
66}
67
[email protected]443e9312013-05-06 06:17:3468namespace user_prefs {
69class PrefRegistrySyncable;
70}
71
[email protected]cce15bb2014-06-17 13:43:5172// This class handles all the information related to a given supervised profile
[email protected]0850e842013-01-19 03:44:3173// (e.g. the installed content packs, the default URL filtering behavior, or
74// manual whitelist/blacklist overrides).
[email protected]cce15bb2014-06-17 13:43:5175class SupervisedUserService : public KeyedService,
[email protected]c14a6802014-07-11 21:51:1276#if defined(ENABLE_EXTENSIONS)
mamire9609642016-06-28 22:17:5477 public extensions::ExtensionRegistryObserver,
[email protected]cce15bb2014-06-17 13:43:5178 public extensions::ManagementPolicy::Provider,
[email protected]c14a6802014-07-11 21:51:1279#endif
[email protected]3a276ff2014-08-12 14:22:0980 public SyncTypePreferenceProvider,
jam1c5a91492016-02-24 20:47:5381#if !defined(OS_ANDROID)
droger507e7e2f2015-04-03 18:56:2382 public sync_driver::SyncServiceObserver,
bauerbce9a1a82014-12-18 13:34:2483 public chrome::BrowserListObserver,
bauerb5f8cda92015-10-07 15:36:4484#endif
bauerbce9a1a82014-12-18 13:34:2485 public SupervisedUserURLFilter::Observer {
[email protected]0850e842013-01-19 03:44:3186 public:
treib8ecc1eb52015-03-04 18:29:0687 using NavigationBlockedCallback = base::Callback<void(content::WebContents*)>;
88 using AuthErrorCallback = base::Callback<void(const GoogleServiceAuthError&)>;
89 using SuccessCallback = base::Callback<void(bool)>;
[email protected]0850e842013-01-19 03:44:3190
[email protected]f085fdd52014-06-11 18:09:2091 class Delegate {
92 public:
93 virtual ~Delegate() {}
94 // Returns true to indicate that the delegate handled the (de)activation, or
[email protected]cce15bb2014-06-17 13:43:5195 // false to indicate that the SupervisedUserService itself should handle it.
[email protected]f085fdd52014-06-11 18:09:2096 virtual bool SetActive(bool active) = 0;
[email protected]f085fdd52014-06-11 18:09:2097 };
98
dchengc072fff2014-10-21 11:39:0599 ~SupervisedUserService() override;
[email protected]0850e842013-01-19 03:44:31100
[email protected]37ca3fe02013-07-05 15:32:44101 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
[email protected]0850e842013-01-19 03:44:31102
bauerb5f8cda92015-10-07 15:36:44103 // Initializes this object.
104 void Init();
105
[email protected]f085fdd52014-06-11 18:09:20106 void SetDelegate(Delegate* delegate);
107
[email protected]0850e842013-01-19 03:44:31108 // Returns the URL filter for the IO thread, for filtering network requests
[email protected]cce15bb2014-06-17 13:43:51109 // (in SupervisedUserResourceThrottle).
110 scoped_refptr<const SupervisedUserURLFilter> GetURLFilterForIOThread();
[email protected]0850e842013-01-19 03:44:31111
112 // Returns the URL filter for the UI thread, for filtering navigations and
113 // classifying sites in the history view.
[email protected]cce15bb2014-06-17 13:43:51114 SupervisedUserURLFilter* GetURLFilterForUIThread();
[email protected]0850e842013-01-19 03:44:31115
bauerb4da36132014-12-26 19:53:13116 // Returns the whitelist service.
117 SupervisedUserWhitelistService* GetWhitelistService();
118
atanasova9572aaf2016-02-26 18:08:26119 const std::vector<scoped_refptr<SupervisedUserSiteList>>& whitelists() const {
120 return whitelists_;
121 }
122
treib8ecc1eb52015-03-04 18:29:06123 // Whether the user can request to get access to blocked URLs or to new
124 // extensions.
[email protected]0369d6ab2013-08-09 01:52:59125 bool AccessRequestsEnabled();
126
treib8ecc1eb52015-03-04 18:29:06127 // Adds an access request for the given URL.
128 void AddURLAccessRequest(const GURL& url, const SuccessCallback& callback);
129
atanasovaac676032016-04-05 16:31:05130 // Reports |url| to the SafeSearch API, because the user thinks this is an
131 // inappropriate URL.
132 void ReportURL(const GURL& url, const SuccessCallback& callback);
133
mamire9609642016-06-28 22:17:54134 // Adds an install request for the given WebStore item (App/Extension).
135 void AddExtensionInstallRequest(const std::string& extension_id,
136 const base::Version& version,
137 const SuccessCallback& callback);
138
139 // Same as above, but without a callback, just logging errors on failure.
140 void AddExtensionInstallRequest(const std::string& extension_id,
141 const base::Version& version);
142
treib8ecc1eb52015-03-04 18:29:06143 // Adds an update request for the given WebStore item (App/Extension).
144 void AddExtensionUpdateRequest(const std::string& extension_id,
treibf832a992015-03-24 18:09:24145 const base::Version& version,
treib8ecc1eb52015-03-04 18:29:06146 const SuccessCallback& callback);
[email protected]e861bba2013-06-17 15:20:54147
treib40d3ad92015-10-20 18:15:42148 // Same as above, but without a callback, just logging errors on failure.
149 void AddExtensionUpdateRequest(const std::string& extension_id,
150 const base::Version& version);
151
mamire9609642016-06-28 22:17:54152 // Get the string used to identify an extension install or update request.
153 // Public for testing.
154 static std::string GetExtensionRequestId(const std::string& extension_id,
155 const base::Version& version);
treib40d3ad92015-10-20 18:15:42156
[email protected]a9c2d642013-05-31 14:37:14157 // Returns the email address of the custodian.
158 std::string GetCustodianEmailAddress() const;
159
[email protected]fae057a2013-06-21 22:46:08160 // Returns the name of the custodian, or the email address if the name is
161 // empty.
162 std::string GetCustodianName() const;
163
treib3e7ecf72014-10-24 16:44:07164 // Returns the email address of the second custodian, or the empty string
165 // if there is no second custodian.
166 std::string GetSecondCustodianEmailAddress() const;
167
168 // Returns the name of the second custodian, or the email address if the name
169 // is empty, or the empty string is there is no second custodian.
170 std::string GetSecondCustodianName() const;
171
treib2170ea02015-10-13 14:55:12172 // Returns a message saying that extensions can only be modified by the
173 // custodian.
174 base::string16 GetExtensionsLockedMessage() const;
175
jam1c5a91492016-02-24 20:47:53176#if !defined(OS_ANDROID)
[email protected]a243d644c2013-06-20 18:37:55177 // Initializes this profile for syncing, using the provided |refresh_token| to
178 // mint access tokens for Sync.
179 void InitSync(const std::string& refresh_token);
[email protected]acfcfbb2013-05-13 18:01:27180
[email protected]cce15bb2014-06-17 13:43:51181 // Convenience method that registers this supervised user using
[email protected]458d59442013-08-01 14:19:32182 // |registration_utility| and initializes sync with the returned token.
183 // The |callback| will be called when registration is complete,
[email protected]3a276ff2014-08-12 14:22:09184 // whether it succeeded or not -- unless registration was cancelled manually,
[email protected]458d59442013-08-01 14:19:32185 // in which case the callback will be ignored.
[email protected]cce15bb2014-06-17 13:43:51186 void RegisterAndInitSync(
187 SupervisedUserRegistrationUtility* registration_utility,
188 Profile* custodian_profile,
189 const std::string& supervised_user_id,
190 const AuthErrorCallback& callback);
thestig1b76f1a2015-09-30 22:52:38191#endif
[email protected]acfcfbb2013-05-13 18:01:27192
[email protected]438f7e12013-08-07 06:59:00193 void AddNavigationBlockedCallback(const NavigationBlockedCallback& callback);
194 void DidBlockNavigation(content::WebContents* web_contents);
195
treibab0a39e2014-09-24 14:48:28196 void AddObserver(SupervisedUserServiceObserver* observer);
197 void RemoveObserver(SupervisedUserServiceObserver* observer);
198
treib531fc7312014-12-09 12:49:20199 void AddPermissionRequestCreator(
dchengf624e472016-04-12 08:33:17200 std::unique_ptr<PermissionRequestCreator> creator);
bauerb646019b12014-10-16 16:23:09201
dchengf624e472016-04-12 08:33:17202 void SetSafeSearchURLReporter(
203 std::unique_ptr<SafeSearchURLReporter> reporter);
atanasovaac676032016-04-05 16:31:05204
bauerbb519f8252016-05-13 09:16:39205 // Returns true if the syncer::SESSIONS type should be included in Sync.
206 // Public for testing.
207 bool IncludesSyncSessionsType() const;
208
bauerb5f8cda92015-10-07 15:36:44209 // ProfileKeyedService override:
210 void Shutdown() override;
211
[email protected]3a276ff2014-08-12 14:22:09212 // SyncTypePreferenceProvider implementation:
dchengc072fff2014-10-21 11:39:05213 syncer::ModelTypeSet GetPreferredDataTypes() const override;
[email protected]3a276ff2014-08-12 14:22:09214
jam1c5a91492016-02-24 20:47:53215#if !defined(OS_ANDROID)
droger507e7e2f2015-04-03 18:56:23216 // sync_driver::SyncServiceObserver implementation:
dchengc072fff2014-10-21 11:39:05217 void OnStateChanged() override;
[email protected]0850e842013-01-19 03:44:31218
[email protected]dfddd022013-07-10 17:29:48219 // chrome::BrowserListObserver implementation:
dchengc072fff2014-10-21 11:39:05220 void OnBrowserSetLastActive(Browser* browser) override;
jam1c5a91492016-02-24 20:47:53221#endif // !defined(OS_ANDROID)
[email protected]dfddd022013-07-10 17:29:48222
bauerbce9a1a82014-12-18 13:34:24223 // SupervisedUserURLFilter::Observer implementation:
224 void OnSiteListUpdated() override;
225
[email protected]0850e842013-01-19 03:44:31226 private:
[email protected]cce15bb2014-06-17 13:43:51227 friend class SupervisedUserServiceExtensionTestBase;
228 friend class SupervisedUserServiceFactory;
pvalenzuelac2ca4582014-10-14 19:24:57229 FRIEND_TEST_ALL_PREFIXES(SingleClientSupervisedUserSettingsSyncTest, Sanity);
[email protected]cce15bb2014-06-17 13:43:51230 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration);
mamire9609642016-06-28 22:17:54231 FRIEND_TEST_ALL_PREFIXES(
232 SupervisedUserServiceExtensionTest,
233 ExtensionManagementPolicyProviderWithoutSUInitiatedInstalls);
234 FRIEND_TEST_ALL_PREFIXES(
235 SupervisedUserServiceExtensionTest,
236 ExtensionManagementPolicyProviderWithSUInitiatedInstalls);
bauerb95a50682015-01-07 17:04:15237
treib8ecc1eb52015-03-04 18:29:06238 using CreatePermissionRequestCallback =
239 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>;
240
[email protected]cce15bb2014-06-17 13:43:51241 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which
242 // lives on the IO thread. This class mediates access to them and makes sure
243 // they are kept in sync.
[email protected]0850e842013-01-19 03:44:31244 class URLFilterContext {
245 public:
246 URLFilterContext();
247 ~URLFilterContext();
248
[email protected]cce15bb2014-06-17 13:43:51249 SupervisedUserURLFilter* ui_url_filter() const;
250 SupervisedUserURLFilter* io_url_filter() const;
[email protected]0850e842013-01-19 03:44:31251
252 void SetDefaultFilteringBehavior(
[email protected]cce15bb2014-06-17 13:43:51253 SupervisedUserURLFilter::FilteringBehavior behavior);
bauerb95a50682015-01-07 17:04:15254 void LoadWhitelists(
255 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists);
treib9cc1b112016-01-08 10:08:01256 // TODO(treib): Make SupervisedUserBlacklist refcounted, so the IO thread
257 // will retain a reference to the blacklist.
258 void SetBlacklist(const SupervisedUserBlacklist* blacklist);
259 bool HasBlacklist() const;
dchengf624e472016-04-12 08:33:17260 void SetManualHosts(std::unique_ptr<std::map<std::string, bool>> host_map);
261 void SetManualURLs(std::unique_ptr<std::map<GURL, bool>> url_map);
[email protected]0850e842013-01-19 03:44:31262
maxbogue8e4fb452015-02-11 20:26:09263 void InitAsyncURLChecker(
treibd3f8b7a2015-04-10 11:41:33264 const scoped_refptr<net::URLRequestContextGetter>& context);
treib9cc1b112016-01-08 10:08:01265 bool HasAsyncURLChecker() const;
266 void ClearAsyncURLChecker();
treib9e4fab902014-10-29 14:25:26267
treib22c3a042015-01-15 21:30:13268 void Clear();
269
[email protected]0850e842013-01-19 03:44:31270 private:
bauerbce9a1a82014-12-18 13:34:24271 void OnBlacklistLoaded(const base::Closure& callback);
treib4edbded2014-09-05 08:43:55272
[email protected]cce15bb2014-06-17 13:43:51273 // SupervisedUserURLFilter is refcounted because the IO thread filter is
274 // used both by ProfileImplIOData and OffTheRecordProfileIOData (to filter
[email protected]0850e842013-01-19 03:44:31275 // network requests), so they both keep a reference to it.
276 // Clients should not keep references to the UI thread filter, however
277 // (the filter will live as long as the profile lives, and afterwards it
278 // should not be used anymore either).
[email protected]cce15bb2014-06-17 13:43:51279 scoped_refptr<SupervisedUserURLFilter> ui_url_filter_;
280 scoped_refptr<SupervisedUserURLFilter> io_url_filter_;
[email protected]0850e842013-01-19 03:44:31281
[email protected]0850e842013-01-19 03:44:31282 DISALLOW_COPY_AND_ASSIGN(URLFilterContext);
283 };
284
[email protected]cce15bb2014-06-17 13:43:51285 // Use |SupervisedUserServiceFactory::GetForProfile(..)| to get
[email protected]3bf45d02013-07-10 00:03:41286 // an instance of this service.
[email protected]cce15bb2014-06-17 13:43:51287 explicit SupervisedUserService(Profile* profile);
[email protected]3bf45d02013-07-10 00:03:41288
[email protected]f085fdd52014-06-11 18:09:20289 void SetActive(bool active);
290
jam1c5a91492016-02-24 20:47:53291#if !defined(OS_ANDROID)
[email protected]0085863a2013-12-06 21:19:03292 void OnCustodianProfileDownloaded(const base::string16& full_name);
[email protected]200729f82013-06-22 07:05:55293
[email protected]cce15bb2014-06-17 13:43:51294 void OnSupervisedUserRegistered(const AuthErrorCallback& callback,
295 Profile* custodian_profile,
296 const GoogleServiceAuthError& auth_error,
297 const std::string& token);
[email protected]acfcfbb2013-05-13 18:01:27298
[email protected]a243d644c2013-06-20 18:37:55299 void SetupSync();
[email protected]6e08b9a62014-07-08 00:32:48300 void StartSetupSync();
301 void FinishSetupSyncWhenReady();
302 void FinishSetupSync();
bauerb5f8cda92015-10-07 15:36:44303#endif
[email protected]a243d644c2013-06-20 18:37:55304
[email protected]cce15bb2014-06-17 13:43:51305 bool ProfileIsSupervised() const;
[email protected]e000daf2013-07-31 16:50:58306
treib3fce4e92014-09-26 16:06:25307 void OnCustodianInfoChanged();
308
[email protected]c14a6802014-07-11 21:51:12309#if defined(ENABLE_EXTENSIONS)
treibbb9a1962015-02-25 13:40:59310 // extensions::ManagementPolicy::Provider implementation:
311 std::string GetDebugPolicyProviderName() const override;
312 bool UserMayLoad(const extensions::Extension* extension,
313 base::string16* error) const override;
treib755c12d2015-03-30 08:46:25314 bool UserMayModifySettings(const extensions::Extension* extension,
315 base::string16* error) const override;
treibbb9a1962015-02-25 13:40:59316 bool MustRemainInstalled(const extensions::Extension* extension,
317 base::string16* error) const override;
mamire9609642016-06-28 22:17:54318 bool MustRemainDisabled(const extensions::Extension* extension,
319 extensions::Extension::DisableReason* reason,
320 base::string16* error) const override;
321
322 // extensions::ExtensionRegistryObserver overrides:
323 void OnExtensionInstalled(content::BrowserContext* browser_context,
324 const extensions::Extension* extension,
325 bool is_update) override;
[email protected]0850e842013-01-19 03:44:31326
mamir192d7882016-06-22 17:10:16327 // An extension can be in one of the following states:
328 //
329 // FORCED: if it is installed by the custodian.
mamire9609642016-06-28 22:17:54330 // REQUIRE_APPROVAL: if it is installed by the supervised user and
331 // hasn't been approved by the custodian yet.
mamir192d7882016-06-22 17:10:16332 // ALLOWED: Components, Themes, Default extensions ..etc
333 // are generally allowed. Extensions that have been approved by the
334 // custodian are also allowed.
335 // BLOCKED: if it is not ALLOWED or FORCED
336 // and supervised users initiated installs are disabled.
mamire9609642016-06-28 22:17:54337 enum class ExtensionState { FORCED, BLOCKED, ALLOWED, REQUIRE_APPROVAL };
mamir192d7882016-06-22 17:10:16338
mamire9609642016-06-28 22:17:54339 // Returns the state of an extension whether being FORCED, BLOCKED, ALLOWED or
340 // REQUIRE_APPROVAL from the Supervised User service's point of view.
mamir192d7882016-06-22 17:10:16341 ExtensionState GetExtensionState(
mamire9609642016-06-28 22:17:54342 const extensions::Extension& extension) const;
mamir192d7882016-06-22 17:10:16343
[email protected]c14a6802014-07-11 21:51:12344 // Extensions helper to SetActive().
345 void SetExtensionsActive();
mamire9609642016-06-28 22:17:54346
347 // Enables/Disables extensions upon change in approved version of the
348 // extension_id.
349 void ChangeExtensionStateIfNecessary(const std::string& extension_id);
350
351 // Updates the map of approved extensions when the corresponding preference
352 // is changed.
353 void UpdateApprovedExtensions();
[email protected]c14a6802014-07-11 21:51:12354#endif
355
[email protected]cce15bb2014-06-17 13:43:51356 SupervisedUserSettingsService* GetSettingsService();
[email protected]e861bba2013-06-17 15:20:54357
bauerbd3a36cc42014-10-01 13:05:49358 size_t FindEnabledPermissionRequestCreator(size_t start);
treib8ecc1eb52015-03-04 18:29:06359 void AddPermissionRequestInternal(
360 const CreatePermissionRequestCallback& create_request,
361 const SuccessCallback& callback,
362 size_t index);
363 void OnPermissionRequestIssued(
364 const CreatePermissionRequestCallback& create_request,
365 const SuccessCallback& callback,
366 size_t index,
367 bool success);
bauerbd3a36cc42014-10-01 13:05:49368
[email protected]cce15bb2014-06-17 13:43:51369 void OnSupervisedUserIdChanged();
[email protected]f085fdd52014-06-11 18:09:20370
[email protected]0850e842013-01-19 03:44:31371 void OnDefaultFilteringBehaviorChanged();
372
treib9cc1b112016-01-08 10:08:01373 void OnSafeSitesSettingChanged();
374
bauerb95a50682015-01-07 17:04:15375 void OnSiteListsChanged(
376 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists);
[email protected]0850e842013-01-19 03:44:31377
treib2fd187392015-04-16 17:19:38378 // Asynchronously loads a blacklist from a binary file at |path| and applies
379 // it to the URL filters. If no file exists at |path| yet, downloads a file
380 // from |url| and stores it at |path| first.
treibf136dfb2014-09-25 17:37:47381 void LoadBlacklist(const base::FilePath& path, const GURL& url);
382
treib2fd187392015-04-16 17:19:38383 void OnBlacklistFileChecked(const base::FilePath& path,
384 const GURL& url,
385 bool file_exists);
386
387 // Asynchronously loads a blacklist from a binary file at |path| and applies
388 // it to the URL filters.
treibf136dfb2014-09-25 17:37:47389 void LoadBlacklistFromFile(const base::FilePath& path);
390
treibf38cc252016-04-07 14:44:11391 void OnBlacklistDownloadDone(const base::FilePath& path,
392 FileDownloader::Result result);
treib4edbded2014-09-05 08:43:55393
bauerbce9a1a82014-12-18 13:34:24394 void OnBlacklistLoaded();
395
treib9cc1b112016-01-08 10:08:01396 void UpdateBlacklist();
397
[email protected]5e022292013-02-06 16:42:17398 // Updates the manual overrides for hosts in the URL filters when the
399 // corresponding preference is changed.
400 void UpdateManualHosts();
[email protected]0850e842013-01-19 03:44:31401
[email protected]5e022292013-02-06 16:42:17402 // Updates the manual overrides for URLs in the URL filters when the
403 // corresponding preference is changed.
404 void UpdateManualURLs();
[email protected]0850e842013-01-19 03:44:31405
[email protected]0b4c6b22014-08-04 09:46:31406 // Returns the human readable name of the supervised user.
407 std::string GetSupervisedUserName() const;
408
fhorschig1f351f02014-09-30 12:30:22409 // Subscribes to the SupervisedUserPrefStore, refreshes
410 // |includes_sync_sessions_type_| and triggers reconfiguring the
411 // ProfileSyncService.
bauerbb519f8252016-05-13 09:16:39412 void OnForceSessionSyncChanged();
fhorschig1f351f02014-09-30 12:30:22413
414 // The option a custodian sets to either record or prevent recording the
415 // supervised user's history. Set by |FetchNewSessionSyncState()| and
416 // defaults to true.
417 bool includes_sync_sessions_type_;
418
[email protected]12b7af32014-03-13 05:28:20419 // Owns us via the KeyedService mechanism.
[email protected]0850e842013-01-19 03:44:31420 Profile* profile_;
421
[email protected]f085fdd52014-06-11 18:09:20422 bool active_;
423
424 Delegate* delegate_;
425
[email protected]0850e842013-01-19 03:44:31426 PrefChangeRegistrar pref_change_registrar_;
427
[email protected]a243d644c2013-06-20 18:37:55428 // True iff we're waiting for the Sync service to be initialized.
429 bool waiting_for_sync_initialization_;
[email protected]dfddd022013-07-10 17:29:48430 bool is_profile_active_;
[email protected]a243d644c2013-06-20 18:37:55431
[email protected]438f7e12013-08-07 06:59:00432 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_;
433
[email protected]3a276ff2014-08-12 14:22:09434 // True only when |Init()| method has been called.
435 bool did_init_;
436
[email protected]3bf45d02013-07-10 00:03:41437 // True only when |Shutdown()| method has been called.
438 bool did_shutdown_;
439
[email protected]0850e842013-01-19 03:44:31440 URLFilterContext url_filter_context_;
treib9cc1b112016-01-08 10:08:01441
mamire9609642016-06-28 22:17:54442 // Stores a map from extension_id -> approved version by the custodian.
443 // It is only relevant for SU-initiated installs.
444 std::map<std::string, base::Version> approved_extensions_map_;
445
treib9cc1b112016-01-08 10:08:01446 enum class BlacklistLoadState {
447 NOT_LOADED,
448 LOAD_STARTED,
449 LOADED
450 } blacklist_state_;
451
452 SupervisedUserBlacklist blacklist_;
dchengf624e472016-04-12 08:33:17453 std::unique_ptr<FileDownloader> blacklist_downloader_;
[email protected]8052b242013-11-15 16:40:55454
dchengf624e472016-04-12 08:33:17455 std::unique_ptr<SupervisedUserWhitelistService> whitelist_service_;
bauerb4da36132014-12-26 19:53:13456
atanasova9572aaf2016-02-26 18:08:26457 std::vector<scoped_refptr<SupervisedUserSiteList>> whitelists_;
458
[email protected]4db65f952014-05-20 15:46:30459 // Used to create permission requests.
bauerbd3a36cc42014-10-01 13:05:49460 ScopedVector<PermissionRequestCreator> permissions_creators_;
[email protected]4db65f952014-05-20 15:46:30461
atanasovaac676032016-04-05 16:31:05462 // Used to report inappropriate URLs to SafeSarch API.
dchengf624e472016-04-12 08:33:17463 std::unique_ptr<SafeSearchURLReporter> url_reporter_;
atanasovaac676032016-04-05 16:31:05464
mamire9609642016-06-28 22:17:54465#if defined(ENABLE_EXTENSIONS)
466 ScopedObserver<extensions::ExtensionRegistry,
467 extensions::ExtensionRegistryObserver>
468 registry_observer_;
469#endif
470
brettwd195c952015-06-02 17:31:12471 base::ObserverList<SupervisedUserServiceObserver> observer_list_;
treibab0a39e2014-09-24 14:48:28472
tommyclif3a1551e2016-06-21 18:11:23473 // Prevents Sync from running until configuration is complete.
474 std::unique_ptr<sync_driver::SyncSetupInProgressHandle> sync_blocker_;
475
[email protected]cce15bb2014-06-17 13:43:51476 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_;
[email protected]0850e842013-01-19 03:44:31477};
478
[email protected]cce15bb2014-06-17 13:43:51479#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_