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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 // extensions. | 118 // extensions. |
119 bool AccessRequestsEnabled(); | 119 bool AccessRequestsEnabled(); |
120 | 120 |
121 // Adds an access request for the given URL. | 121 // Adds an access request for the given URL. |
122 void AddURLAccessRequest(const GURL& url, const SuccessCallback& callback); | 122 void AddURLAccessRequest(const GURL& url, const SuccessCallback& callback); |
123 | 123 |
124 // Reports |url| to the SafeSearch API, because the user thinks this is an | 124 // Reports |url| to the SafeSearch API, because the user thinks this is an |
125 // inappropriate URL. | 125 // inappropriate URL. |
126 void ReportURL(const GURL& url, const SuccessCallback& callback); | 126 void ReportURL(const GURL& url, const SuccessCallback& callback); |
127 | 127 |
128 // Adds an install request for the given WebStore item (App/Extension). | |
129 void AddExtensionInstallRequest(const std::string& extension_id, | |
130 const base::Version& version, | |
131 const SuccessCallback& callback); | |
132 | |
133 // Same as above, but without a callback, just logging errors on failure. | |
134 void AddExtensionInstallRequest(const std::string& extension_id, | |
135 const base::Version& version); | |
136 | |
128 // Adds an update request for the given WebStore item (App/Extension). | 137 // Adds an update request for the given WebStore item (App/Extension). |
129 void AddExtensionUpdateRequest(const std::string& extension_id, | 138 void AddExtensionUpdateRequest(const std::string& extension_id, |
130 const base::Version& version, | 139 const base::Version& version, |
131 const SuccessCallback& callback); | 140 const SuccessCallback& callback); |
132 | 141 |
133 // Same as above, but without a callback, just logging errors on failure. | 142 // Same as above, but without a callback, just logging errors on failure. |
134 void AddExtensionUpdateRequest(const std::string& extension_id, | 143 void AddExtensionUpdateRequest(const std::string& extension_id, |
135 const base::Version& version); | 144 const base::Version& version); |
136 | 145 |
137 // Get the string used to identify an extension update request. Public for | 146 // Get the string used to identify an extension install or update request. |
138 // testing. | 147 // Public for testing. |
139 static std::string GetExtensionUpdateRequestId( | 148 static std::string GetExtensionRequestId(const std::string& extension_id, |
140 const std::string& extension_id, | 149 const base::Version& version); |
141 const base::Version& version); | |
142 | 150 |
143 // Returns the email address of the custodian. | 151 // Returns the email address of the custodian. |
144 std::string GetCustodianEmailAddress() const; | 152 std::string GetCustodianEmailAddress() const; |
145 | 153 |
146 // Returns the name of the custodian, or the email address if the name is | 154 // Returns the name of the custodian, or the email address if the name is |
147 // empty. | 155 // empty. |
148 std::string GetCustodianName() const; | 156 std::string GetCustodianName() const; |
149 | 157 |
150 // Returns the email address of the second custodian, or the empty string | 158 // Returns the email address of the second custodian, or the empty string |
151 // if there is no second custodian. | 159 // if there is no second custodian. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 | 215 |
208 private: | 216 private: |
209 friend class SupervisedUserServiceExtensionTestBase; | 217 friend class SupervisedUserServiceExtensionTestBase; |
210 friend class SupervisedUserServiceFactory; | 218 friend class SupervisedUserServiceFactory; |
211 FRIEND_TEST_ALL_PREFIXES(SingleClientSupervisedUserSettingsSyncTest, Sanity); | 219 FRIEND_TEST_ALL_PREFIXES(SingleClientSupervisedUserSettingsSyncTest, Sanity); |
212 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); | 220 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); |
213 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, | 221 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, |
214 ChangesIncludedSessionOnChangedSettings); | 222 ChangesIncludedSessionOnChangedSettings); |
215 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, | 223 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, |
216 ChangesSyncSessionStateOnChangedSettings); | 224 ChangesSyncSessionStateOnChangedSettings); |
217 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceExtensionTest, | 225 FRIEND_TEST_ALL_PREFIXES( |
218 ExtensionManagementPolicyProvider); | 226 SupervisedUserServiceExtensionTest, |
227 ExtensionManagementPolicyProviderWithDisabledSUInitiatedInstalls); | |
228 FRIEND_TEST_ALL_PREFIXES( | |
229 SupervisedUserServiceExtensionTest, | |
230 ExtensionManagementPolicyProviderWithEnabledSUInitiatedInstalls); | |
219 | 231 |
220 using CreatePermissionRequestCallback = | 232 using CreatePermissionRequestCallback = |
221 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>; | 233 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>; |
222 | 234 |
223 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which | 235 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which |
224 // lives on the IO thread. This class mediates access to them and makes sure | 236 // lives on the IO thread. This class mediates access to them and makes sure |
225 // they are kept in sync. | 237 // they are kept in sync. |
226 class URLFilterContext { | 238 class URLFilterContext { |
227 public: | 239 public: |
228 URLFilterContext(); | 240 URLFilterContext(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 | 302 |
291 #if defined(ENABLE_EXTENSIONS) | 303 #if defined(ENABLE_EXTENSIONS) |
292 // extensions::ManagementPolicy::Provider implementation: | 304 // extensions::ManagementPolicy::Provider implementation: |
293 std::string GetDebugPolicyProviderName() const override; | 305 std::string GetDebugPolicyProviderName() const override; |
294 bool UserMayLoad(const extensions::Extension* extension, | 306 bool UserMayLoad(const extensions::Extension* extension, |
295 base::string16* error) const override; | 307 base::string16* error) const override; |
296 bool UserMayModifySettings(const extensions::Extension* extension, | 308 bool UserMayModifySettings(const extensions::Extension* extension, |
297 base::string16* error) const override; | 309 base::string16* error) const override; |
298 bool MustRemainInstalled(const extensions::Extension* extension, | 310 bool MustRemainInstalled(const extensions::Extension* extension, |
299 base::string16* error) const override; | 311 base::string16* error) const override; |
312 bool MustRemainDisabled(const extensions::Extension* extension, | |
313 extensions::Extension::DisableReason* reason, | |
314 base::string16* error) const override; | |
315 | |
316 // An extension can be in one of the following states: | |
317 // | |
318 // FORCED: if it is installed by the custodian. | |
319 // REQUIRE_APPROVAL: if it is installed by the supervised user and | |
320 // hasn't been approved by the custodian yet. | |
321 // ALLOWED: Components, Themes, Default extensions ..etc | |
322 // are generally allowed. Extensions that have been approved by the | |
323 // custodian are also allowed. | |
324 // BLOCKED: Extension is blocked if it is not ALLOWED or FORCED | |
325 // and supervised users initiated installs are disabled. | |
326 enum class ExtensionState { FORCED, BLOCKED, ALLOWED, REQUIRE_APPROVAL }; | |
327 | |
328 ExtensionState GetExtensionState( | |
329 const extensions::Extension& extension) const; | |
300 | 330 |
301 // Extensions helper to SetActive(). | 331 // Extensions helper to SetActive(). |
302 void SetExtensionsActive(); | 332 void SetExtensionsActive(); |
303 #endif | 333 #endif |
304 | 334 |
305 SupervisedUserSettingsService* GetSettingsService(); | 335 SupervisedUserSettingsService* GetSettingsService(); |
306 | 336 |
307 size_t FindEnabledPermissionRequestCreator(size_t start); | 337 size_t FindEnabledPermissionRequestCreator(size_t start); |
308 void AddPermissionRequestInternal( | 338 void AddPermissionRequestInternal( |
309 const CreatePermissionRequestCallback& create_request, | 339 const CreatePermissionRequestCallback& create_request, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 void UpdateBlacklist(); | 375 void UpdateBlacklist(); |
346 | 376 |
347 // Updates the manual overrides for hosts in the URL filters when the | 377 // Updates the manual overrides for hosts in the URL filters when the |
348 // corresponding preference is changed. | 378 // corresponding preference is changed. |
349 void UpdateManualHosts(); | 379 void UpdateManualHosts(); |
350 | 380 |
351 // Updates the manual overrides for URLs in the URL filters when the | 381 // Updates the manual overrides for URLs in the URL filters when the |
352 // corresponding preference is changed. | 382 // corresponding preference is changed. |
353 void UpdateManualURLs(); | 383 void UpdateManualURLs(); |
354 | 384 |
385 // Updates the map of approved extensions when the corresponding preference | |
386 // is changed | |
Marc Treib
2016/05/23 15:32:42
nit: period after comment
mamir
2016/05/23 19:35:14
Done.
| |
387 void UpdateApprovedExtensions(); | |
388 | |
355 // Returns the human readable name of the supervised user. | 389 // Returns the human readable name of the supervised user. |
356 std::string GetSupervisedUserName() const; | 390 std::string GetSupervisedUserName() const; |
357 | 391 |
358 // Subscribes to the SupervisedUserPrefStore, refreshes | 392 // Subscribes to the SupervisedUserPrefStore, refreshes |
359 // |includes_sync_sessions_type_| and triggers reconfiguring the | 393 // |includes_sync_sessions_type_| and triggers reconfiguring the |
360 // ProfileSyncService. | 394 // ProfileSyncService. |
361 void OnHistoryRecordingStateChanged(); | 395 void OnHistoryRecordingStateChanged(); |
362 | 396 |
363 // Returns true if the syncer::SESSIONS type should be included in Sync. | 397 // Returns true if the syncer::SESSIONS type should be included in Sync. |
364 bool IncludesSyncSessionsType() const; | 398 bool IncludesSyncSessionsType() const; |
(...skipping 19 matching lines...) Expand all Loading... | |
384 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; | 418 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; |
385 | 419 |
386 // True only when |Init()| method has been called. | 420 // True only when |Init()| method has been called. |
387 bool did_init_; | 421 bool did_init_; |
388 | 422 |
389 // True only when |Shutdown()| method has been called. | 423 // True only when |Shutdown()| method has been called. |
390 bool did_shutdown_; | 424 bool did_shutdown_; |
391 | 425 |
392 URLFilterContext url_filter_context_; | 426 URLFilterContext url_filter_context_; |
393 | 427 |
428 std::unique_ptr<std::map<std::string, std::string>> approved_extensions_map_; | |
Marc Treib
2016/05/23 15:32:42
Why is this a pointer?
Also, please document what'
mamir
2016/05/23 19:35:14
Done.
| |
429 | |
394 enum class BlacklistLoadState { | 430 enum class BlacklistLoadState { |
395 NOT_LOADED, | 431 NOT_LOADED, |
396 LOAD_STARTED, | 432 LOAD_STARTED, |
397 LOADED | 433 LOADED |
398 } blacklist_state_; | 434 } blacklist_state_; |
399 | 435 |
400 SupervisedUserBlacklist blacklist_; | 436 SupervisedUserBlacklist blacklist_; |
401 std::unique_ptr<FileDownloader> blacklist_downloader_; | 437 std::unique_ptr<FileDownloader> blacklist_downloader_; |
402 | 438 |
403 std::unique_ptr<SupervisedUserWhitelistService> whitelist_service_; | 439 std::unique_ptr<SupervisedUserWhitelistService> whitelist_service_; |
404 | 440 |
405 std::vector<scoped_refptr<SupervisedUserSiteList>> whitelists_; | 441 std::vector<scoped_refptr<SupervisedUserSiteList>> whitelists_; |
406 | 442 |
407 // Used to create permission requests. | 443 // Used to create permission requests. |
408 ScopedVector<PermissionRequestCreator> permissions_creators_; | 444 ScopedVector<PermissionRequestCreator> permissions_creators_; |
409 | 445 |
410 // Used to report inappropriate URLs to SafeSarch API. | 446 // Used to report inappropriate URLs to SafeSarch API. |
411 std::unique_ptr<SafeSearchURLReporter> url_reporter_; | 447 std::unique_ptr<SafeSearchURLReporter> url_reporter_; |
412 | 448 |
413 base::ObserverList<SupervisedUserServiceObserver> observer_list_; | 449 base::ObserverList<SupervisedUserServiceObserver> observer_list_; |
414 | 450 |
415 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; | 451 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; |
416 }; | 452 }; |
417 | 453 |
418 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 454 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
OLD | NEW |