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