| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // manual whitelist/blacklist overrides). | 62 // manual whitelist/blacklist overrides). |
| 63 class SupervisedUserService : public KeyedService, | 63 class SupervisedUserService : public KeyedService, |
| 64 #if defined(ENABLE_EXTENSIONS) | 64 #if defined(ENABLE_EXTENSIONS) |
| 65 public extensions::ManagementPolicy::Provider, | 65 public extensions::ManagementPolicy::Provider, |
| 66 #endif | 66 #endif |
| 67 public SyncTypePreferenceProvider, | 67 public SyncTypePreferenceProvider, |
| 68 public ProfileSyncServiceObserver, | 68 public ProfileSyncServiceObserver, |
| 69 public chrome::BrowserListObserver, | 69 public chrome::BrowserListObserver, |
| 70 public SupervisedUserURLFilter::Observer { | 70 public SupervisedUserURLFilter::Observer { |
| 71 public: | 71 public: |
| 72 typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback; | 72 using NavigationBlockedCallback = base::Callback<void(content::WebContents*)>; |
| 73 typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback; | 73 using AuthErrorCallback = base::Callback<void(const GoogleServiceAuthError&)>; |
| 74 typedef base::Callback<void(bool)> SuccessCallback; | 74 using SuccessCallback = base::Callback<void(bool)>; |
| 75 | 75 |
| 76 class Delegate { | 76 class Delegate { |
| 77 public: | 77 public: |
| 78 virtual ~Delegate() {} | 78 virtual ~Delegate() {} |
| 79 // Returns true to indicate that the delegate handled the (de)activation, or | 79 // Returns true to indicate that the delegate handled the (de)activation, or |
| 80 // false to indicate that the SupervisedUserService itself should handle it. | 80 // false to indicate that the SupervisedUserService itself should handle it. |
| 81 virtual bool SetActive(bool active) = 0; | 81 virtual bool SetActive(bool active) = 0; |
| 82 // Returns the path to a blacklist file to load, or an empty path to | 82 // Returns the path to a blacklist file to load, or an empty path to |
| 83 // indicate "none". | 83 // indicate "none". |
| 84 virtual base::FilePath GetBlacklistPath() const; | 84 virtual base::FilePath GetBlacklistPath() const; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 104 // (in SupervisedUserResourceThrottle). | 104 // (in SupervisedUserResourceThrottle). |
| 105 scoped_refptr<const SupervisedUserURLFilter> GetURLFilterForIOThread(); | 105 scoped_refptr<const SupervisedUserURLFilter> GetURLFilterForIOThread(); |
| 106 | 106 |
| 107 // Returns the URL filter for the UI thread, for filtering navigations and | 107 // Returns the URL filter for the UI thread, for filtering navigations and |
| 108 // classifying sites in the history view. | 108 // classifying sites in the history view. |
| 109 SupervisedUserURLFilter* GetURLFilterForUIThread(); | 109 SupervisedUserURLFilter* GetURLFilterForUIThread(); |
| 110 | 110 |
| 111 // Returns the whitelist service. | 111 // Returns the whitelist service. |
| 112 SupervisedUserWhitelistService* GetWhitelistService(); | 112 SupervisedUserWhitelistService* GetWhitelistService(); |
| 113 | 113 |
| 114 // Whether the user can request access to blocked URLs. | 114 // Whether the user can request to get access to blocked URLs or to new |
| 115 // extensions. |
| 115 bool AccessRequestsEnabled(); | 116 bool AccessRequestsEnabled(); |
| 116 | 117 |
| 117 // Adds an access request for the given URL. The requests are stored using | 118 // Adds an access request for the given URL. |
| 118 // a prefix followed by a URIEncoded version of the URL. Each entry contains | 119 void AddURLAccessRequest(const GURL& url, const SuccessCallback& callback); |
| 119 // a dictionary which currently has the timestamp of the request in it. | 120 |
| 120 void AddAccessRequest(const GURL& url, const SuccessCallback& callback); | 121 // Adds an update request for the given WebStore item (App/Extension). |
| 122 void AddExtensionUpdateRequest(const std::string& extension_id, |
| 123 const SuccessCallback& callback); |
| 121 | 124 |
| 122 // Returns the email address of the custodian. | 125 // Returns the email address of the custodian. |
| 123 std::string GetCustodianEmailAddress() const; | 126 std::string GetCustodianEmailAddress() const; |
| 124 | 127 |
| 125 // Returns the name of the custodian, or the email address if the name is | 128 // Returns the name of the custodian, or the email address if the name is |
| 126 // empty. | 129 // empty. |
| 127 std::string GetCustodianName() const; | 130 std::string GetCustodianName() const; |
| 128 | 131 |
| 129 // Returns the email address of the second custodian, or the empty string | 132 // Returns the email address of the second custodian, or the empty string |
| 130 // if there is no second custodian. | 133 // if there is no second custodian. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 friend class SupervisedUserServiceFactory; | 182 friend class SupervisedUserServiceFactory; |
| 180 FRIEND_TEST_ALL_PREFIXES(SingleClientSupervisedUserSettingsSyncTest, Sanity); | 183 FRIEND_TEST_ALL_PREFIXES(SingleClientSupervisedUserSettingsSyncTest, Sanity); |
| 181 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); | 184 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); |
| 182 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, | 185 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, |
| 183 ChangesIncludedSessionOnChangedSettings); | 186 ChangesIncludedSessionOnChangedSettings); |
| 184 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, | 187 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, |
| 185 ChangesSyncSessionStateOnChangedSettings); | 188 ChangesSyncSessionStateOnChangedSettings); |
| 186 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceExtensionTest, | 189 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceExtensionTest, |
| 187 ExtensionManagementPolicyProvider); | 190 ExtensionManagementPolicyProvider); |
| 188 | 191 |
| 192 using CreatePermissionRequestCallback = |
| 193 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>; |
| 194 |
| 189 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which | 195 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which |
| 190 // lives on the IO thread. This class mediates access to them and makes sure | 196 // lives on the IO thread. This class mediates access to them and makes sure |
| 191 // they are kept in sync. | 197 // they are kept in sync. |
| 192 class URLFilterContext { | 198 class URLFilterContext { |
| 193 public: | 199 public: |
| 194 URLFilterContext(); | 200 URLFilterContext(); |
| 195 ~URLFilterContext(); | 201 ~URLFilterContext(); |
| 196 | 202 |
| 197 SupervisedUserURLFilter* ui_url_filter() const; | 203 SupervisedUserURLFilter* ui_url_filter() const; |
| 198 SupervisedUserURLFilter* io_url_filter() const; | 204 SupervisedUserURLFilter* io_url_filter() const; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 bool MustRemainInstalled(const extensions::Extension* extension, | 265 bool MustRemainInstalled(const extensions::Extension* extension, |
| 260 base::string16* error) const override; | 266 base::string16* error) const override; |
| 261 | 267 |
| 262 // Extensions helper to SetActive(). | 268 // Extensions helper to SetActive(). |
| 263 void SetExtensionsActive(); | 269 void SetExtensionsActive(); |
| 264 #endif | 270 #endif |
| 265 | 271 |
| 266 SupervisedUserSettingsService* GetSettingsService(); | 272 SupervisedUserSettingsService* GetSettingsService(); |
| 267 | 273 |
| 268 size_t FindEnabledPermissionRequestCreator(size_t start); | 274 size_t FindEnabledPermissionRequestCreator(size_t start); |
| 269 void AddAccessRequestInternal(const GURL& url, | 275 void AddPermissionRequestInternal( |
| 270 const SuccessCallback& callback, | 276 const CreatePermissionRequestCallback& create_request, |
| 271 size_t index); | 277 const SuccessCallback& callback, |
| 272 void OnPermissionRequestIssued(const GURL& url, | 278 size_t index); |
| 273 const SuccessCallback& callback, | 279 void OnPermissionRequestIssued( |
| 274 size_t index, | 280 const CreatePermissionRequestCallback& create_request, |
| 275 bool success); | 281 const SuccessCallback& callback, |
| 282 size_t index, |
| 283 bool success); |
| 276 | 284 |
| 277 void OnSupervisedUserIdChanged(); | 285 void OnSupervisedUserIdChanged(); |
| 278 | 286 |
| 279 void OnDefaultFilteringBehaviorChanged(); | 287 void OnDefaultFilteringBehaviorChanged(); |
| 280 | 288 |
| 281 void OnSiteListsChanged( | 289 void OnSiteListsChanged( |
| 282 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists); | 290 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists); |
| 283 | 291 |
| 284 // Asynchronously downloads a static blacklist file from |url|, stores it at | 292 // Asynchronously downloads a static blacklist file from |url|, stores it at |
| 285 // |path|, loads it, and applies it to the URL filters. If |url| is not valid | 293 // |path|, loads it, and applies it to the URL filters. If |url| is not valid |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 354 |
| 347 // Used to create permission requests. | 355 // Used to create permission requests. |
| 348 ScopedVector<PermissionRequestCreator> permissions_creators_; | 356 ScopedVector<PermissionRequestCreator> permissions_creators_; |
| 349 | 357 |
| 350 ObserverList<SupervisedUserServiceObserver> observer_list_; | 358 ObserverList<SupervisedUserServiceObserver> observer_list_; |
| 351 | 359 |
| 352 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; | 360 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; |
| 353 }; | 361 }; |
| 354 | 362 |
| 355 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 363 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
| OLD | NEW |