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

Unified 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: Fixing updates of SU initiated installs 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/supervised_user/supervised_user_service.h
diff --git a/chrome/browser/supervised_user/supervised_user_service.h b/chrome/browser/supervised_user/supervised_user_service.h
index 8e93e7576efa31e5e2a529401eb1d559d8a2536a..a5c00eea65d8773c4693958647a19720fdb48161 100644
--- a/chrome/browser/supervised_user/supervised_user_service.h
+++ b/chrome/browser/supervised_user/supervised_user_service.h
@@ -30,6 +30,7 @@
#include "components/prefs/pref_change_registrar.h"
#include "components/sync_driver/sync_service_observer.h"
#include "components/sync_driver/sync_type_preference_provider.h"
+#include "extensions/browser/extension_registry_observer.h"
#include "net/url_request/url_request_context_getter.h"
#if defined(ENABLE_EXTENSIONS)
@@ -76,7 +77,8 @@ class SupervisedUserService : public KeyedService,
public sync_driver::SyncServiceObserver,
public chrome::BrowserListObserver,
#endif
- public SupervisedUserURLFilter::Observer {
+ public SupervisedUserURLFilter::Observer,
+ public extensions::ExtensionRegistryObserver {
Marc Treib 2016/06/03 13:24:14 This should go into the ENABLE_EXTENSIONS above
mamir 2016/06/06 15:01:37 Done.
public:
using NavigationBlockedCallback = base::Callback<void(content::WebContents*)>;
using AuthErrorCallback = base::Callback<void(const GoogleServiceAuthError&)>;
@@ -125,6 +127,15 @@ class SupervisedUserService : public KeyedService,
// inappropriate URL.
void ReportURL(const GURL& url, const SuccessCallback& callback);
+ // Adds an install request for the given WebStore item (App/Extension).
+ void AddExtensionInstallRequest(const std::string& extension_id,
+ const base::Version& version,
+ const SuccessCallback& callback);
+
+ // Same as above, but without a callback, just logging errors on failure.
+ void AddExtensionInstallRequest(const std::string& extension_id,
+ const base::Version& version);
+
// Adds an update request for the given WebStore item (App/Extension).
void AddExtensionUpdateRequest(const std::string& extension_id,
const base::Version& version,
@@ -134,11 +145,15 @@ class SupervisedUserService : public KeyedService,
void AddExtensionUpdateRequest(const std::string& extension_id,
const base::Version& version);
- // Get the string used to identify an extension update request. Public for
- // testing.
- static std::string GetExtensionUpdateRequestId(
- const std::string& extension_id,
- const base::Version& version);
+ // Get the string used to identify an extension install or update request.
+ // Public for testing.
+ static std::string GetExtensionRequestId(const std::string& extension_id,
+ const base::Version& version);
+
+ // Updates the approved version of the extensions in the
+ // approved_extensions_map_.
+ void UpdateApprovedVersion(const std::string& extension_id,
Marc Treib 2016/06/03 13:24:14 UpdateApprovedExtensionVersion?
mamir 2016/06/06 15:01:37 Done.
+ const base::Version& version);
// Returns the email address of the custodian.
std::string GetCustodianEmailAddress() const;
@@ -214,8 +229,12 @@ class SupervisedUserService : public KeyedService,
friend class SupervisedUserServiceFactory;
FRIEND_TEST_ALL_PREFIXES(SingleClientSupervisedUserSettingsSyncTest, Sanity);
FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration);
- FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceExtensionTest,
- ExtensionManagementPolicyProvider);
+ FRIEND_TEST_ALL_PREFIXES(
+ SupervisedUserServiceExtensionTest,
+ ExtensionManagementPolicyProviderWithoutSUInitiatedInstalls);
+ FRIEND_TEST_ALL_PREFIXES(
+ SupervisedUserServiceExtensionTest,
+ ExtensionManagementPolicyProviderWithSUInitiatedInstalls);
using CreatePermissionRequestCallback =
base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>;
@@ -297,6 +316,24 @@ class SupervisedUserService : public KeyedService,
base::string16* error) const override;
bool MustRemainInstalled(const extensions::Extension* extension,
base::string16* error) const override;
+ bool MustRemainDisabled(const extensions::Extension* extension,
+ extensions::Extension::DisableReason* reason,
+ base::string16* error) const override;
+
+ // An extension can be in one of the following states:
+ //
+ // FORCED: if it is installed by the custodian.
+ // REQUIRE_APPROVAL: if it is installed by the supervised user and
+ // hasn't been approved by the custodian yet.
+ // ALLOWED: Components, Themes, Default extensions ..etc
+ // are generally allowed. Extensions that have been approved by the
+ // custodian are also allowed.
+ // BLOCKED: if it is not ALLOWED or FORCED
+ // and supervised users initiated installs are disabled.
+ enum class ExtensionState { FORCED, BLOCKED, ALLOWED, REQUIRE_APPROVAL };
+
+ ExtensionState GetExtensionState(
+ const extensions::Extension& extension) const;
// Extensions helper to SetActive().
void SetExtensionsActive();
@@ -352,6 +389,13 @@ class SupervisedUserService : public KeyedService,
// corresponding preference is changed.
void UpdateManualURLs();
+ // Updates the map of approved extensions when the corresponding preference
+ // is changed.
+ void UpdateApprovedExtensions();
+
+ // Checks the disable reasons and enables the extension if possible.
+ void EnableExtensionIfPossible(const std::string& extension_id);
+
// Returns the human readable name of the supervised user.
std::string GetSupervisedUserName() const;
@@ -360,6 +404,11 @@ class SupervisedUserService : public KeyedService,
// ProfileSyncService.
void OnForceSessionSyncChanged();
+ // extensions::ExtensionRegistryObserver overrides:
+ void OnExtensionInstalled(content::BrowserContext* browser_context,
Marc Treib 2016/06/03 13:24:14 This should go into the ENABLE_EXTENSIONS above; E
mamir 2016/06/06 15:01:37 Done.
+ const extensions::Extension* extension,
+ bool is_update) override;
+
// The option a custodian sets to either record or prevent recording the
// supervised user's history. Set by |FetchNewSessionSyncState()| and
// defaults to true.
@@ -388,6 +437,10 @@ class SupervisedUserService : public KeyedService,
URLFilterContext url_filter_context_;
+ // Stores a map from extension_id -> approved version by the custodian.
+ // It is only relevant for SU-initiated installs.
+ std::map<std::string, base::Version> approved_extensions_map_;
+
enum class BlacklistLoadState {
NOT_LOADED,
LOAD_STARTED,

Powered by Google App Engine
This is Rietveld 408576698