diff options
author | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-25 18:28:24 +0000 |
---|---|---|
committer | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-25 18:28:24 +0000 |
commit | a6c7a8255c419ad81945fe10834956d0dc6fad0b (patch) | |
tree | 82c1768c0e6e3c132a27eb736c0c585c1b637a2b /chrome/browser/managed_mode.h | |
parent | 3e324142a9d9a10f3c4b7ceceed97c1b5006f61a (diff) | |
download | chromium_src-a6c7a8255c419ad81945fe10834956d0dc6fad0b.zip chromium_src-a6c7a8255c419ad81945fe10834956d0dc6fad0b.tar.gz chromium_src-a6c7a8255c419ad81945fe10834956d0dc6fad0b.tar.bz2 |
Disable modifying extensions when in managed mode.
Consolidate yellow banners on Extensions and Options pages. Add managed mode as an extensions::ManagementPolicy::Provider. Managed mode prohibits installing, uninstalling, enabling, or disabling extensions, both in the UI and in the back end. Also remove links to the web store, as well as optional controls (options, incognito, reload, etc.).
BUG=117987
TEST=unit tests (for managed mode methods); manual: verify that chrome://extensions UI is disabled in managed mode; manual: launch in managed mode and verify that managed mode can be disabled
Review URL: https://chromiumcodereview.appspot.com/10542023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/managed_mode.h')
-rw-r--r-- | chrome/browser/managed_mode.h | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/chrome/browser/managed_mode.h b/chrome/browser/managed_mode.h index d3779ca..76f0b32 100644 --- a/chrome/browser/managed_mode.h +++ b/chrome/browser/managed_mode.h @@ -6,11 +6,13 @@ #define CHROME_BROWSER_MANAGED_MODE_H_ #include <set> +#include <string> #include <vector> #include "base/callback.h" #include "base/compiler_specific.h" #include "base/memory/singleton.h" +#include "chrome/browser/extensions/management_policy.h" #include "chrome/browser/ui/browser_list.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" @@ -26,11 +28,16 @@ class Profile; // The ManagedMode class provides methods to check whether the browser is in // managed mode, and to attempt to enter or leave managed mode. class ManagedMode : public BrowserList::Observer, + public extensions::ManagementPolicy::Provider, public content::NotificationObserver { public: typedef base::Callback<void(bool)> EnterCallback; static void RegisterPrefs(PrefService* prefs); + + // Initializes the singleton, setting the managed_profile_. Must be called + // after g_browser_process and the LocalState have been created. + static void Init(Profile* profile); static bool IsInManagedMode(); // Calls |callback| with the argument true iff managed mode was entered @@ -38,6 +45,13 @@ class ManagedMode : public BrowserList::Observer, static void EnterManagedMode(Profile* profile, const EnterCallback& callback); static void LeaveManagedMode(); + // ExtensionManagementPolicy::Provider implementation: + virtual std::string GetDebugPolicyProviderName() const OVERRIDE; + virtual bool UserMayLoad(const extensions::Extension* extension, + string16* error) const OVERRIDE; + virtual bool UserMayModifySettings(const extensions::Extension* extension, + string16* error) const OVERRIDE; + // BrowserList::Observer implementation: virtual void OnBrowserAdded(Browser* browser) OVERRIDE; virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; @@ -52,13 +66,25 @@ class ManagedMode : public BrowserList::Observer, virtual ~ManagedMode(); void EnterManagedModeImpl(Profile* profile, const EnterCallback& callback); + // The managed profile. This is NULL iff we are not in managed mode. + Profile* managed_profile_; + private: friend struct DefaultSingletonTraits<ManagedMode>; friend class Singleton<ManagedMode>; FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ManagedModeOnChange); + FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, + ManagedModeProhibitsModification); static ManagedMode* GetInstance(); + virtual void InitImpl(Profile* profile); + + // Internal implementation for ExtensionManagementPolicy::Delegate methods. + // If |error| is not NULL, it will be filled with an error message if the + // requested extension action (install, modify status, etc.) is not permitted. + bool ExtensionManagementPolicyImpl(string16* error) const; + void LeaveManagedModeImpl(); void FinalizeEnter(bool result); @@ -68,16 +94,21 @@ class ManagedMode : public BrowserList::Observer, virtual bool PlatformConfirmEnter(); virtual bool PlatformConfirmLeave(); - virtual bool IsInManagedModeImpl(); - virtual void SetInManagedMode(bool in_managed_mode); + virtual bool IsInManagedModeImpl() const; + + // Enables or disables managed mode and registers or unregisters it with the + // ManagementPolicy. If |newly_managed_profile| is NULL, managed mode will + // be disabled. Otherwise, managed mode will be enabled for that profile + // (typically |managed_profile_|, but other values are possible during + // testing). + virtual void SetInManagedMode(Profile* newly_managed_profile); content::NotificationRegistrar registrar_; - // The managed profile. This is non-NULL only while we're entering - // managed mode. - const Profile* managed_profile_; std::set<Browser*> browsers_to_close_; std::vector<EnterCallback> callbacks_; + + DISALLOW_COPY_AND_ASSIGN(ManagedMode); }; #endif // CHROME_BROWSER_MANAGED_MODE_H_ |