Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_MANAGEMENT_POLICY_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_MANAGEMENT_POLICY_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <set> | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "chrome/common/extensions/extension.h" | |
| 14 | |
| 15 namespace extensions { | |
| 16 // This class registers providers that want to prohibit certain actions from | |
|
Aaron Boodman
2012/05/22 15:56:11
Add a blank line here.
| |
| 17 // being applied to extensions. It must be called, via the ExtensionService, | |
| 18 // before allowing a user or a user-level mechanism to perform the respective | |
| 19 // action. (That is, installing or otherwise modifying an extension in order | |
| 20 // to conform to enterprise administrator policy must be exempted from these | |
| 21 // checks.) | |
| 22 // | |
| 23 // This "policy" and its providers should not be confused with administrator | |
| 24 // policy, although admin policy is one of the sources ("Providers") of | |
| 25 // restrictions registered with and exposed by the ManagementPolicy. | |
| 26 class ManagementPolicy { | |
|
Pam (message me for reviews)
2012/05/22 12:51:07
On 2012/05/17 22:41:06, Aaron Boodman wrote:
> ext
| |
| 27 public: | |
| 28 // Each mechanism that wishes to limit users' ability to control extensions, | |
| 29 // whether one individual extension or the whole system, should implement | |
| 30 // the methods of this Provider interface that it needs. In each case, if the | |
| 31 // provider does not need to control a certain action, that method does not | |
| 32 // need to be implemented. | |
| 33 // | |
| 34 // It is not guaranteed that a particular Provider's methods will be called | |
| 35 // each time a user tries to perform one of the controlled actions (the list | |
| 36 // of providers is short-circuited as soon as a decision is possible), so | |
| 37 // implementations of these methods must have no side effects. | |
| 38 // | |
| 39 // For all of the Provider methods below, if |error| is not NULL and the | |
| 40 // method imposes a restriction on the desired action, |error| may be set | |
| 41 // to an applicable error message, but this is not required. | |
| 42 class Provider { | |
|
Pam (message me for reviews)
2012/05/22 12:51:07
There's precedent in the list of delegates in reso
| |
| 43 public: | |
| 44 Provider() {} | |
| 45 virtual ~Provider() {} | |
| 46 | |
| 47 // A human-readable name for this provider, for use in debug messages. | |
| 48 virtual std::string PolicyProviderName() const = 0; | |
| 49 | |
| 50 // Providers should return false if a user may not intall the |extension| | |
| 51 // from the given |location|. Note that the Extension may not be fully | |
| 52 // configured when this is called (e.g., extension->location() may not be | |
|
Aaron Boodman
2012/05/22 15:56:11
Is location() the only edge case like this? This b
Pam (message me for reviews)
2012/05/23 15:00:58
The apparent problem is the call in CrxInstaller::
Aaron Boodman
2012/05/24 08:11:23
It used to be that extensions were unpacked with n
| |
| 53 // correctly set yet). | |
| 54 virtual bool UserMayLoad(const Extension* extension, | |
| 55 Extension::Location location, | |
| 56 string16* error) const; | |
| 57 | |
| 58 // Providers should return false if a user may not enable, disable, or | |
| 59 // uninstall the |extension|, or change its usage options (incognito | |
| 60 // permission, file access, etc.). | |
| 61 virtual bool UserMayModifyStatus(const Extension* extension, | |
|
Pam (message me for reviews)
2012/05/22 12:51:07
Sure, except it's not just settings anymore.
Aaron Boodman
2012/05/22 15:56:11
I meant settings to encompass all of them, includi
Pam (message me for reviews)
2012/05/23 15:00:58
Coming at it as I do from the preferences side of
Aaron Boodman
2012/05/24 08:11:23
I don't think we have a convention, but I prefer s
| |
| 62 string16* error) const; | |
| 63 | |
| 64 // Providers should return true if the |extension| must always remain | |
| 65 // enabled. This is distinct from UserMayModifyStatus() in that the latter | |
| 66 // also prohibits enabling the extension if it is currently disabled. | |
| 67 // Providers implementing this method should also implement the others | |
| 68 // above, if they wish to completely lock in an extension. | |
| 69 virtual bool MustRemainEnabled(const Extension* extension, | |
|
Pam (message me for reviews)
2012/05/22 12:51:07
That would be enough for policy force- and blackli
Aaron Boodman
2012/05/22 15:56:11
Couldn't that be implemented by just looking at th
Pam (message me for reviews)
2012/05/23 15:00:58
Not enabled status, but installed status: we still
| |
| 70 string16* error) const; | |
| 71 | |
| 72 private: | |
| 73 DISALLOW_COPY_AND_ASSIGN(Provider); | |
| 74 }; | |
| 75 | |
| 76 ManagementPolicy(); | |
| 77 ~ManagementPolicy(); | |
| 78 | |
| 79 // Registers or unregisters a provider, causing it to be added to or removed | |
| 80 // from the list of providers queried. Ownership of the provider remains with | |
| 81 // the caller. Providers do not need to be unregistered on shutdown. | |
| 82 void RegisterProvider(Provider* provider); | |
| 83 void UnregisterProvider(Provider* provider); | |
| 84 | |
| 85 // Returns true if the user is permitted to install the given extension. If | |
| 86 // not, |error| may be set to an appropriate message. | |
| 87 bool UserMayLoad(const Extension* extension, Extension::Location location, | |
| 88 string16* error) const; | |
| 89 | |
| 90 // Returns true if the user is permitted to enable, disable, or uninstall the | |
| 91 // given extension, or change the extension's usage options (incognito mode, | |
| 92 // file access, etc.). If not, |error| may be set to an appropriate message. | |
| 93 bool UserMayModifyStatus(const Extension* extension, | |
| 94 string16* error) const; | |
| 95 | |
| 96 // Returns true if the extension must remain enabled at all times (e.g. a | |
| 97 // compoment extension). In that case, |error| may be set to an appropriate | |
| 98 // message. | |
| 99 bool MustRemainEnabled(const Extension* extension, | |
| 100 string16* error) const; | |
| 101 | |
| 102 // For use in testing. | |
| 103 void UnregisterAllProviders(); | |
| 104 int GetNumProviders() const; | |
|
Pam (message me for reviews)
2012/05/22 12:51:07
On 2012/05/17 22:41:06, Aaron Boodman wrote:
> Use
| |
| 105 | |
| 106 private: | |
| 107 typedef std::set<Provider*> ProviderList; | |
| 108 ProviderList providers_; | |
| 109 | |
| 110 DISALLOW_COPY_AND_ASSIGN(ManagementPolicy); | |
| 111 }; | |
| 112 } // namespace | |
| 113 | |
| 114 #endif // CHROME_BROWSER_EXTENSIONS_MANAGEMENT_POLICY_H_ | |
| OLD | NEW |