[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
| 6 | #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 7 | |
avi | 664c07b | 2015-12-26 02:18:31 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | |
treib | 950c6e8 | 2014-09-23 13:07:29 | [diff] [blame] | 10 | #include <map> |
dcheng | f624e47 | 2016-04-12 08:33:17 | [diff] [blame] | 11 | #include <memory> |
treib | 950c6e8 | 2014-09-23 13:07:29 | [diff] [blame] | 12 | #include <string> |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 13 | #include <vector> |
| 14 | |
[email protected] | 438f7e1 | 2013-08-07 06:59:00 | [diff] [blame] | 15 | #include "base/callback.h" |
[email protected] | 076ebeda | 2014-06-06 21:47:26 | [diff] [blame] | 16 | #include "base/gtest_prod_util.h" |
avi | 664c07b | 2015-12-26 02:18:31 | [diff] [blame] | 17 | #include "base/macros.h" |
treib | ab0a39e | 2014-09-24 14:48:28 | [diff] [blame] | 18 | #include "base/observer_list.h" |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 19 | #include "base/scoped_observer.h" |
[email protected] | f9b29436 | 2013-06-10 20:22:31 | [diff] [blame] | 20 | #include "base/strings/string16.h" |
avi | 664c07b | 2015-12-26 02:18:31 | [diff] [blame] | 21 | #include "build/build_config.h" |
treib | f38cc25 | 2016-04-07 14:44:11 | [diff] [blame] | 22 | #include "chrome/browser/net/file_downloader.h" |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 23 | #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist.h" |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 24 | #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
| 25 | #include "chrome/browser/supervised_user/supervised_users.h" |
[email protected] | 514fcf2 | 2013-08-13 06:37:24 | [diff] [blame] | 26 | #include "chrome/browser/ui/browser_list_observer.h" |
[email protected] | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 27 | #include "components/keyed_service/core/keyed_service.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 28 | #include "components/prefs/pref_change_registrar.h" |
maxbogue | 455a57e3 | 2016-08-14 00:08:32 | [diff] [blame] | 29 | #include "components/sync/driver/sync_type_preference_provider.h" |
Scott Violet | c8240b0 | 2018-03-08 22:03:59 | [diff] [blame] | 30 | #include "extensions/buildflags/buildflags.h" |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 31 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 32 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 33 | #include "extensions/browser/extension_registry_observer.h" |
[email protected] | 301116c6 | 2013-11-26 10:37:45 | [diff] [blame] | 34 | #include "extensions/browser/management_policy.h" |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 35 | #endif |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 36 | |
[email protected] | 509ad1a9 | 2013-03-19 21:41:06 | [diff] [blame] | 37 | class Browser; |
[email protected] | 4db65f95 | 2014-05-20 15:46:30 | [diff] [blame] | 38 | class PermissionRequestCreator; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 39 | class Profile; |
treib | ab0a39e | 2014-09-24 14:48:28 | [diff] [blame] | 40 | class SupervisedUserServiceObserver; |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 41 | class SupervisedUserSettingsService; |
| 42 | class SupervisedUserSiteList; |
| 43 | class SupervisedUserURLFilter; |
bauerb | 4da3613 | 2014-12-26 19:53:13 | [diff] [blame] | 44 | class SupervisedUserWhitelistService; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 45 | |
treib | daece84f | 2014-09-05 12:58:15 | [diff] [blame] | 46 | namespace base { |
| 47 | class FilePath; |
treib | f832a99 | 2015-03-24 18:09:24 | [diff] [blame] | 48 | class Version; |
treib | daece84f | 2014-09-05 12:58:15 | [diff] [blame] | 49 | } |
| 50 | |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 51 | namespace extensions { |
| 52 | class ExtensionRegistry; |
| 53 | } |
| 54 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 55 | namespace user_prefs { |
| 56 | class PrefRegistrySyncable; |
| 57 | } |
| 58 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 59 | // This class handles all the information related to a given supervised profile |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 60 | // (e.g. the installed content packs, the default URL filtering behavior, or |
| 61 | // manual whitelist/blacklist overrides). |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 62 | class SupervisedUserService : public KeyedService, |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 63 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 64 | public extensions::ExtensionRegistryObserver, |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 65 | public extensions::ManagementPolicy::Provider, |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 66 | #endif |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 67 | public syncer::SyncTypePreferenceProvider, |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 68 | #if !defined(OS_ANDROID) |
cm.sanchi | a0d6add | 2017-12-13 04:59:33 | [diff] [blame] | 69 | public BrowserListObserver, |
bauerb | 5f8cda9 | 2015-10-07 15:36:44 | [diff] [blame] | 70 | #endif |
bauerb | ce9a1a8 | 2014-12-18 13:34:24 | [diff] [blame] | 71 | public SupervisedUserURLFilter::Observer { |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 72 | public: |
Carlos IL | 6b784a6 | 2018-03-20 00:26:49 | [diff] [blame] | 73 | using SuccessCallback = base::OnceCallback<void(bool)>; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 74 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 75 | class Delegate { |
| 76 | public: |
| 77 | virtual ~Delegate() {} |
| 78 | // Returns true to indicate that the delegate handled the (de)activation, or |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 79 | // false to indicate that the SupervisedUserService itself should handle it. |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 80 | virtual bool SetActive(bool active) = 0; |
| 81 | }; |
| 82 | |
dcheng | c072fff | 2014-10-21 11:39:05 | [diff] [blame] | 83 | ~SupervisedUserService() override; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 84 | |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame] | 85 | static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 86 | |
bauerb | 5f8cda9 | 2015-10-07 15:36:44 | [diff] [blame] | 87 | // Initializes this object. |
| 88 | void Init(); |
| 89 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 90 | void SetDelegate(Delegate* delegate); |
| 91 | |
mmenke | db2637ff | 2017-03-30 23:59:42 | [diff] [blame] | 92 | // Returns the URL filter for filtering navigations and classifying sites in |
| 93 | // the history view. Both this method and the returned filter may only be used |
| 94 | // on the UI thread. |
| 95 | SupervisedUserURLFilter* GetURLFilter(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 96 | |
bauerb | 4da3613 | 2014-12-26 19:53:13 | [diff] [blame] | 97 | // Returns the whitelist service. |
| 98 | SupervisedUserWhitelistService* GetWhitelistService(); |
| 99 | |
atanasova | 9572aaf | 2016-02-26 18:08:26 | [diff] [blame] | 100 | const std::vector<scoped_refptr<SupervisedUserSiteList>>& whitelists() const { |
| 101 | return whitelists_; |
| 102 | } |
| 103 | |
treib | 8ecc1eb5 | 2015-03-04 18:29:06 | [diff] [blame] | 104 | // Whether the user can request to get access to blocked URLs or to new |
| 105 | // extensions. |
[email protected] | 0369d6ab | 2013-08-09 01:52:59 | [diff] [blame] | 106 | bool AccessRequestsEnabled(); |
| 107 | |
treib | 8ecc1eb5 | 2015-03-04 18:29:06 | [diff] [blame] | 108 | // Adds an access request for the given URL. |
Carlos IL | 6b784a6 | 2018-03-20 00:26:49 | [diff] [blame] | 109 | void AddURLAccessRequest(const GURL& url, SuccessCallback callback); |
treib | 8ecc1eb5 | 2015-03-04 18:29:06 | [diff] [blame] | 110 | |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 111 | // Adds an install request for the given WebStore item (App/Extension). |
| 112 | void AddExtensionInstallRequest(const std::string& extension_id, |
| 113 | const base::Version& version, |
Carlos IL | 6b784a6 | 2018-03-20 00:26:49 | [diff] [blame] | 114 | SuccessCallback callback); |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 115 | |
| 116 | // Same as above, but without a callback, just logging errors on failure. |
| 117 | void AddExtensionInstallRequest(const std::string& extension_id, |
| 118 | const base::Version& version); |
| 119 | |
treib | 8ecc1eb5 | 2015-03-04 18:29:06 | [diff] [blame] | 120 | // Adds an update request for the given WebStore item (App/Extension). |
| 121 | void AddExtensionUpdateRequest(const std::string& extension_id, |
treib | f832a99 | 2015-03-24 18:09:24 | [diff] [blame] | 122 | const base::Version& version, |
Carlos IL | 6b784a6 | 2018-03-20 00:26:49 | [diff] [blame] | 123 | SuccessCallback callback); |
[email protected] | e861bba | 2013-06-17 15:20:54 | [diff] [blame] | 124 | |
treib | 40d3ad9 | 2015-10-20 18:15:42 | [diff] [blame] | 125 | // Same as above, but without a callback, just logging errors on failure. |
| 126 | void AddExtensionUpdateRequest(const std::string& extension_id, |
| 127 | const base::Version& version); |
| 128 | |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 129 | // Get the string used to identify an extension install or update request. |
| 130 | // Public for testing. |
| 131 | static std::string GetExtensionRequestId(const std::string& extension_id, |
| 132 | const base::Version& version); |
treib | 40d3ad9 | 2015-10-20 18:15:42 | [diff] [blame] | 133 | |
[email protected] | a9c2d64 | 2013-05-31 14:37:14 | [diff] [blame] | 134 | // Returns the email address of the custodian. |
| 135 | std::string GetCustodianEmailAddress() const; |
| 136 | |
Danan S | bef6ca2 | 2019-05-09 18:15:54 | [diff] [blame] | 137 | // Returns the obfuscated GAIA id of the custodian. |
| 138 | std::string GetCustodianObfuscatedGaiaId() const; |
| 139 | |
[email protected] | fae057a | 2013-06-21 22:46:08 | [diff] [blame] | 140 | // Returns the name of the custodian, or the email address if the name is |
| 141 | // empty. |
| 142 | std::string GetCustodianName() const; |
| 143 | |
treib | 3e7ecf7 | 2014-10-24 16:44:07 | [diff] [blame] | 144 | // Returns the email address of the second custodian, or the empty string |
| 145 | // if there is no second custodian. |
| 146 | std::string GetSecondCustodianEmailAddress() const; |
| 147 | |
Danan S | bef6ca2 | 2019-05-09 18:15:54 | [diff] [blame] | 148 | // Returns the obfuscated GAIA id of the second custodian or the empty |
| 149 | // string if there is no second custodian. |
| 150 | std::string GetSecondCustodianObfuscatedGaiaId() const; |
| 151 | |
treib | 3e7ecf7 | 2014-10-24 16:44:07 | [diff] [blame] | 152 | // Returns the name of the second custodian, or the email address if the name |
Danan S | bef6ca2 | 2019-05-09 18:15:54 | [diff] [blame] | 153 | // is empty, or the empty string if there is no second custodian. |
treib | 3e7ecf7 | 2014-10-24 16:44:07 | [diff] [blame] | 154 | std::string GetSecondCustodianName() const; |
| 155 | |
treib | 2170ea0 | 2015-10-13 14:55:12 | [diff] [blame] | 156 | // Returns a message saying that extensions can only be modified by the |
| 157 | // custodian. |
| 158 | base::string16 GetExtensionsLockedMessage() const; |
| 159 | |
yilkal | 190d97c | 2019-09-06 23:50:03 | [diff] [blame^] | 160 | bool IsSupervisedUserIframeFilterEnabled() const; |
| 161 | |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 162 | #if !defined(OS_ANDROID) |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 163 | // Initializes this profile for syncing, using the provided |refresh_token| to |
| 164 | // mint access tokens for Sync. |
| 165 | void InitSync(const std::string& refresh_token); |
thestig | 1b76f1a | 2015-09-30 22:52:38 | [diff] [blame] | 166 | #endif |
[email protected] | acfcfbb | 2013-05-13 18:01:27 | [diff] [blame] | 167 | |
treib | ab0a39e | 2014-09-24 14:48:28 | [diff] [blame] | 168 | void AddObserver(SupervisedUserServiceObserver* observer); |
| 169 | void RemoveObserver(SupervisedUserServiceObserver* observer); |
| 170 | |
treib | 531fc731 | 2014-12-09 12:49:20 | [diff] [blame] | 171 | void AddPermissionRequestCreator( |
dcheng | f624e47 | 2016-04-12 08:33:17 | [diff] [blame] | 172 | std::unique_ptr<PermissionRequestCreator> creator); |
bauerb | 646019b1 | 2014-10-16 16:23:09 | [diff] [blame] | 173 | |
bauerb | 5f8cda9 | 2015-10-07 15:36:44 | [diff] [blame] | 174 | // ProfileKeyedService override: |
| 175 | void Shutdown() override; |
| 176 | |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 177 | // SyncTypePreferenceProvider implementation: |
Maksim Moskvitin | 35f598b | 2019-04-18 11:47:00 | [diff] [blame] | 178 | syncer::UserSelectableTypeSet GetForcedTypes() const override; |
Marc Treib | b3bbf1d2 | 2019-03-27 15:45:39 | [diff] [blame] | 179 | bool IsEncryptEverythingAllowed() const override; |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 180 | |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 181 | #if !defined(OS_ANDROID) |
cm.sanchi | a0d6add | 2017-12-13 04:59:33 | [diff] [blame] | 182 | // BrowserListObserver implementation: |
dcheng | c072fff | 2014-10-21 11:39:05 | [diff] [blame] | 183 | void OnBrowserSetLastActive(Browser* browser) override; |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 184 | #endif // !defined(OS_ANDROID) |
[email protected] | dfddd02 | 2013-07-10 17:29:48 | [diff] [blame] | 185 | |
bauerb | ce9a1a8 | 2014-12-18 13:34:24 | [diff] [blame] | 186 | // SupervisedUserURLFilter::Observer implementation: |
| 187 | void OnSiteListUpdated() override; |
| 188 | |
Danan S | c194591 | 2019-06-27 02:56:30 | [diff] [blame] | 189 | #if !defined(OS_ANDROID) |
| 190 | bool signout_required_after_supervision_enabled() { |
| 191 | return signout_required_after_supervision_enabled_; |
| 192 | } |
| 193 | void set_signout_required_after_supervision_enabled() { |
| 194 | signout_required_after_supervision_enabled_ = true; |
| 195 | } |
| 196 | #endif // !defined(OS_ANDROID) |
| 197 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 198 | private: |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 199 | friend class SupervisedUserServiceExtensionTestBase; |
| 200 | friend class SupervisedUserServiceFactory; |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 201 | FRIEND_TEST_ALL_PREFIXES( |
| 202 | SupervisedUserServiceExtensionTest, |
| 203 | ExtensionManagementPolicyProviderWithoutSUInitiatedInstalls); |
| 204 | FRIEND_TEST_ALL_PREFIXES( |
| 205 | SupervisedUserServiceExtensionTest, |
| 206 | ExtensionManagementPolicyProviderWithSUInitiatedInstalls); |
bauerb | 95a5068 | 2015-01-07 17:04:15 | [diff] [blame] | 207 | |
treib | 8ecc1eb5 | 2015-03-04 18:29:06 | [diff] [blame] | 208 | using CreatePermissionRequestCallback = |
Carlos IL | 6b784a6 | 2018-03-20 00:26:49 | [diff] [blame] | 209 | base::RepeatingCallback<void(PermissionRequestCreator*, SuccessCallback)>; |
treib | 8ecc1eb5 | 2015-03-04 18:29:06 | [diff] [blame] | 210 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 211 | // Use |SupervisedUserServiceFactory::GetForProfile(..)| to get |
[email protected] | 3bf45d0 | 2013-07-10 00:03:41 | [diff] [blame] | 212 | // an instance of this service. |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 213 | explicit SupervisedUserService(Profile* profile); |
[email protected] | 3bf45d0 | 2013-07-10 00:03:41 | [diff] [blame] | 214 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 215 | void SetActive(bool active); |
| 216 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 217 | bool ProfileIsSupervised() const; |
[email protected] | e000daf | 2013-07-31 16:50:58 | [diff] [blame] | 218 | |
treib | 3fce4e9 | 2014-09-26 16:06:25 | [diff] [blame] | 219 | void OnCustodianInfoChanged(); |
| 220 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 221 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
treib | bb9a196 | 2015-02-25 13:40:59 | [diff] [blame] | 222 | // extensions::ManagementPolicy::Provider implementation: |
| 223 | std::string GetDebugPolicyProviderName() const override; |
| 224 | bool UserMayLoad(const extensions::Extension* extension, |
| 225 | base::string16* error) const override; |
treib | 755c12d | 2015-03-30 08:46:25 | [diff] [blame] | 226 | bool UserMayModifySettings(const extensions::Extension* extension, |
| 227 | base::string16* error) const override; |
treib | bb9a196 | 2015-02-25 13:40:59 | [diff] [blame] | 228 | bool MustRemainInstalled(const extensions::Extension* extension, |
| 229 | base::string16* error) const override; |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 230 | bool MustRemainDisabled(const extensions::Extension* extension, |
Minh X. Nguyen | 4547901 | 2017-08-18 21:35:36 | [diff] [blame] | 231 | extensions::disable_reason::DisableReason* reason, |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 232 | base::string16* error) const override; |
| 233 | |
| 234 | // extensions::ExtensionRegistryObserver overrides: |
| 235 | void OnExtensionInstalled(content::BrowserContext* browser_context, |
| 236 | const extensions::Extension* extension, |
| 237 | bool is_update) override; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 238 | |
mamir | 192d788 | 2016-06-22 17:10:16 | [diff] [blame] | 239 | // An extension can be in one of the following states: |
| 240 | // |
| 241 | // FORCED: if it is installed by the custodian. |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 242 | // REQUIRE_APPROVAL: if it is installed by the supervised user and |
| 243 | // hasn't been approved by the custodian yet. |
mamir | 192d788 | 2016-06-22 17:10:16 | [diff] [blame] | 244 | // ALLOWED: Components, Themes, Default extensions ..etc |
| 245 | // are generally allowed. Extensions that have been approved by the |
| 246 | // custodian are also allowed. |
| 247 | // BLOCKED: if it is not ALLOWED or FORCED |
| 248 | // and supervised users initiated installs are disabled. |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 249 | enum class ExtensionState { FORCED, BLOCKED, ALLOWED, REQUIRE_APPROVAL }; |
mamir | 192d788 | 2016-06-22 17:10:16 | [diff] [blame] | 250 | |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 251 | // Returns the state of an extension whether being FORCED, BLOCKED, ALLOWED or |
| 252 | // REQUIRE_APPROVAL from the Supervised User service's point of view. |
mamir | 192d788 | 2016-06-22 17:10:16 | [diff] [blame] | 253 | ExtensionState GetExtensionState( |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 254 | const extensions::Extension& extension) const; |
mamir | 192d788 | 2016-06-22 17:10:16 | [diff] [blame] | 255 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 256 | // Extensions helper to SetActive(). |
| 257 | void SetExtensionsActive(); |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 258 | |
| 259 | // Enables/Disables extensions upon change in approved version of the |
| 260 | // extension_id. |
| 261 | void ChangeExtensionStateIfNecessary(const std::string& extension_id); |
| 262 | |
| 263 | // Updates the map of approved extensions when the corresponding preference |
| 264 | // is changed. |
| 265 | void UpdateApprovedExtensions(); |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 266 | #endif |
| 267 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 268 | SupervisedUserSettingsService* GetSettingsService(); |
[email protected] | e861bba | 2013-06-17 15:20:54 | [diff] [blame] | 269 | |
bauerb | d3a36cc4 | 2014-10-01 13:05:49 | [diff] [blame] | 270 | size_t FindEnabledPermissionRequestCreator(size_t start); |
treib | 8ecc1eb5 | 2015-03-04 18:29:06 | [diff] [blame] | 271 | void AddPermissionRequestInternal( |
| 272 | const CreatePermissionRequestCallback& create_request, |
Carlos IL | 6b784a6 | 2018-03-20 00:26:49 | [diff] [blame] | 273 | SuccessCallback callback, |
treib | 8ecc1eb5 | 2015-03-04 18:29:06 | [diff] [blame] | 274 | size_t index); |
| 275 | void OnPermissionRequestIssued( |
| 276 | const CreatePermissionRequestCallback& create_request, |
Carlos IL | 6b784a6 | 2018-03-20 00:26:49 | [diff] [blame] | 277 | SuccessCallback callback, |
treib | 8ecc1eb5 | 2015-03-04 18:29:06 | [diff] [blame] | 278 | size_t index, |
| 279 | bool success); |
bauerb | d3a36cc4 | 2014-10-01 13:05:49 | [diff] [blame] | 280 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 281 | void OnSupervisedUserIdChanged(); |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 282 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 283 | void OnDefaultFilteringBehaviorChanged(); |
| 284 | |
treib | 9cc1b11 | 2016-01-08 10:08:01 | [diff] [blame] | 285 | void OnSafeSitesSettingChanged(); |
| 286 | |
bauerb | 95a5068 | 2015-01-07 17:04:15 | [diff] [blame] | 287 | void OnSiteListsChanged( |
| 288 | const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 289 | |
treib | 2fd18739 | 2015-04-16 17:19:38 | [diff] [blame] | 290 | // Asynchronously loads a blacklist from a binary file at |path| and applies |
| 291 | // it to the URL filters. If no file exists at |path| yet, downloads a file |
| 292 | // from |url| and stores it at |path| first. |
treib | f136dfb | 2014-09-25 17:37:47 | [diff] [blame] | 293 | void LoadBlacklist(const base::FilePath& path, const GURL& url); |
| 294 | |
treib | 2fd18739 | 2015-04-16 17:19:38 | [diff] [blame] | 295 | void OnBlacklistFileChecked(const base::FilePath& path, |
| 296 | const GURL& url, |
| 297 | bool file_exists); |
| 298 | |
| 299 | // Asynchronously loads a blacklist from a binary file at |path| and applies |
| 300 | // it to the URL filters. |
treib | f136dfb | 2014-09-25 17:37:47 | [diff] [blame] | 301 | void LoadBlacklistFromFile(const base::FilePath& path); |
| 302 | |
treib | f38cc25 | 2016-04-07 14:44:11 | [diff] [blame] | 303 | void OnBlacklistDownloadDone(const base::FilePath& path, |
| 304 | FileDownloader::Result result); |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 305 | |
bauerb | ce9a1a8 | 2014-12-18 13:34:24 | [diff] [blame] | 306 | void OnBlacklistLoaded(); |
| 307 | |
treib | 9cc1b11 | 2016-01-08 10:08:01 | [diff] [blame] | 308 | void UpdateBlacklist(); |
| 309 | |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 310 | // Updates the manual overrides for hosts in the URL filters when the |
| 311 | // corresponding preference is changed. |
| 312 | void UpdateManualHosts(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 313 | |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 314 | // Updates the manual overrides for URLs in the URL filters when the |
| 315 | // corresponding preference is changed. |
| 316 | void UpdateManualURLs(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 317 | |
[email protected] | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 318 | // Owns us via the KeyedService mechanism. |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 319 | Profile* profile_; |
| 320 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 321 | bool active_; |
| 322 | |
| 323 | Delegate* delegate_; |
| 324 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 325 | PrefChangeRegistrar pref_change_registrar_; |
| 326 | |
[email protected] | dfddd02 | 2013-07-10 17:29:48 | [diff] [blame] | 327 | bool is_profile_active_; |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 328 | |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 329 | // True only when |Init()| method has been called. |
| 330 | bool did_init_; |
| 331 | |
[email protected] | 3bf45d0 | 2013-07-10 00:03:41 | [diff] [blame] | 332 | // True only when |Shutdown()| method has been called. |
| 333 | bool did_shutdown_; |
| 334 | |
mmenke | db2637ff | 2017-03-30 23:59:42 | [diff] [blame] | 335 | SupervisedUserURLFilter url_filter_; |
treib | 9cc1b11 | 2016-01-08 10:08:01 | [diff] [blame] | 336 | |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 337 | // Stores a map from extension_id -> approved version by the custodian. |
| 338 | // It is only relevant for SU-initiated installs. |
| 339 | std::map<std::string, base::Version> approved_extensions_map_; |
| 340 | |
treib | 9cc1b11 | 2016-01-08 10:08:01 | [diff] [blame] | 341 | enum class BlacklistLoadState { |
| 342 | NOT_LOADED, |
| 343 | LOAD_STARTED, |
| 344 | LOADED |
| 345 | } blacklist_state_; |
| 346 | |
| 347 | SupervisedUserBlacklist blacklist_; |
dcheng | f624e47 | 2016-04-12 08:33:17 | [diff] [blame] | 348 | std::unique_ptr<FileDownloader> blacklist_downloader_; |
[email protected] | 8052b24 | 2013-11-15 16:40:55 | [diff] [blame] | 349 | |
dcheng | f624e47 | 2016-04-12 08:33:17 | [diff] [blame] | 350 | std::unique_ptr<SupervisedUserWhitelistService> whitelist_service_; |
bauerb | 4da3613 | 2014-12-26 19:53:13 | [diff] [blame] | 351 | |
atanasova | 9572aaf | 2016-02-26 18:08:26 | [diff] [blame] | 352 | std::vector<scoped_refptr<SupervisedUserSiteList>> whitelists_; |
| 353 | |
[email protected] | 4db65f95 | 2014-05-20 15:46:30 | [diff] [blame] | 354 | // Used to create permission requests. |
leon.han | 4ea301f | 2017-03-28 03:36:31 | [diff] [blame] | 355 | std::vector<std::unique_ptr<PermissionRequestCreator>> permissions_creators_; |
[email protected] | 4db65f95 | 2014-05-20 15:46:30 | [diff] [blame] | 356 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 357 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
mamir | e960964 | 2016-06-28 22:17:54 | [diff] [blame] | 358 | ScopedObserver<extensions::ExtensionRegistry, |
| 359 | extensions::ExtensionRegistryObserver> |
| 360 | registry_observer_; |
| 361 | #endif |
| 362 | |
Trent Apted | a250ec3ab | 2018-08-19 08:52:19 | [diff] [blame] | 363 | base::ObserverList<SupervisedUserServiceObserver>::Unchecked observer_list_; |
treib | ab0a39e | 2014-09-24 14:48:28 | [diff] [blame] | 364 | |
Danan S | c194591 | 2019-06-27 02:56:30 | [diff] [blame] | 365 | #if !defined(OS_ANDROID) |
| 366 | bool signout_required_after_supervision_enabled_ = false; |
| 367 | #endif |
| 368 | |
Jeremy Roman | 495db68 | 2019-07-12 16:03:24 | [diff] [blame] | 369 | base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_{this}; |
leon.han | 4ea301f | 2017-03-28 03:36:31 | [diff] [blame] | 370 | |
| 371 | DISALLOW_COPY_AND_ASSIGN(SupervisedUserService); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 372 | }; |
| 373 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 374 | #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |