Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chrome/browser/supervised_user/supervised_user_service.h

Issue 2004043002: Supervised Users Initiated Installs v2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kid_initiated_install
Patch Set: minor Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
207 #endif // !defined(OS_ANDROID) 215 #endif // !defined(OS_ANDROID)
208 216
209 // SupervisedUserURLFilter::Observer implementation: 217 // SupervisedUserURLFilter::Observer implementation:
210 void OnSiteListUpdated() override; 218 void OnSiteListUpdated() override;
211 219
212 private: 220 private:
213 friend class SupervisedUserServiceExtensionTestBase; 221 friend class SupervisedUserServiceExtensionTestBase;
214 friend class SupervisedUserServiceFactory; 222 friend class SupervisedUserServiceFactory;
215 FRIEND_TEST_ALL_PREFIXES(SingleClientSupervisedUserSettingsSyncTest, Sanity); 223 FRIEND_TEST_ALL_PREFIXES(SingleClientSupervisedUserSettingsSyncTest, Sanity);
216 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); 224 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration);
217 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceExtensionTest, 225 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest,
218 ExtensionManagementPolicyProvider); 226 ChangesIncludedSessionOnChangedSettings);
227 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest,
228 ChangesSyncSessionStateOnChangedSettings);
Marc Treib 2016/05/24 09:54:58 Any reason for adding these unrelated tests here?
mamir 2016/06/03 09:45:55 Nop :-) I think they came here during a rebase.
229 FRIEND_TEST_ALL_PREFIXES(
230 SupervisedUserServiceExtensionTest,
231 ExtensionManagementPolicyProviderWithDisabledSUInitiatedInstalls);
232 FRIEND_TEST_ALL_PREFIXES(
233 SupervisedUserServiceExtensionTest,
234 ExtensionManagementPolicyProviderWithEnabledSUInitiatedInstalls);
235
219 236
220 using CreatePermissionRequestCallback = 237 using CreatePermissionRequestCallback =
221 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>; 238 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>;
222 239
223 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which 240 // 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 241 // lives on the IO thread. This class mediates access to them and makes sure
225 // they are kept in sync. 242 // they are kept in sync.
226 class URLFilterContext { 243 class URLFilterContext {
227 public: 244 public:
228 URLFilterContext(); 245 URLFilterContext();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 307
291 #if defined(ENABLE_EXTENSIONS) 308 #if defined(ENABLE_EXTENSIONS)
292 // extensions::ManagementPolicy::Provider implementation: 309 // extensions::ManagementPolicy::Provider implementation:
293 std::string GetDebugPolicyProviderName() const override; 310 std::string GetDebugPolicyProviderName() const override;
294 bool UserMayLoad(const extensions::Extension* extension, 311 bool UserMayLoad(const extensions::Extension* extension,
295 base::string16* error) const override; 312 base::string16* error) const override;
296 bool UserMayModifySettings(const extensions::Extension* extension, 313 bool UserMayModifySettings(const extensions::Extension* extension,
297 base::string16* error) const override; 314 base::string16* error) const override;
298 bool MustRemainInstalled(const extensions::Extension* extension, 315 bool MustRemainInstalled(const extensions::Extension* extension,
299 base::string16* error) const override; 316 base::string16* error) const override;
317 bool MustRemainDisabled(const extensions::Extension* extension,
318 extensions::Extension::DisableReason* reason,
319 base::string16* error) const override;
320
321 // An extension can be in one of the following states:
322 //
323 // FORCED: if it is installed by the custodian.
324 // REQUIRE_APPROVAL: if it is installed by the supervised user and
325 // hasn't been approved by the custodian yet.
326 // ALLOWED: Components, Themes, Default extensions ..etc
327 // are generally allowed. Extensions that have been approved by the
328 // custodian are also allowed.
329 // BLOCKED: Extension is blocked if it is not ALLOWED or FORCED
Marc Treib 2016/05/24 09:54:58 remove "Extension is blocked" to be consistent wit
mamir 2016/06/03 09:45:55 Done.
330 // and supervised users initiated installs are disabled.
331 enum class ExtensionState { FORCED, BLOCKED, ALLOWED, REQUIRE_APPROVAL };
332
333 ExtensionState GetExtensionState(
334 const extensions::Extension& extension) const;
300 335
301 // Extensions helper to SetActive(). 336 // Extensions helper to SetActive().
302 void SetExtensionsActive(); 337 void SetExtensionsActive();
303 #endif 338 #endif
304 339
305 SupervisedUserSettingsService* GetSettingsService(); 340 SupervisedUserSettingsService* GetSettingsService();
306 341
307 size_t FindEnabledPermissionRequestCreator(size_t start); 342 size_t FindEnabledPermissionRequestCreator(size_t start);
308 void AddPermissionRequestInternal( 343 void AddPermissionRequestInternal(
309 const CreatePermissionRequestCallback& create_request, 344 const CreatePermissionRequestCallback& create_request,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 void UpdateBlacklist(); 380 void UpdateBlacklist();
346 381
347 // Updates the manual overrides for hosts in the URL filters when the 382 // Updates the manual overrides for hosts in the URL filters when the
348 // corresponding preference is changed. 383 // corresponding preference is changed.
349 void UpdateManualHosts(); 384 void UpdateManualHosts();
350 385
351 // Updates the manual overrides for URLs in the URL filters when the 386 // Updates the manual overrides for URLs in the URL filters when the
352 // corresponding preference is changed. 387 // corresponding preference is changed.
353 void UpdateManualURLs(); 388 void UpdateManualURLs();
354 389
390 // Updates the map of approved extensions when the corresponding preference
391 // is changed.
392 void UpdateApprovedExtensions();
393
355 // Returns the human readable name of the supervised user. 394 // Returns the human readable name of the supervised user.
356 std::string GetSupervisedUserName() const; 395 std::string GetSupervisedUserName() const;
357 396
358 // Subscribes to the SupervisedUserPrefStore, refreshes 397 // Subscribes to the SupervisedUserPrefStore, refreshes
359 // |includes_sync_sessions_type_| and triggers reconfiguring the 398 // |includes_sync_sessions_type_| and triggers reconfiguring the
360 // ProfileSyncService. 399 // ProfileSyncService.
361 void OnForceSessionSyncChanged(); 400 void OnForceSessionSyncChanged();
362 401
363 // The option a custodian sets to either record or prevent recording the 402 // The option a custodian sets to either record or prevent recording the
364 // supervised user's history. Set by |FetchNewSessionSyncState()| and 403 // supervised user's history. Set by |FetchNewSessionSyncState()| and
(...skipping 16 matching lines...) Expand all
381 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; 420 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_;
382 421
383 // True only when |Init()| method has been called. 422 // True only when |Init()| method has been called.
384 bool did_init_; 423 bool did_init_;
385 424
386 // True only when |Shutdown()| method has been called. 425 // True only when |Shutdown()| method has been called.
387 bool did_shutdown_; 426 bool did_shutdown_;
388 427
389 URLFilterContext url_filter_context_; 428 URLFilterContext url_filter_context_;
390 429
430 // Stores a map from extension_id -> latest approved version by the custodian.
Marc Treib 2016/05/24 09:54:58 It's not really *latest* approved version, but rat
mamir 2016/06/06 15:01:36 Done.
431 std::map<std::string, base::Version> approved_extensions_map_;
432
391 enum class BlacklistLoadState { 433 enum class BlacklistLoadState {
392 NOT_LOADED, 434 NOT_LOADED,
393 LOAD_STARTED, 435 LOAD_STARTED,
394 LOADED 436 LOADED
395 } blacklist_state_; 437 } blacklist_state_;
396 438
397 SupervisedUserBlacklist blacklist_; 439 SupervisedUserBlacklist blacklist_;
398 std::unique_ptr<FileDownloader> blacklist_downloader_; 440 std::unique_ptr<FileDownloader> blacklist_downloader_;
399 441
400 std::unique_ptr<SupervisedUserWhitelistService> whitelist_service_; 442 std::unique_ptr<SupervisedUserWhitelistService> whitelist_service_;
401 443
402 std::vector<scoped_refptr<SupervisedUserSiteList>> whitelists_; 444 std::vector<scoped_refptr<SupervisedUserSiteList>> whitelists_;
403 445
404 // Used to create permission requests. 446 // Used to create permission requests.
405 ScopedVector<PermissionRequestCreator> permissions_creators_; 447 ScopedVector<PermissionRequestCreator> permissions_creators_;
406 448
407 // Used to report inappropriate URLs to SafeSarch API. 449 // Used to report inappropriate URLs to SafeSarch API.
408 std::unique_ptr<SafeSearchURLReporter> url_reporter_; 450 std::unique_ptr<SafeSearchURLReporter> url_reporter_;
409 451
410 base::ObserverList<SupervisedUserServiceObserver> observer_list_; 452 base::ObserverList<SupervisedUserServiceObserver> observer_list_;
411 453
412 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; 454 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_;
413 }; 455 };
414 456
415 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ 457 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698