[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 | |
treib | 950c6e8 | 2014-09-23 13:07:29 | [diff] [blame] | 8 | #include <map> |
treib | 950c6e8 | 2014-09-23 13:07:29 | [diff] [blame] | 9 | #include <string> |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
[email protected] | 438f7e1 | 2013-08-07 06:59:00 | [diff] [blame] | 12 | #include "base/callback.h" |
[email protected] | 076ebeda | 2014-06-06 21:47:26 | [diff] [blame] | 13 | #include "base/gtest_prod_util.h" |
[email protected] | a581ea2 | 2013-05-06 12:34:19 | [diff] [blame] | 14 | #include "base/memory/scoped_ptr.h" |
treib | ab0a39e | 2014-09-24 14:48:28 | [diff] [blame] | 15 | #include "base/observer_list.h" |
[email protected] | 1ab137b | 2013-03-21 03:33:18 | [diff] [blame] | 16 | #include "base/prefs/pref_change_registrar.h" |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 17 | #include "base/scoped_observer.h" |
[email protected] | f9b29436 | 2013-06-10 20:22:31 | [diff] [blame] | 18 | #include "base/strings/string16.h" |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 19 | #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist.h" |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 20 | #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
| 21 | #include "chrome/browser/supervised_user/supervised_users.h" |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 22 | #include "chrome/browser/sync/profile_sync_service_observer.h" |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 23 | #include "chrome/browser/sync/sync_type_preference_provider.h" |
[email protected] | 514fcf2 | 2013-08-13 06:37:24 | [diff] [blame] | 24 | #include "chrome/browser/ui/browser_list_observer.h" |
[email protected] | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 25 | #include "components/keyed_service/core/keyed_service.h" |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 26 | |
| 27 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 28 | #include "extensions/browser/extension_registry_observer.h" |
[email protected] | 301116c6 | 2013-11-26 10:37:45 | [diff] [blame] | 29 | #include "extensions/browser/management_policy.h" |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 30 | #endif |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 31 | |
[email protected] | 509ad1a9 | 2013-03-19 21:41:06 | [diff] [blame] | 32 | class Browser; |
[email protected] | acfcfbb | 2013-05-13 18:01:27 | [diff] [blame] | 33 | class GoogleServiceAuthError; |
[email protected] | 4db65f95 | 2014-05-20 15:46:30 | [diff] [blame] | 34 | class PermissionRequestCreator; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 35 | class Profile; |
treib | f136dfb | 2014-09-25 17:37:47 | [diff] [blame] | 36 | class SupervisedUserBlacklistDownloader; |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 37 | class SupervisedUserRegistrationUtility; |
treib | ab0a39e | 2014-09-24 14:48:28 | [diff] [blame] | 38 | class SupervisedUserServiceObserver; |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 39 | class SupervisedUserSettingsService; |
| 40 | class SupervisedUserSiteList; |
| 41 | class SupervisedUserURLFilter; |
bauerb | 4da3613 | 2014-12-26 19:53:13 | [diff] [blame^] | 42 | class SupervisedUserWhitelistService; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 43 | |
treib | daece84f | 2014-09-05 12:58:15 | [diff] [blame] | 44 | namespace base { |
| 45 | class FilePath; |
| 46 | } |
| 47 | |
treib | 565a019 | 2014-12-04 13:17:31 | [diff] [blame] | 48 | namespace content { |
| 49 | class WebContents; |
| 50 | } |
| 51 | |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 52 | namespace extensions { |
| 53 | class ExtensionRegistry; |
| 54 | } |
| 55 | |
treib | 9e4fab90 | 2014-10-29 14:25:26 | [diff] [blame] | 56 | namespace net { |
| 57 | class URLRequestContextGetter; |
| 58 | } |
| 59 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 60 | namespace user_prefs { |
| 61 | class PrefRegistrySyncable; |
| 62 | } |
| 63 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 64 | // This class handles all the information related to a given supervised profile |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 65 | // (e.g. the installed content packs, the default URL filtering behavior, or |
| 66 | // manual whitelist/blacklist overrides). |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 67 | class SupervisedUserService : public KeyedService, |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 68 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 69 | public extensions::ManagementPolicy::Provider, |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 70 | public extensions::ExtensionRegistryObserver, |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 71 | #endif |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 72 | public SyncTypePreferenceProvider, |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 73 | public ProfileSyncServiceObserver, |
bauerb | ce9a1a8 | 2014-12-18 13:34:24 | [diff] [blame] | 74 | public chrome::BrowserListObserver, |
| 75 | public SupervisedUserURLFilter::Observer { |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 76 | public: |
[email protected] | d2065e06 | 2013-12-12 23:49:52 | [diff] [blame] | 77 | typedef std::vector<base::string16> CategoryList; |
[email protected] | 438f7e1 | 2013-08-07 06:59:00 | [diff] [blame] | 78 | typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback; |
[email protected] | 514fcf2 | 2013-08-13 06:37:24 | [diff] [blame] | 79 | typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback; |
bauerb | 646019b1 | 2014-10-16 16:23:09 | [diff] [blame] | 80 | typedef base::Callback<void(bool)> SuccessCallback; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 81 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 82 | class Delegate { |
| 83 | public: |
| 84 | virtual ~Delegate() {} |
| 85 | // Returns true to indicate that the delegate handled the (de)activation, or |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 86 | // false to indicate that the SupervisedUserService itself should handle it. |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 87 | virtual bool SetActive(bool active) = 0; |
treib | daece84f | 2014-09-05 12:58:15 | [diff] [blame] | 88 | // Returns the path to a blacklist file to load, or an empty path to |
| 89 | // indicate "none". |
treib | 38983df | 2014-10-24 09:35:12 | [diff] [blame] | 90 | virtual base::FilePath GetBlacklistPath() const; |
treib | f136dfb | 2014-09-25 17:37:47 | [diff] [blame] | 91 | // Returns the URL from which to download a blacklist if no local one exists |
| 92 | // yet. The blacklist file will be stored at |GetBlacklistPath()|. |
treib | 38983df | 2014-10-24 09:35:12 | [diff] [blame] | 93 | virtual GURL GetBlacklistURL() const; |
treib | 9e4fab90 | 2014-10-29 14:25:26 | [diff] [blame] | 94 | // Returns the identifier ("cx") of the Custom Search Engine to use for the |
| 95 | // experimental "SafeSites" feature, or the empty string to disable the |
| 96 | // feature. |
| 97 | virtual std::string GetSafeSitesCx() const; |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 98 | }; |
| 99 | |
dcheng | c072fff | 2014-10-21 11:39:05 | [diff] [blame] | 100 | ~SupervisedUserService() override; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 101 | |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 102 | // ProfileKeyedService override: |
dcheng | c072fff | 2014-10-21 11:39:05 | [diff] [blame] | 103 | void Shutdown() override; |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 104 | |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame] | 105 | static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 106 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 107 | void SetDelegate(Delegate* delegate); |
| 108 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 109 | // Returns the URL filter for the IO thread, for filtering network requests |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 110 | // (in SupervisedUserResourceThrottle). |
| 111 | scoped_refptr<const SupervisedUserURLFilter> GetURLFilterForIOThread(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 112 | |
| 113 | // Returns the URL filter for the UI thread, for filtering navigations and |
| 114 | // classifying sites in the history view. |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 115 | SupervisedUserURLFilter* GetURLFilterForUIThread(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 116 | |
bauerb | 4da3613 | 2014-12-26 19:53:13 | [diff] [blame^] | 117 | // Returns the whitelist service. |
| 118 | SupervisedUserWhitelistService* GetWhitelistService(); |
| 119 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 120 | // Returns the URL's category, obtained from the installed content packs. |
| 121 | int GetCategory(const GURL& url); |
| 122 | |
| 123 | // Returns the list of all known human-readable category names, sorted by ID |
| 124 | // number. Called in the critical path of drawing the history UI, so needs to |
| 125 | // be fast. |
| 126 | void GetCategoryNames(CategoryList* list); |
| 127 | |
[email protected] | 0369d6ab | 2013-08-09 01:52:59 | [diff] [blame] | 128 | // Whether the user can request access to blocked URLs. |
| 129 | bool AccessRequestsEnabled(); |
| 130 | |
[email protected] | e861bba | 2013-06-17 15:20:54 | [diff] [blame] | 131 | // Adds an access request for the given URL. The requests are stored using |
| 132 | // a prefix followed by a URIEncoded version of the URL. Each entry contains |
| 133 | // a dictionary which currently has the timestamp of the request in it. |
bauerb | 646019b1 | 2014-10-16 16:23:09 | [diff] [blame] | 134 | void AddAccessRequest(const GURL& url, const SuccessCallback& callback); |
[email protected] | e861bba | 2013-06-17 15:20:54 | [diff] [blame] | 135 | |
[email protected] | a9c2d64 | 2013-05-31 14:37:14 | [diff] [blame] | 136 | // Returns the email address of the custodian. |
| 137 | std::string GetCustodianEmailAddress() const; |
| 138 | |
[email protected] | fae057a | 2013-06-21 22:46:08 | [diff] [blame] | 139 | // Returns the name of the custodian, or the email address if the name is |
| 140 | // empty. |
| 141 | std::string GetCustodianName() const; |
| 142 | |
treib | 3e7ecf7 | 2014-10-24 16:44:07 | [diff] [blame] | 143 | // Returns the email address of the second custodian, or the empty string |
| 144 | // if there is no second custodian. |
| 145 | std::string GetSecondCustodianEmailAddress() const; |
| 146 | |
| 147 | // Returns the name of the second custodian, or the email address if the name |
| 148 | // is empty, or the empty string is there is no second custodian. |
| 149 | std::string GetSecondCustodianName() const; |
| 150 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 151 | // Initializes this object. This method does nothing if the profile is not |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 152 | // supervised. |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 153 | void Init(); |
| 154 | |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 155 | // Initializes this profile for syncing, using the provided |refresh_token| to |
| 156 | // mint access tokens for Sync. |
| 157 | void InitSync(const std::string& refresh_token); |
[email protected] | acfcfbb | 2013-05-13 18:01:27 | [diff] [blame] | 158 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 159 | // Convenience method that registers this supervised user using |
[email protected] | 458d5944 | 2013-08-01 14:19:32 | [diff] [blame] | 160 | // |registration_utility| and initializes sync with the returned token. |
| 161 | // The |callback| will be called when registration is complete, |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 162 | // whether it succeeded or not -- unless registration was cancelled manually, |
[email protected] | 458d5944 | 2013-08-01 14:19:32 | [diff] [blame] | 163 | // in which case the callback will be ignored. |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 164 | void RegisterAndInitSync( |
| 165 | SupervisedUserRegistrationUtility* registration_utility, |
| 166 | Profile* custodian_profile, |
| 167 | const std::string& supervised_user_id, |
| 168 | const AuthErrorCallback& callback); |
[email protected] | acfcfbb | 2013-05-13 18:01:27 | [diff] [blame] | 169 | |
[email protected] | 4f02aac1 | 2013-05-20 05:19:06 | [diff] [blame] | 170 | void set_elevated_for_testing(bool skip) { |
| 171 | elevated_for_testing_ = skip; |
[email protected] | 849749d | 2013-05-06 17:30:45 | [diff] [blame] | 172 | } |
| 173 | |
[email protected] | 438f7e1 | 2013-08-07 06:59:00 | [diff] [blame] | 174 | void AddNavigationBlockedCallback(const NavigationBlockedCallback& callback); |
| 175 | void DidBlockNavigation(content::WebContents* web_contents); |
| 176 | |
treib | ab0a39e | 2014-09-24 14:48:28 | [diff] [blame] | 177 | void AddObserver(SupervisedUserServiceObserver* observer); |
| 178 | void RemoveObserver(SupervisedUserServiceObserver* observer); |
| 179 | |
treib | 531fc731 | 2014-12-09 12:49:20 | [diff] [blame] | 180 | void AddPermissionRequestCreator( |
| 181 | scoped_ptr<PermissionRequestCreator> creator); |
bauerb | 646019b1 | 2014-10-16 16:23:09 | [diff] [blame] | 182 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 183 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | ce01914 | 2013-02-12 18:08:10 | [diff] [blame] | 184 | // extensions::ManagementPolicy::Provider implementation: |
dcheng | c072fff | 2014-10-21 11:39:05 | [diff] [blame] | 185 | std::string GetDebugPolicyProviderName() const override; |
| 186 | bool UserMayLoad(const extensions::Extension* extension, |
| 187 | base::string16* error) const override; |
| 188 | bool UserMayModifySettings(const extensions::Extension* extension, |
| 189 | base::string16* error) const override; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 190 | |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 191 | // extensions::ExtensionRegistryObserver implementation. |
dcheng | c072fff | 2014-10-21 11:39:05 | [diff] [blame] | 192 | void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 193 | const extensions::Extension* extension) override; |
| 194 | void OnExtensionUnloaded( |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 195 | content::BrowserContext* browser_context, |
| 196 | const extensions::Extension* extension, |
mostynb | fb66cb4f | 2014-10-07 09:15:42 | [diff] [blame] | 197 | extensions::UnloadedExtensionInfo::Reason reason) override; |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 198 | #endif |
| 199 | |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 200 | // SyncTypePreferenceProvider implementation: |
dcheng | c072fff | 2014-10-21 11:39:05 | [diff] [blame] | 201 | syncer::ModelTypeSet GetPreferredDataTypes() const override; |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 202 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 203 | // ProfileSyncServiceObserver implementation: |
dcheng | c072fff | 2014-10-21 11:39:05 | [diff] [blame] | 204 | void OnStateChanged() override; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 205 | |
[email protected] | dfddd02 | 2013-07-10 17:29:48 | [diff] [blame] | 206 | // chrome::BrowserListObserver implementation: |
dcheng | c072fff | 2014-10-21 11:39:05 | [diff] [blame] | 207 | void OnBrowserSetLastActive(Browser* browser) override; |
[email protected] | dfddd02 | 2013-07-10 17:29:48 | [diff] [blame] | 208 | |
bauerb | ce9a1a8 | 2014-12-18 13:34:24 | [diff] [blame] | 209 | // SupervisedUserURLFilter::Observer implementation: |
| 210 | void OnSiteListUpdated() override; |
| 211 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 212 | private: |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 213 | friend class SupervisedUserServiceExtensionTestBase; |
| 214 | friend class SupervisedUserServiceFactory; |
pvalenzuela | c2ca458 | 2014-10-14 19:24:57 | [diff] [blame] | 215 | FRIEND_TEST_ALL_PREFIXES(SingleClientSupervisedUserSettingsSyncTest, Sanity); |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 216 | FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); |
fhorschig | 1f351f0 | 2014-09-30 12:30:22 | [diff] [blame] | 217 | FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, |
| 218 | ChangesIncludedSessionOnChangedSettings); |
| 219 | FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, |
| 220 | ChangesSyncSessionStateOnChangedSettings); |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 221 | // A bridge from the UI thread to the SupervisedUserURLFilters, one of which |
| 222 | // lives on the IO thread. This class mediates access to them and makes sure |
| 223 | // they are kept in sync. |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 224 | class URLFilterContext { |
| 225 | public: |
| 226 | URLFilterContext(); |
| 227 | ~URLFilterContext(); |
| 228 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 229 | SupervisedUserURLFilter* ui_url_filter() const; |
| 230 | SupervisedUserURLFilter* io_url_filter() const; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 231 | |
| 232 | void SetDefaultFilteringBehavior( |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 233 | SupervisedUserURLFilter::FilteringBehavior behavior); |
| 234 | void LoadWhitelists(ScopedVector<SupervisedUserSiteList> site_lists); |
bauerb | ce9a1a8 | 2014-12-18 13:34:24 | [diff] [blame] | 235 | void LoadBlacklist(const base::FilePath& path, |
| 236 | const base::Closure& callback); |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 237 | void SetManualHosts(scoped_ptr<std::map<std::string, bool> > host_map); |
| 238 | void SetManualURLs(scoped_ptr<std::map<GURL, bool> > url_map); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 239 | |
treib | 9e4fab90 | 2014-10-29 14:25:26 | [diff] [blame] | 240 | void InitAsyncURLChecker(net::URLRequestContextGetter* context, |
treib | e81fd0f | 2014-11-24 12:35:48 | [diff] [blame] | 241 | const std::string& cx); |
treib | 9e4fab90 | 2014-10-29 14:25:26 | [diff] [blame] | 242 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 243 | private: |
bauerb | ce9a1a8 | 2014-12-18 13:34:24 | [diff] [blame] | 244 | void OnBlacklistLoaded(const base::Closure& callback); |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 245 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 246 | // SupervisedUserURLFilter is refcounted because the IO thread filter is |
| 247 | // used both by ProfileImplIOData and OffTheRecordProfileIOData (to filter |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 248 | // network requests), so they both keep a reference to it. |
| 249 | // Clients should not keep references to the UI thread filter, however |
| 250 | // (the filter will live as long as the profile lives, and afterwards it |
| 251 | // should not be used anymore either). |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 252 | scoped_refptr<SupervisedUserURLFilter> ui_url_filter_; |
| 253 | scoped_refptr<SupervisedUserURLFilter> io_url_filter_; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 254 | |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 255 | SupervisedUserBlacklist blacklist_; |
| 256 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 257 | DISALLOW_COPY_AND_ASSIGN(URLFilterContext); |
| 258 | }; |
| 259 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 260 | // Use |SupervisedUserServiceFactory::GetForProfile(..)| to get |
[email protected] | 3bf45d0 | 2013-07-10 00:03:41 | [diff] [blame] | 261 | // an instance of this service. |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 262 | explicit SupervisedUserService(Profile* profile); |
[email protected] | 3bf45d0 | 2013-07-10 00:03:41 | [diff] [blame] | 263 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 264 | void SetActive(bool active); |
| 265 | |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 266 | void OnCustodianProfileDownloaded(const base::string16& full_name); |
[email protected] | 200729f8 | 2013-06-22 07:05:55 | [diff] [blame] | 267 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 268 | void OnSupervisedUserRegistered(const AuthErrorCallback& callback, |
| 269 | Profile* custodian_profile, |
| 270 | const GoogleServiceAuthError& auth_error, |
| 271 | const std::string& token); |
[email protected] | acfcfbb | 2013-05-13 18:01:27 | [diff] [blame] | 272 | |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 273 | void SetupSync(); |
[email protected] | 6e08b9a6 | 2014-07-08 00:32:48 | [diff] [blame] | 274 | void StartSetupSync(); |
| 275 | void FinishSetupSyncWhenReady(); |
| 276 | void FinishSetupSync(); |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 277 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 278 | bool ProfileIsSupervised() const; |
[email protected] | e000daf | 2013-07-31 16:50:58 | [diff] [blame] | 279 | |
treib | 3fce4e9 | 2014-09-26 16:06:25 | [diff] [blame] | 280 | void OnCustodianInfoChanged(); |
| 281 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 282 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 283 | // Internal implementation for ExtensionManagementPolicy::Delegate methods. |
| 284 | // If |error| is not NULL, it will be filled with an error message if the |
| 285 | // requested extension action (install, modify status, etc.) is not permitted. |
[email protected] | 38b7fb9 | 2013-07-26 16:32:26 | [diff] [blame] | 286 | bool ExtensionManagementPolicyImpl(const extensions::Extension* extension, |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 287 | base::string16* error) const; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 288 | |
| 289 | // Returns a list of all installed and enabled site lists in the current |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 290 | // supervised profile. |
| 291 | ScopedVector<SupervisedUserSiteList> GetActiveSiteLists(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 292 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 293 | // Extensions helper to SetActive(). |
| 294 | void SetExtensionsActive(); |
| 295 | #endif |
| 296 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 297 | SupervisedUserSettingsService* GetSettingsService(); |
[email protected] | e861bba | 2013-06-17 15:20:54 | [diff] [blame] | 298 | |
bauerb | d3a36cc4 | 2014-10-01 13:05:49 | [diff] [blame] | 299 | size_t FindEnabledPermissionRequestCreator(size_t start); |
bauerb | 646019b1 | 2014-10-16 16:23:09 | [diff] [blame] | 300 | void AddAccessRequestInternal(const GURL& url, |
| 301 | const SuccessCallback& callback, |
| 302 | size_t index); |
| 303 | void OnPermissionRequestIssued(const GURL& url, |
| 304 | const SuccessCallback& callback, |
| 305 | size_t index, |
| 306 | bool success); |
bauerb | d3a36cc4 | 2014-10-01 13:05:49 | [diff] [blame] | 307 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 308 | void OnSupervisedUserIdChanged(); |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 309 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 310 | void OnDefaultFilteringBehaviorChanged(); |
| 311 | |
| 312 | void UpdateSiteLists(); |
| 313 | |
treib | f136dfb | 2014-09-25 17:37:47 | [diff] [blame] | 314 | // Asynchronously downloads a static blacklist file from |url|, stores it at |
| 315 | // |path|, loads it, and applies it to the URL filters. If |url| is not valid |
| 316 | // (e.g. empty), directly tries to load from |path|. |
| 317 | void LoadBlacklist(const base::FilePath& path, const GURL& url); |
| 318 | |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 319 | // Asynchronously loads a static blacklist from a binary file at |path| and |
| 320 | // applies it to the URL filters. |
treib | f136dfb | 2014-09-25 17:37:47 | [diff] [blame] | 321 | void LoadBlacklistFromFile(const base::FilePath& path); |
| 322 | |
| 323 | void OnBlacklistDownloadDone(const base::FilePath& path, bool success); |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 324 | |
bauerb | ce9a1a8 | 2014-12-18 13:34:24 | [diff] [blame] | 325 | void OnBlacklistLoaded(); |
| 326 | |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 327 | // Updates the manual overrides for hosts in the URL filters when the |
| 328 | // corresponding preference is changed. |
| 329 | void UpdateManualHosts(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 330 | |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 331 | // Updates the manual overrides for URLs in the URL filters when the |
| 332 | // corresponding preference is changed. |
| 333 | void UpdateManualURLs(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 334 | |
[email protected] | 0b4c6b2 | 2014-08-04 09:46:31 | [diff] [blame] | 335 | // Returns the human readable name of the supervised user. |
| 336 | std::string GetSupervisedUserName() const; |
| 337 | |
fhorschig | 1f351f0 | 2014-09-30 12:30:22 | [diff] [blame] | 338 | // Subscribes to the SupervisedUserPrefStore, refreshes |
| 339 | // |includes_sync_sessions_type_| and triggers reconfiguring the |
| 340 | // ProfileSyncService. |
| 341 | void OnHistoryRecordingStateChanged(); |
| 342 | |
| 343 | // Returns true if the syncer::SESSIONS type should be included in Sync. |
| 344 | bool IncludesSyncSessionsType() const; |
| 345 | |
| 346 | // The option a custodian sets to either record or prevent recording the |
| 347 | // supervised user's history. Set by |FetchNewSessionSyncState()| and |
| 348 | // defaults to true. |
| 349 | bool includes_sync_sessions_type_; |
| 350 | |
[email protected] | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 351 | // Owns us via the KeyedService mechanism. |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 352 | Profile* profile_; |
| 353 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 354 | bool active_; |
| 355 | |
| 356 | Delegate* delegate_; |
| 357 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 358 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 359 | ScopedObserver<extensions::ExtensionRegistry, |
| 360 | extensions::ExtensionRegistryObserver> |
| 361 | extension_registry_observer_; |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 362 | #endif |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 363 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 364 | PrefChangeRegistrar pref_change_registrar_; |
| 365 | |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 366 | // True iff we're waiting for the Sync service to be initialized. |
| 367 | bool waiting_for_sync_initialization_; |
[email protected] | dfddd02 | 2013-07-10 17:29:48 | [diff] [blame] | 368 | bool is_profile_active_; |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 369 | |
[email protected] | 438f7e1 | 2013-08-07 06:59:00 | [diff] [blame] | 370 | std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; |
| 371 | |
[email protected] | 4f02aac1 | 2013-05-20 05:19:06 | [diff] [blame] | 372 | // Sets a profile in elevated state for testing if set to true. |
| 373 | bool elevated_for_testing_; |
[email protected] | 849749d | 2013-05-06 17:30:45 | [diff] [blame] | 374 | |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 375 | // True only when |Init()| method has been called. |
| 376 | bool did_init_; |
| 377 | |
[email protected] | 3bf45d0 | 2013-07-10 00:03:41 | [diff] [blame] | 378 | // True only when |Shutdown()| method has been called. |
| 379 | bool did_shutdown_; |
| 380 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 381 | URLFilterContext url_filter_context_; |
treib | f136dfb | 2014-09-25 17:37:47 | [diff] [blame] | 382 | scoped_ptr<SupervisedUserBlacklistDownloader> blacklist_downloader_; |
[email protected] | 8052b24 | 2013-11-15 16:40:55 | [diff] [blame] | 383 | |
bauerb | 4da3613 | 2014-12-26 19:53:13 | [diff] [blame^] | 384 | scoped_ptr<SupervisedUserWhitelistService> whitelist_service_; |
| 385 | |
[email protected] | 4db65f95 | 2014-05-20 15:46:30 | [diff] [blame] | 386 | // Used to create permission requests. |
bauerb | d3a36cc4 | 2014-10-01 13:05:49 | [diff] [blame] | 387 | ScopedVector<PermissionRequestCreator> permissions_creators_; |
[email protected] | 4db65f95 | 2014-05-20 15:46:30 | [diff] [blame] | 388 | |
treib | ab0a39e | 2014-09-24 14:48:28 | [diff] [blame] | 389 | ObserverList<SupervisedUserServiceObserver> observer_list_; |
| 390 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 391 | base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 392 | }; |
| 393 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 394 | #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |