blob: b896f63a56025bc84eb713a64e87ee038429008c [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"
maxbogue455a57e32016-08-14 00:08:3231#include "components/sync/driver/sync_service_observer.h"
32#include "components/sync/driver/sync_type_preference_provider.h"
brettw00899e62016-11-12 02:10:1733#include "extensions/features/features.h"
maxbogue8e4fb452015-02-11 20:26:0934#include "net/url_request/url_request_context_getter.h"
[email protected]c14a6802014-07-11 21:51:1235
brettw00899e62016-11-12 02:10:1736#if BUILDFLAG(ENABLE_EXTENSIONS)
mamire9609642016-06-28 22:17:5437#include "extensions/browser/extension_registry_observer.h"
[email protected]301116c62013-11-26 10:37:4538#include "extensions/browser/management_policy.h"
[email protected]c14a6802014-07-11 21:51:1239#endif
[email protected]0850e842013-01-19 03:44:3140
[email protected]509ad1a92013-03-19 21:41:0641class Browser;
[email protected]acfcfbb2013-05-13 18:01:2742class GoogleServiceAuthError;
[email protected]4db65f952014-05-20 15:46:3043class PermissionRequestCreator;
[email protected]0850e842013-01-19 03:44:3144class Profile;
[email protected]cce15bb2014-06-17 13:43:5145class SupervisedUserRegistrationUtility;
treibab0a39e2014-09-24 14:48:2846class SupervisedUserServiceObserver;
[email protected]cce15bb2014-06-17 13:43:5147class SupervisedUserSettingsService;
48class SupervisedUserSiteList;
49class SupervisedUserURLFilter;
bauerb4da36132014-12-26 19:53:1350class SupervisedUserWhitelistService;
[email protected]0850e842013-01-19 03:44:3151
treibdaece84f2014-09-05 12:58:1552namespace base {
53class FilePath;
treibf832a992015-03-24 18:09:2454class Version;
treibdaece84f2014-09-05 12:58:1555}
56
treib565a0192014-12-04 13:17:3157namespace content {
58class WebContents;
59}
60
[email protected]f2253ac2014-05-28 08:37:2161namespace extensions {
62class ExtensionRegistry;
63}
64
maxbogue7e006db2016-10-03 19:48:2865namespace syncer {
tommyclif3a1551e2016-06-21 18:11:2366class SyncSetupInProgressHandle;
67}
68
[email protected]443e9312013-05-06 06:17:3469namespace user_prefs {
70class PrefRegistrySyncable;
71}
72
[email protected]cce15bb2014-06-17 13:43:5173// This class handles all the information related to a given supervised profile
[email protected]0850e842013-01-19 03:44:3174// (e.g. the installed content packs, the default URL filtering behavior, or
75// manual whitelist/blacklist overrides).
[email protected]cce15bb2014-06-17 13:43:5176class SupervisedUserService : public KeyedService,
brettw00899e62016-11-12 02:10:1777#if BUILDFLAG(ENABLE_EXTENSIONS)
mamire9609642016-06-28 22:17:5478 public extensions::ExtensionRegistryObserver,
[email protected]cce15bb2014-06-17 13:43:5179 public extensions::ManagementPolicy::Provider,
[email protected]c14a6802014-07-11 21:51:1280#endif
maxbogue7e006db2016-10-03 19:48:2881 public syncer::SyncTypePreferenceProvider,
jam1c5a91492016-02-24 20:47:5382#if !defined(OS_ANDROID)
maxbogue7e006db2016-10-03 19:48:2883 public syncer::SyncServiceObserver,
bauerbce9a1a82014-12-18 13:34:2484 public chrome::BrowserListObserver,
bauerb5f8cda92015-10-07 15:36:4485#endif
bauerbce9a1a82014-12-18 13:34:2486 public SupervisedUserURLFilter::Observer {
[email protected]0850e842013-01-19 03:44:3187 public:
treib8ecc1eb52015-03-04 18:29:0688 using NavigationBlockedCallback = base::Callback<void(content::WebContents*)>;
89 using AuthErrorCallback = base::Callback<void(const GoogleServiceAuthError&)>;
90 using SuccessCallback = base::Callback<void(bool)>;
[email protected]0850e842013-01-19 03:44:3191
[email protected]f085fdd52014-06-11 18:09:2092 class Delegate {
93 public:
94 virtual ~Delegate() {}
95 // Returns true to indicate that the delegate handled the (de)activation, or
[email protected]cce15bb2014-06-17 13:43:5196 // false to indicate that the SupervisedUserService itself should handle it.
[email protected]f085fdd52014-06-11 18:09:2097 virtual bool SetActive(bool active) = 0;
[email protected]f085fdd52014-06-11 18:09:2098 };
99
dchengc072fff2014-10-21 11:39:05100 ~SupervisedUserService() override;
[email protected]0850e842013-01-19 03:44:31101
[email protected]37ca3fe02013-07-05 15:32:44102 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
[email protected]0850e842013-01-19 03:44:31103
bauerb5f8cda92015-10-07 15:36:44104 // Initializes this object.
105 void Init();
106
[email protected]f085fdd52014-06-11 18:09:20107 void SetDelegate(Delegate* delegate);
108
[email protected]0850e842013-01-19 03:44:31109 // Returns the URL filter for the IO thread, for filtering network requests
[email protected]cce15bb2014-06-17 13:43:51110 // (in SupervisedUserResourceThrottle).
111 scoped_refptr<const SupervisedUserURLFilter> GetURLFilterForIOThread();
[email protected]0850e842013-01-19 03:44:31112
113 // Returns the URL filter for the UI thread, for filtering navigations and
114 // classifying sites in the history view.
[email protected]cce15bb2014-06-17 13:43:51115 SupervisedUserURLFilter* GetURLFilterForUIThread();
[email protected]0850e842013-01-19 03:44:31116
bauerb4da36132014-12-26 19:53:13117 // Returns the whitelist service.
118 SupervisedUserWhitelistService* GetWhitelistService();
119
atanasova9572aaf2016-02-26 18:08:26120 const std::vector<scoped_refptr<SupervisedUserSiteList>>& whitelists() const {
121 return whitelists_;
122 }
123
treib8ecc1eb52015-03-04 18:29:06124 // Whether the user can request to get access to blocked URLs or to new
125 // extensions.
[email protected]0369d6ab2013-08-09 01:52:59126 bool AccessRequestsEnabled();
127
treib8ecc1eb52015-03-04 18:29:06128 // Adds an access request for the given URL.
129 void AddURLAccessRequest(const GURL& url, const SuccessCallback& callback);
130
atanasovaac676032016-04-05 16:31:05131 // Reports |url| to the SafeSearch API, because the user thinks this is an
132 // inappropriate URL.
133 void ReportURL(const GURL& url, const SuccessCallback& callback);
134
mamire9609642016-06-28 22:17:54135 // Adds an install request for the given WebStore item (App/Extension).
136 void AddExtensionInstallRequest(const std::string& extension_id,
137 const base::Version& version,
138 const SuccessCallback& callback);
139
140 // Same as above, but without a callback, just logging errors on failure.
141 void AddExtensionInstallRequest(const std::string& extension_id,
142 const base::Version& version);
143
treib8ecc1eb52015-03-04 18:29:06144 // Adds an update request for the given WebStore item (App/Extension).
145 void AddExtensionUpdateRequest(const std::string& extension_id,
treibf832a992015-03-24 18:09:24146 const base::Version& version,
treib8ecc1eb52015-03-04 18:29:06147 const SuccessCallback& callback);
[email protected]e861bba2013-06-17 15:20:54148
treib40d3ad92015-10-20 18:15:42149 // Same as above, but without a callback, just logging errors on failure.
150 void AddExtensionUpdateRequest(const std::string& extension_id,
151 const base::Version& version);
152
mamire9609642016-06-28 22:17:54153 // Get the string used to identify an extension install or update request.
154 // Public for testing.
155 static std::string GetExtensionRequestId(const std::string& extension_id,
156 const base::Version& version);
treib40d3ad92015-10-20 18:15:42157
[email protected]a9c2d642013-05-31 14:37:14158 // Returns the email address of the custodian.
159 std::string GetCustodianEmailAddress() const;
160
[email protected]fae057a2013-06-21 22:46:08161 // Returns the name of the custodian, or the email address if the name is
162 // empty.
163 std::string GetCustodianName() const;
164
treib3e7ecf72014-10-24 16:44:07165 // Returns the email address of the second custodian, or the empty string
166 // if there is no second custodian.
167 std::string GetSecondCustodianEmailAddress() const;
168
169 // Returns the name of the second custodian, or the email address if the name
170 // is empty, or the empty string is there is no second custodian.
171 std::string GetSecondCustodianName() const;
172
treib2170ea02015-10-13 14:55:12173 // Returns a message saying that extensions can only be modified by the
174 // custodian.
175 base::string16 GetExtensionsLockedMessage() const;
176
jam1c5a91492016-02-24 20:47:53177#if !defined(OS_ANDROID)
[email protected]a243d644c2013-06-20 18:37:55178 // Initializes this profile for syncing, using the provided |refresh_token| to
179 // mint access tokens for Sync.
180 void InitSync(const std::string& refresh_token);
[email protected]acfcfbb2013-05-13 18:01:27181
[email protected]cce15bb2014-06-17 13:43:51182 // Convenience method that registers this supervised user using
[email protected]458d59442013-08-01 14:19:32183 // |registration_utility| and initializes sync with the returned token.
184 // The |callback| will be called when registration is complete,
[email protected]3a276ff2014-08-12 14:22:09185 // whether it succeeded or not -- unless registration was cancelled manually,
[email protected]458d59442013-08-01 14:19:32186 // in which case the callback will be ignored.
[email protected]cce15bb2014-06-17 13:43:51187 void RegisterAndInitSync(
188 SupervisedUserRegistrationUtility* registration_utility,
189 Profile* custodian_profile,
190 const std::string& supervised_user_id,
191 const AuthErrorCallback& callback);
thestig1b76f1a2015-09-30 22:52:38192#endif
[email protected]acfcfbb2013-05-13 18:01:27193
[email protected]438f7e12013-08-07 06:59:00194 void AddNavigationBlockedCallback(const NavigationBlockedCallback& callback);
195 void DidBlockNavigation(content::WebContents* web_contents);
196
treibab0a39e2014-09-24 14:48:28197 void AddObserver(SupervisedUserServiceObserver* observer);
198 void RemoveObserver(SupervisedUserServiceObserver* observer);
199
treib531fc7312014-12-09 12:49:20200 void AddPermissionRequestCreator(
dchengf624e472016-04-12 08:33:17201 std::unique_ptr<PermissionRequestCreator> creator);
bauerb646019b12014-10-16 16:23:09202
dchengf624e472016-04-12 08:33:17203 void SetSafeSearchURLReporter(
204 std::unique_ptr<SafeSearchURLReporter> reporter);
atanasovaac676032016-04-05 16:31:05205
bauerbb519f8252016-05-13 09:16:39206 // Returns true if the syncer::SESSIONS type should be included in Sync.
207 // Public for testing.
208 bool IncludesSyncSessionsType() const;
209
bauerb5f8cda92015-10-07 15:36:44210 // ProfileKeyedService override:
211 void Shutdown() override;
212
[email protected]3a276ff2014-08-12 14:22:09213 // SyncTypePreferenceProvider implementation:
dchengc072fff2014-10-21 11:39:05214 syncer::ModelTypeSet GetPreferredDataTypes() const override;
[email protected]3a276ff2014-08-12 14:22:09215
jam1c5a91492016-02-24 20:47:53216#if !defined(OS_ANDROID)
maxbogue7e006db2016-10-03 19:48:28217 // syncer::SyncServiceObserver implementation:
dchengc072fff2014-10-21 11:39:05218 void OnStateChanged() override;
[email protected]0850e842013-01-19 03:44:31219
[email protected]dfddd022013-07-10 17:29:48220 // chrome::BrowserListObserver implementation:
dchengc072fff2014-10-21 11:39:05221 void OnBrowserSetLastActive(Browser* browser) override;
jam1c5a91492016-02-24 20:47:53222#endif // !defined(OS_ANDROID)
[email protected]dfddd022013-07-10 17:29:48223
bauerbce9a1a82014-12-18 13:34:24224 // SupervisedUserURLFilter::Observer implementation:
225 void OnSiteListUpdated() override;
226
[email protected]0850e842013-01-19 03:44:31227 private:
[email protected]cce15bb2014-06-17 13:43:51228 friend class SupervisedUserServiceExtensionTestBase;
229 friend class SupervisedUserServiceFactory;
pvalenzuelac2ca4582014-10-14 19:24:57230 FRIEND_TEST_ALL_PREFIXES(SingleClientSupervisedUserSettingsSyncTest, Sanity);
[email protected]cce15bb2014-06-17 13:43:51231 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration);
mamire9609642016-06-28 22:17:54232 FRIEND_TEST_ALL_PREFIXES(
233 SupervisedUserServiceExtensionTest,
234 ExtensionManagementPolicyProviderWithoutSUInitiatedInstalls);
235 FRIEND_TEST_ALL_PREFIXES(
236 SupervisedUserServiceExtensionTest,
237 ExtensionManagementPolicyProviderWithSUInitiatedInstalls);
bauerb95a50682015-01-07 17:04:15238
treib8ecc1eb52015-03-04 18:29:06239 using CreatePermissionRequestCallback =
240 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>;
241
[email protected]cce15bb2014-06-17 13:43:51242 // 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.
[email protected]0850e842013-01-19 03:44:31245 class URLFilterContext {
246 public:
247 URLFilterContext();
248 ~URLFilterContext();
249
[email protected]cce15bb2014-06-17 13:43:51250 SupervisedUserURLFilter* ui_url_filter() const;
251 SupervisedUserURLFilter* io_url_filter() const;
[email protected]0850e842013-01-19 03:44:31252
253 void SetDefaultFilteringBehavior(
[email protected]cce15bb2014-06-17 13:43:51254 SupervisedUserURLFilter::FilteringBehavior behavior);
bauerb95a50682015-01-07 17:04:15255 void LoadWhitelists(
256 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists);
treib9cc1b112016-01-08 10:08:01257 // 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;
dchengf624e472016-04-12 08:33:17261 void SetManualHosts(std::unique_ptr<std::map<std::string, bool>> host_map);
262 void SetManualURLs(std::unique_ptr<std::map<GURL, bool>> url_map);
[email protected]0850e842013-01-19 03:44:31263
maxbogue8e4fb452015-02-11 20:26:09264 void InitAsyncURLChecker(
treibd3f8b7a2015-04-10 11:41:33265 const scoped_refptr<net::URLRequestContextGetter>& context);
treib9cc1b112016-01-08 10:08:01266 bool HasAsyncURLChecker() const;
267 void ClearAsyncURLChecker();
treib9e4fab902014-10-29 14:25:26268
treib22c3a042015-01-15 21:30:13269 void Clear();
270
[email protected]0850e842013-01-19 03:44:31271 private:
bauerbce9a1a82014-12-18 13:34:24272 void OnBlacklistLoaded(const base::Closure& callback);
treib4edbded2014-09-05 08:43:55273
[email protected]cce15bb2014-06-17 13:43:51274 // SupervisedUserURLFilter is refcounted because the IO thread filter is
275 // used both by ProfileImplIOData and OffTheRecordProfileIOData (to filter
[email protected]0850e842013-01-19 03:44:31276 // 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).
[email protected]cce15bb2014-06-17 13:43:51280 scoped_refptr<SupervisedUserURLFilter> ui_url_filter_;
281 scoped_refptr<SupervisedUserURLFilter> io_url_filter_;
[email protected]0850e842013-01-19 03:44:31282
[email protected]0850e842013-01-19 03:44:31283 DISALLOW_COPY_AND_ASSIGN(URLFilterContext);
284 };
285
[email protected]cce15bb2014-06-17 13:43:51286 // Use |SupervisedUserServiceFactory::GetForProfile(..)| to get
[email protected]3bf45d02013-07-10 00:03:41287 // an instance of this service.
[email protected]cce15bb2014-06-17 13:43:51288 explicit SupervisedUserService(Profile* profile);
[email protected]3bf45d02013-07-10 00:03:41289
[email protected]f085fdd52014-06-11 18:09:20290 void SetActive(bool active);
291
jam1c5a91492016-02-24 20:47:53292#if !defined(OS_ANDROID)
[email protected]0085863a2013-12-06 21:19:03293 void OnCustodianProfileDownloaded(const base::string16& full_name);
[email protected]200729f82013-06-22 07:05:55294
[email protected]cce15bb2014-06-17 13:43:51295 void OnSupervisedUserRegistered(const AuthErrorCallback& callback,
296 Profile* custodian_profile,
297 const GoogleServiceAuthError& auth_error,
298 const std::string& token);
[email protected]acfcfbb2013-05-13 18:01:27299
[email protected]a243d644c2013-06-20 18:37:55300 void SetupSync();
[email protected]6e08b9a62014-07-08 00:32:48301 void StartSetupSync();
302 void FinishSetupSyncWhenReady();
303 void FinishSetupSync();
bauerb5f8cda92015-10-07 15:36:44304#endif
[email protected]a243d644c2013-06-20 18:37:55305
[email protected]cce15bb2014-06-17 13:43:51306 bool ProfileIsSupervised() const;
[email protected]e000daf2013-07-31 16:50:58307
treib3fce4e92014-09-26 16:06:25308 void OnCustodianInfoChanged();
309
brettw00899e62016-11-12 02:10:17310#if BUILDFLAG(ENABLE_EXTENSIONS)
treibbb9a1962015-02-25 13:40:59311 // extensions::ManagementPolicy::Provider implementation:
312 std::string GetDebugPolicyProviderName() const override;
313 bool UserMayLoad(const extensions::Extension* extension,
314 base::string16* error) const override;
treib755c12d2015-03-30 08:46:25315 bool UserMayModifySettings(const extensions::Extension* extension,
316 base::string16* error) const override;
treibbb9a1962015-02-25 13:40:59317 bool MustRemainInstalled(const extensions::Extension* extension,
318 base::string16* error) const override;
mamire9609642016-06-28 22:17:54319 bool MustRemainDisabled(const extensions::Extension* extension,
320 extensions::Extension::DisableReason* reason,
321 base::string16* error) const override;
322
323 // extensions::ExtensionRegistryObserver overrides:
324 void OnExtensionInstalled(content::BrowserContext* browser_context,
325 const extensions::Extension* extension,
326 bool is_update) override;
[email protected]0850e842013-01-19 03:44:31327
mamir192d7882016-06-22 17:10:16328 // An extension can be in one of the following states:
329 //
330 // FORCED: if it is installed by the custodian.
mamire9609642016-06-28 22:17:54331 // REQUIRE_APPROVAL: if it is installed by the supervised user and
332 // hasn't been approved by the custodian yet.
mamir192d7882016-06-22 17:10:16333 // ALLOWED: Components, Themes, Default extensions ..etc
334 // are generally allowed. Extensions that have been approved by the
335 // custodian are also allowed.
336 // BLOCKED: if it is not ALLOWED or FORCED
337 // and supervised users initiated installs are disabled.
mamire9609642016-06-28 22:17:54338 enum class ExtensionState { FORCED, BLOCKED, ALLOWED, REQUIRE_APPROVAL };
mamir192d7882016-06-22 17:10:16339
mamire9609642016-06-28 22:17:54340 // Returns the state of an extension whether being FORCED, BLOCKED, ALLOWED or
341 // REQUIRE_APPROVAL from the Supervised User service's point of view.
mamir192d7882016-06-22 17:10:16342 ExtensionState GetExtensionState(
mamire9609642016-06-28 22:17:54343 const extensions::Extension& extension) const;
mamir192d7882016-06-22 17:10:16344
[email protected]c14a6802014-07-11 21:51:12345 // Extensions helper to SetActive().
346 void SetExtensionsActive();
mamire9609642016-06-28 22:17:54347
348 // Enables/Disables extensions upon change in approved version of the
349 // extension_id.
350 void ChangeExtensionStateIfNecessary(const std::string& extension_id);
351
352 // Updates the map of approved extensions when the corresponding preference
353 // is changed.
354 void UpdateApprovedExtensions();
[email protected]c14a6802014-07-11 21:51:12355#endif
356
[email protected]cce15bb2014-06-17 13:43:51357 SupervisedUserSettingsService* GetSettingsService();
[email protected]e861bba2013-06-17 15:20:54358
bauerbd3a36cc42014-10-01 13:05:49359 size_t FindEnabledPermissionRequestCreator(size_t start);
treib8ecc1eb52015-03-04 18:29:06360 void AddPermissionRequestInternal(
361 const CreatePermissionRequestCallback& create_request,
362 const SuccessCallback& callback,
363 size_t index);
364 void OnPermissionRequestIssued(
365 const CreatePermissionRequestCallback& create_request,
366 const SuccessCallback& callback,
367 size_t index,
368 bool success);
bauerbd3a36cc42014-10-01 13:05:49369
[email protected]cce15bb2014-06-17 13:43:51370 void OnSupervisedUserIdChanged();
[email protected]f085fdd52014-06-11 18:09:20371
[email protected]0850e842013-01-19 03:44:31372 void OnDefaultFilteringBehaviorChanged();
373
treib9cc1b112016-01-08 10:08:01374 void OnSafeSitesSettingChanged();
375
bauerb95a50682015-01-07 17:04:15376 void OnSiteListsChanged(
377 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists);
[email protected]0850e842013-01-19 03:44:31378
treib2fd187392015-04-16 17:19:38379 // Asynchronously loads a blacklist from a binary file at |path| and applies
380 // it to the URL filters. If no file exists at |path| yet, downloads a file
381 // from |url| and stores it at |path| first.
treibf136dfb2014-09-25 17:37:47382 void LoadBlacklist(const base::FilePath& path, const GURL& url);
383
treib2fd187392015-04-16 17:19:38384 void OnBlacklistFileChecked(const base::FilePath& path,
385 const GURL& url,
386 bool file_exists);
387
388 // Asynchronously loads a blacklist from a binary file at |path| and applies
389 // it to the URL filters.
treibf136dfb2014-09-25 17:37:47390 void LoadBlacklistFromFile(const base::FilePath& path);
391
treibf38cc252016-04-07 14:44:11392 void OnBlacklistDownloadDone(const base::FilePath& path,
393 FileDownloader::Result result);
treib4edbded2014-09-05 08:43:55394
bauerbce9a1a82014-12-18 13:34:24395 void OnBlacklistLoaded();
396
treib9cc1b112016-01-08 10:08:01397 void UpdateBlacklist();
398
[email protected]5e022292013-02-06 16:42:17399 // Updates the manual overrides for hosts in the URL filters when the
400 // corresponding preference is changed.
401 void UpdateManualHosts();
[email protected]0850e842013-01-19 03:44:31402
[email protected]5e022292013-02-06 16:42:17403 // Updates the manual overrides for URLs in the URL filters when the
404 // corresponding preference is changed.
405 void UpdateManualURLs();
[email protected]0850e842013-01-19 03:44:31406
[email protected]0b4c6b22014-08-04 09:46:31407 // Returns the human readable name of the supervised user.
408 std::string GetSupervisedUserName() const;
409
fhorschig1f351f02014-09-30 12:30:22410 // Subscribes to the SupervisedUserPrefStore, refreshes
411 // |includes_sync_sessions_type_| and triggers reconfiguring the
412 // ProfileSyncService.
bauerbb519f8252016-05-13 09:16:39413 void OnForceSessionSyncChanged();
fhorschig1f351f02014-09-30 12:30:22414
415 // The option a custodian sets to either record or prevent recording the
416 // supervised user's history. Set by |FetchNewSessionSyncState()| and
417 // defaults to true.
418 bool includes_sync_sessions_type_;
419
[email protected]12b7af32014-03-13 05:28:20420 // Owns us via the KeyedService mechanism.
[email protected]0850e842013-01-19 03:44:31421 Profile* profile_;
422
[email protected]f085fdd52014-06-11 18:09:20423 bool active_;
424
425 Delegate* delegate_;
426
[email protected]0850e842013-01-19 03:44:31427 PrefChangeRegistrar pref_change_registrar_;
428
[email protected]a243d644c2013-06-20 18:37:55429 // True iff we're waiting for the Sync service to be initialized.
430 bool waiting_for_sync_initialization_;
[email protected]dfddd022013-07-10 17:29:48431 bool is_profile_active_;
[email protected]a243d644c2013-06-20 18:37:55432
[email protected]438f7e12013-08-07 06:59:00433 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_;
434
[email protected]3a276ff2014-08-12 14:22:09435 // True only when |Init()| method has been called.
436 bool did_init_;
437
[email protected]3bf45d02013-07-10 00:03:41438 // True only when |Shutdown()| method has been called.
439 bool did_shutdown_;
440
[email protected]0850e842013-01-19 03:44:31441 URLFilterContext url_filter_context_;
treib9cc1b112016-01-08 10:08:01442
mamire9609642016-06-28 22:17:54443 // Stores a map from extension_id -> approved version by the custodian.
444 // It is only relevant for SU-initiated installs.
445 std::map<std::string, base::Version> approved_extensions_map_;
446
treib9cc1b112016-01-08 10:08:01447 enum class BlacklistLoadState {
448 NOT_LOADED,
449 LOAD_STARTED,
450 LOADED
451 } blacklist_state_;
452
453 SupervisedUserBlacklist blacklist_;
dchengf624e472016-04-12 08:33:17454 std::unique_ptr<FileDownloader> blacklist_downloader_;
[email protected]8052b242013-11-15 16:40:55455
dchengf624e472016-04-12 08:33:17456 std::unique_ptr<SupervisedUserWhitelistService> whitelist_service_;
bauerb4da36132014-12-26 19:53:13457
atanasova9572aaf2016-02-26 18:08:26458 std::vector<scoped_refptr<SupervisedUserSiteList>> whitelists_;
459
[email protected]4db65f952014-05-20 15:46:30460 // Used to create permission requests.
bauerbd3a36cc42014-10-01 13:05:49461 ScopedVector<PermissionRequestCreator> permissions_creators_;
[email protected]4db65f952014-05-20 15:46:30462
atanasovaac676032016-04-05 16:31:05463 // Used to report inappropriate URLs to SafeSarch API.
dchengf624e472016-04-12 08:33:17464 std::unique_ptr<SafeSearchURLReporter> url_reporter_;
atanasovaac676032016-04-05 16:31:05465
brettw00899e62016-11-12 02:10:17466#if BUILDFLAG(ENABLE_EXTENSIONS)
mamire9609642016-06-28 22:17:54467 ScopedObserver<extensions::ExtensionRegistry,
468 extensions::ExtensionRegistryObserver>
469 registry_observer_;
470#endif
471
brettwd195c952015-06-02 17:31:12472 base::ObserverList<SupervisedUserServiceObserver> observer_list_;
treibab0a39e2014-09-24 14:48:28473
tommyclif3a1551e2016-06-21 18:11:23474 // Prevents Sync from running until configuration is complete.
maxbogue7e006db2016-10-03 19:48:28475 std::unique_ptr<syncer::SyncSetupInProgressHandle> sync_blocker_;
tommyclif3a1551e2016-06-21 18:11:23476
[email protected]cce15bb2014-06-17 13:43:51477 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_;
[email protected]0850e842013-01-19 03:44:31478};
479
[email protected]cce15bb2014-06-17 13:43:51480#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_