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