[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> |
[email protected] | 0d9a1da8 | 2013-03-14 21:52:07 | [diff] [blame] | 9 | #include <set> |
treib | 950c6e8 | 2014-09-23 13:07:29 | [diff] [blame^] | 10 | #include <string> |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
[email protected] | 438f7e1 | 2013-08-07 06:59:00 | [diff] [blame] | 13 | #include "base/callback.h" |
[email protected] | 076ebeda | 2014-06-06 21:47:26 | [diff] [blame] | 14 | #include "base/gtest_prod_util.h" |
[email protected] | a581ea2 | 2013-05-06 12:34:19 | [diff] [blame] | 15 | #include "base/memory/scoped_ptr.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] | bfd8cf98 | 2013-03-04 15:24:00 | [diff] [blame] | 26 | #include "content/public/browser/web_contents.h" |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 27 | |
| 28 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 29 | #include "extensions/browser/extension_registry_observer.h" |
[email protected] | 301116c6 | 2013-11-26 10:37:45 | [diff] [blame] | 30 | #include "extensions/browser/management_policy.h" |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 31 | #endif |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 32 | |
[email protected] | 509ad1a9 | 2013-03-19 21:41:06 | [diff] [blame] | 33 | class Browser; |
[email protected] | acfcfbb | 2013-05-13 18:01:27 | [diff] [blame] | 34 | class GoogleServiceAuthError; |
[email protected] | 4db65f95 | 2014-05-20 15:46:30 | [diff] [blame] | 35 | class PermissionRequestCreator; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 36 | class Profile; |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 37 | class SupervisedUserRegistrationUtility; |
| 38 | class SupervisedUserSettingsService; |
| 39 | class SupervisedUserSiteList; |
| 40 | class SupervisedUserURLFilter; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 41 | |
treib | daece84f | 2014-09-05 12:58:15 | [diff] [blame] | 42 | namespace base { |
| 43 | class FilePath; |
| 44 | } |
| 45 | |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 46 | namespace extensions { |
| 47 | class ExtensionRegistry; |
| 48 | } |
| 49 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 50 | namespace user_prefs { |
| 51 | class PrefRegistrySyncable; |
| 52 | } |
| 53 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 54 | // This class handles all the information related to a given supervised profile |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 55 | // (e.g. the installed content packs, the default URL filtering behavior, or |
| 56 | // manual whitelist/blacklist overrides). |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 57 | class SupervisedUserService : public KeyedService, |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 58 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 59 | public extensions::ManagementPolicy::Provider, |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 60 | public extensions::ExtensionRegistryObserver, |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 61 | #endif |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 62 | public SyncTypePreferenceProvider, |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 63 | public ProfileSyncServiceObserver, |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 64 | public chrome::BrowserListObserver { |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 65 | public: |
[email protected] | d2065e06 | 2013-12-12 23:49:52 | [diff] [blame] | 66 | typedef std::vector<base::string16> CategoryList; |
[email protected] | 438f7e1 | 2013-08-07 06:59:00 | [diff] [blame] | 67 | typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback; |
[email protected] | 514fcf2 | 2013-08-13 06:37:24 | [diff] [blame] | 68 | typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 69 | |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 70 | enum ManualBehavior { |
| 71 | MANUAL_NONE = 0, |
| 72 | MANUAL_ALLOW, |
| 73 | MANUAL_BLOCK |
| 74 | }; |
| 75 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 76 | class Delegate { |
| 77 | public: |
| 78 | virtual ~Delegate() {} |
| 79 | // Returns true to indicate that the delegate handled the (de)activation, or |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 80 | // false to indicate that the SupervisedUserService itself should handle it. |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 81 | virtual bool SetActive(bool active) = 0; |
treib | daece84f | 2014-09-05 12:58:15 | [diff] [blame] | 82 | // Returns the path to a blacklist file to load, or an empty path to |
| 83 | // indicate "none". |
| 84 | virtual base::FilePath GetBlacklistPath() const = 0; |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 85 | }; |
| 86 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 87 | virtual ~SupervisedUserService(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 88 | |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 89 | // ProfileKeyedService override: |
| 90 | virtual void Shutdown() OVERRIDE; |
| 91 | |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame] | 92 | static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 93 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 94 | void SetDelegate(Delegate* delegate); |
| 95 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 96 | // Returns the URL filter for the IO thread, for filtering network requests |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 97 | // (in SupervisedUserResourceThrottle). |
| 98 | scoped_refptr<const SupervisedUserURLFilter> GetURLFilterForIOThread(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 99 | |
| 100 | // Returns the URL filter for the UI thread, for filtering navigations and |
| 101 | // classifying sites in the history view. |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 102 | SupervisedUserURLFilter* GetURLFilterForUIThread(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 103 | |
| 104 | // Returns the URL's category, obtained from the installed content packs. |
| 105 | int GetCategory(const GURL& url); |
| 106 | |
| 107 | // Returns the list of all known human-readable category names, sorted by ID |
| 108 | // number. Called in the critical path of drawing the history UI, so needs to |
| 109 | // be fast. |
| 110 | void GetCategoryNames(CategoryList* list); |
| 111 | |
[email protected] | 0369d6ab | 2013-08-09 01:52:59 | [diff] [blame] | 112 | // Whether the user can request access to blocked URLs. |
| 113 | bool AccessRequestsEnabled(); |
| 114 | |
[email protected] | 4db65f95 | 2014-05-20 15:46:30 | [diff] [blame] | 115 | void OnPermissionRequestIssued(); |
| 116 | |
[email protected] | e861bba | 2013-06-17 15:20:54 | [diff] [blame] | 117 | // Adds an access request for the given URL. The requests are stored using |
| 118 | // a prefix followed by a URIEncoded version of the URL. Each entry contains |
| 119 | // a dictionary which currently has the timestamp of the request in it. |
| 120 | void AddAccessRequest(const GURL& url); |
| 121 | |
[email protected] | a9c2d64 | 2013-05-31 14:37:14 | [diff] [blame] | 122 | // Returns the email address of the custodian. |
| 123 | std::string GetCustodianEmailAddress() const; |
| 124 | |
[email protected] | fae057a | 2013-06-21 22:46:08 | [diff] [blame] | 125 | // Returns the name of the custodian, or the email address if the name is |
| 126 | // empty. |
| 127 | std::string GetCustodianName() const; |
| 128 | |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 129 | // These methods allow querying and modifying the manual filtering behavior. |
| 130 | // The manual behavior is set by the user and overrides all other settings |
| 131 | // (whitelists or the default behavior). |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 132 | |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 133 | // Returns the manual behavior for the given host. |
| 134 | ManualBehavior GetManualBehaviorForHost(const std::string& hostname); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 135 | |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 136 | // Returns the manual behavior for the given URL. |
| 137 | ManualBehavior GetManualBehaviorForURL(const GURL& url); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 138 | |
[email protected] | 4325790 | 2013-03-26 20:59:37 | [diff] [blame] | 139 | // Returns all URLS on the given host that have exceptions. |
| 140 | void GetManualExceptionsForHost(const std::string& host, |
| 141 | std::vector<GURL>* urls); |
| 142 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 143 | // Initializes this object. This method does nothing if the profile is not |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 144 | // supervised. |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 145 | void Init(); |
| 146 | |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 147 | // Initializes this profile for syncing, using the provided |refresh_token| to |
| 148 | // mint access tokens for Sync. |
| 149 | void InitSync(const std::string& refresh_token); |
[email protected] | acfcfbb | 2013-05-13 18:01:27 | [diff] [blame] | 150 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 151 | // Convenience method that registers this supervised user using |
[email protected] | 458d5944 | 2013-08-01 14:19:32 | [diff] [blame] | 152 | // |registration_utility| and initializes sync with the returned token. |
| 153 | // The |callback| will be called when registration is complete, |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 154 | // whether it succeeded or not -- unless registration was cancelled manually, |
[email protected] | 458d5944 | 2013-08-01 14:19:32 | [diff] [blame] | 155 | // in which case the callback will be ignored. |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 156 | void RegisterAndInitSync( |
| 157 | SupervisedUserRegistrationUtility* registration_utility, |
| 158 | Profile* custodian_profile, |
| 159 | const std::string& supervised_user_id, |
| 160 | const AuthErrorCallback& callback); |
[email protected] | acfcfbb | 2013-05-13 18:01:27 | [diff] [blame] | 161 | |
[email protected] | 4f02aac1 | 2013-05-20 05:19:06 | [diff] [blame] | 162 | void set_elevated_for_testing(bool skip) { |
| 163 | elevated_for_testing_ = skip; |
[email protected] | 849749d | 2013-05-06 17:30:45 | [diff] [blame] | 164 | } |
| 165 | |
[email protected] | 438f7e1 | 2013-08-07 06:59:00 | [diff] [blame] | 166 | void AddNavigationBlockedCallback(const NavigationBlockedCallback& callback); |
| 167 | void DidBlockNavigation(content::WebContents* web_contents); |
| 168 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 169 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | ce01914 | 2013-02-12 18:08:10 | [diff] [blame] | 170 | // extensions::ManagementPolicy::Provider implementation: |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 171 | virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
| 172 | virtual bool UserMayLoad(const extensions::Extension* extension, |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 173 | base::string16* error) const OVERRIDE; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 174 | virtual bool UserMayModifySettings(const extensions::Extension* extension, |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 175 | base::string16* error) const OVERRIDE; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 176 | |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 177 | // extensions::ExtensionRegistryObserver implementation. |
| 178 | virtual void OnExtensionLoaded( |
| 179 | content::BrowserContext* browser_context, |
| 180 | const extensions::Extension* extension) OVERRIDE; |
| 181 | virtual void OnExtensionUnloaded( |
| 182 | content::BrowserContext* browser_context, |
| 183 | const extensions::Extension* extension, |
| 184 | extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 185 | #endif |
| 186 | |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 187 | // SyncTypePreferenceProvider implementation: |
| 188 | virtual syncer::ModelTypeSet GetPreferredDataTypes() const OVERRIDE; |
| 189 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 190 | // ProfileSyncServiceObserver implementation: |
| 191 | virtual void OnStateChanged() OVERRIDE; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 192 | |
[email protected] | dfddd02 | 2013-07-10 17:29:48 | [diff] [blame] | 193 | // chrome::BrowserListObserver implementation: |
| 194 | virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; |
| 195 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 196 | private: |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 197 | friend class SupervisedUserServiceExtensionTestBase; |
| 198 | friend class SupervisedUserServiceFactory; |
| 199 | FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 200 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 201 | // A bridge from the UI thread to the SupervisedUserURLFilters, one of which |
| 202 | // lives on the IO thread. This class mediates access to them and makes sure |
| 203 | // they are kept in sync. |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 204 | class URLFilterContext { |
| 205 | public: |
| 206 | URLFilterContext(); |
| 207 | ~URLFilterContext(); |
| 208 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 209 | SupervisedUserURLFilter* ui_url_filter() const; |
| 210 | SupervisedUserURLFilter* io_url_filter() const; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 211 | |
| 212 | void SetDefaultFilteringBehavior( |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 213 | SupervisedUserURLFilter::FilteringBehavior behavior); |
| 214 | void LoadWhitelists(ScopedVector<SupervisedUserSiteList> site_lists); |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 215 | void LoadBlacklist(const base::FilePath& path); |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [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 | |
| 219 | private: |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 220 | void OnBlacklistLoaded(); |
| 221 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 222 | // SupervisedUserURLFilter is refcounted because the IO thread filter is |
| 223 | // used both by ProfileImplIOData and OffTheRecordProfileIOData (to filter |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 224 | // network requests), so they both keep a reference to it. |
| 225 | // Clients should not keep references to the UI thread filter, however |
| 226 | // (the filter will live as long as the profile lives, and afterwards it |
| 227 | // should not be used anymore either). |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 228 | scoped_refptr<SupervisedUserURLFilter> ui_url_filter_; |
| 229 | scoped_refptr<SupervisedUserURLFilter> io_url_filter_; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 230 | |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 231 | SupervisedUserBlacklist blacklist_; |
| 232 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 233 | DISALLOW_COPY_AND_ASSIGN(URLFilterContext); |
| 234 | }; |
| 235 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 236 | // Use |SupervisedUserServiceFactory::GetForProfile(..)| to get |
[email protected] | 3bf45d0 | 2013-07-10 00:03:41 | [diff] [blame] | 237 | // an instance of this service. |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 238 | explicit SupervisedUserService(Profile* profile); |
[email protected] | 3bf45d0 | 2013-07-10 00:03:41 | [diff] [blame] | 239 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 240 | void SetActive(bool active); |
| 241 | |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 242 | void OnCustodianProfileDownloaded(const base::string16& full_name); |
[email protected] | 200729f8 | 2013-06-22 07:05:55 | [diff] [blame] | 243 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 244 | void OnSupervisedUserRegistered(const AuthErrorCallback& callback, |
| 245 | Profile* custodian_profile, |
| 246 | const GoogleServiceAuthError& auth_error, |
| 247 | const std::string& token); |
[email protected] | acfcfbb | 2013-05-13 18:01:27 | [diff] [blame] | 248 | |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 249 | void SetupSync(); |
[email protected] | 6e08b9a6 | 2014-07-08 00:32:48 | [diff] [blame] | 250 | void StartSetupSync(); |
| 251 | void FinishSetupSyncWhenReady(); |
| 252 | void FinishSetupSync(); |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 253 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 254 | bool ProfileIsSupervised() const; |
[email protected] | e000daf | 2013-07-31 16:50:58 | [diff] [blame] | 255 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 256 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 257 | // Internal implementation for ExtensionManagementPolicy::Delegate methods. |
| 258 | // If |error| is not NULL, it will be filled with an error message if the |
| 259 | // requested extension action (install, modify status, etc.) is not permitted. |
[email protected] | 38b7fb9 | 2013-07-26 16:32:26 | [diff] [blame] | 260 | bool ExtensionManagementPolicyImpl(const extensions::Extension* extension, |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 261 | base::string16* error) const; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 262 | |
| 263 | // Returns a list of all installed and enabled site lists in the current |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 264 | // supervised profile. |
| 265 | ScopedVector<SupervisedUserSiteList> GetActiveSiteLists(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 266 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 267 | // Extensions helper to SetActive(). |
| 268 | void SetExtensionsActive(); |
| 269 | #endif |
| 270 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 271 | SupervisedUserSettingsService* GetSettingsService(); |
[email protected] | e861bba | 2013-06-17 15:20:54 | [diff] [blame] | 272 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 273 | void OnSupervisedUserIdChanged(); |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 274 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 275 | void OnDefaultFilteringBehaviorChanged(); |
| 276 | |
| 277 | void UpdateSiteLists(); |
| 278 | |
treib | 4edbded | 2014-09-05 08:43:55 | [diff] [blame] | 279 | // Asynchronously loads a static blacklist from a binary file at |path| and |
| 280 | // applies it to the URL filters. |
| 281 | void LoadBlacklist(const base::FilePath& path); |
| 282 | |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 283 | // Updates the manual overrides for hosts in the URL filters when the |
| 284 | // corresponding preference is changed. |
| 285 | void UpdateManualHosts(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 286 | |
[email protected] | 5e02229 | 2013-02-06 16:42:17 | [diff] [blame] | 287 | // Updates the manual overrides for URLs in the URL filters when the |
| 288 | // corresponding preference is changed. |
| 289 | void UpdateManualURLs(); |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 290 | |
[email protected] | 0b4c6b2 | 2014-08-04 09:46:31 | [diff] [blame] | 291 | // Returns the human readable name of the supervised user. |
| 292 | std::string GetSupervisedUserName() const; |
| 293 | |
[email protected] | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 294 | // Owns us via the KeyedService mechanism. |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 295 | Profile* profile_; |
| 296 | |
[email protected] | f085fdd5 | 2014-06-11 18:09:20 | [diff] [blame] | 297 | bool active_; |
| 298 | |
| 299 | Delegate* delegate_; |
| 300 | |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 301 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 302 | ScopedObserver<extensions::ExtensionRegistry, |
| 303 | extensions::ExtensionRegistryObserver> |
| 304 | extension_registry_observer_; |
[email protected] | c14a680 | 2014-07-11 21:51:12 | [diff] [blame] | 305 | #endif |
[email protected] | f2253ac | 2014-05-28 08:37:21 | [diff] [blame] | 306 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 307 | PrefChangeRegistrar pref_change_registrar_; |
| 308 | |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 309 | // True iff we're waiting for the Sync service to be initialized. |
| 310 | bool waiting_for_sync_initialization_; |
[email protected] | dfddd02 | 2013-07-10 17:29:48 | [diff] [blame] | 311 | bool is_profile_active_; |
[email protected] | a243d644c | 2013-06-20 18:37:55 | [diff] [blame] | 312 | |
[email protected] | 438f7e1 | 2013-08-07 06:59:00 | [diff] [blame] | 313 | std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; |
| 314 | |
[email protected] | 4f02aac1 | 2013-05-20 05:19:06 | [diff] [blame] | 315 | // Sets a profile in elevated state for testing if set to true. |
| 316 | bool elevated_for_testing_; |
[email protected] | 849749d | 2013-05-06 17:30:45 | [diff] [blame] | 317 | |
[email protected] | 3a276ff | 2014-08-12 14:22:09 | [diff] [blame] | 318 | // True only when |Init()| method has been called. |
| 319 | bool did_init_; |
| 320 | |
[email protected] | 3bf45d0 | 2013-07-10 00:03:41 | [diff] [blame] | 321 | // True only when |Shutdown()| method has been called. |
| 322 | bool did_shutdown_; |
| 323 | |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 324 | URLFilterContext url_filter_context_; |
[email protected] | 8052b24 | 2013-11-15 16:40:55 | [diff] [blame] | 325 | |
[email protected] | 4db65f95 | 2014-05-20 15:46:30 | [diff] [blame] | 326 | // Used to create permission requests. |
| 327 | scoped_ptr<PermissionRequestCreator> permissions_creator_; |
| 328 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 329 | base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; |
[email protected] | 0850e84 | 2013-01-19 03:44:31 | [diff] [blame] | 330 | }; |
| 331 | |
[email protected] | cce15bb | 2014-06-17 13:43:51 | [diff] [blame] | 332 | #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |