| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_BROWSER_MANAGEMENT_POLICY_H_ | 5 #ifndef EXTENSIONS_BROWSER_MANAGEMENT_POLICY_H_ |
| 6 #define EXTENSIONS_BROWSER_MANAGEMENT_POLICY_H_ | 6 #define EXTENSIONS_BROWSER_MANAGEMENT_POLICY_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 Provider() {} | 45 Provider() {} |
| 46 virtual ~Provider() {} | 46 virtual ~Provider() {} |
| 47 | 47 |
| 48 // A human-readable name for this provider, for use in debug messages. | 48 // A human-readable name for this provider, for use in debug messages. |
| 49 // Implementers should return an empty string in non-debug builds, to save | 49 // Implementers should return an empty string in non-debug builds, to save |
| 50 // executable size. | 50 // executable size. |
| 51 virtual std::string GetDebugPolicyProviderName() const = 0; | 51 virtual std::string GetDebugPolicyProviderName() const = 0; |
| 52 | 52 |
| 53 // Providers should return false if a user may not install the |extension|, | 53 // Providers should return false if a user may not install the |extension|, |
| 54 // or load or run it if it has already been installed. | 54 // or load or run it if it has already been installed. |
| 55 // TODO(treib,pam): The method name is misleading, since this applies to all |
| 56 // extension installations, not just user-initiated ones. Fix either the |
| 57 // name or the semantics. |
| 55 virtual bool UserMayLoad(const Extension* extension, | 58 virtual bool UserMayLoad(const Extension* extension, |
| 56 base::string16* error) const; | 59 base::string16* error) const; |
| 57 | 60 |
| 58 // Providers should return false if a user may not enable, disable, or | 61 // Providers should return false if a user may not enable, disable, or |
| 59 // uninstall the |extension|, or change its usage options (incognito | 62 // uninstall the |extension|, or change its usage options (incognito |
| 60 // permission, file access, etc.). | 63 // permission, file access, etc.). |
| 64 // TODO(treib,pam): The method name is misleading, since this applies to all |
| 65 // setting modifications, not just user-initiated ones. Fix either the |
| 66 // name or the semantics. |
| 61 virtual bool UserMayModifySettings(const Extension* extension, | 67 virtual bool UserMayModifySettings(const Extension* extension, |
| 62 base::string16* error) const; | 68 base::string16* error) const; |
| 63 | 69 |
| 64 // Providers should return true if the |extension| must always remain | 70 // Providers should return true if the |extension| must always remain |
| 65 // enabled. This is distinct from UserMayModifySettings() in that the latter | 71 // enabled. This is distinct from UserMayModifySettings() in that the latter |
| 66 // also prohibits enabling the extension if it is currently disabled. | 72 // also prohibits enabling the extension if it is currently disabled. |
| 67 // Providers implementing this method should also implement the others | 73 // Providers implementing this method should also implement the others |
| 68 // above, if they wish to completely lock in an extension. | 74 // above, if they wish to completely lock in an extension. |
| 69 virtual bool MustRemainEnabled(const Extension* extension, | 75 virtual bool MustRemainEnabled(const Extension* extension, |
| 70 base::string16* error) const; | 76 base::string16* error) const; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 91 // from the list of providers queried. Ownership of the provider remains with | 97 // from the list of providers queried. Ownership of the provider remains with |
| 92 // the caller. Providers do not need to be unregistered on shutdown. | 98 // the caller. Providers do not need to be unregistered on shutdown. |
| 93 void RegisterProvider(Provider* provider); | 99 void RegisterProvider(Provider* provider); |
| 94 void UnregisterProvider(Provider* provider); | 100 void UnregisterProvider(Provider* provider); |
| 95 | 101 |
| 96 // Like RegisterProvider(), but registers multiple providers instead. | 102 // Like RegisterProvider(), but registers multiple providers instead. |
| 97 void RegisterProviders(std::vector<Provider*> providers); | 103 void RegisterProviders(std::vector<Provider*> providers); |
| 98 | 104 |
| 99 // Returns true if the user is permitted to install, load, and run the given | 105 // Returns true if the user is permitted to install, load, and run the given |
| 100 // extension. If not, |error| may be set to an appropriate message. | 106 // extension. If not, |error| may be set to an appropriate message. |
| 107 // TODO(treib,pam): Misleading name; see comment in Provider above. |
| 101 bool UserMayLoad(const Extension* extension, base::string16* error) const; | 108 bool UserMayLoad(const Extension* extension, base::string16* error) const; |
| 102 | 109 |
| 103 // Returns true if the user is permitted to enable, disable, or uninstall the | 110 // Returns true if the user is permitted to enable, disable, or uninstall the |
| 104 // given extension, or change the extension's usage options (incognito mode, | 111 // given extension, or change the extension's usage options (incognito mode, |
| 105 // file access, etc.). If not, |error| may be set to an appropriate message. | 112 // file access, etc.). If not, |error| may be set to an appropriate message. |
| 113 // TODO(treib,pam): Misleading name; see comment in Provider above. |
| 106 bool UserMayModifySettings(const Extension* extension, | 114 bool UserMayModifySettings(const Extension* extension, |
| 107 base::string16* error) const; | 115 base::string16* error) const; |
| 108 | 116 |
| 109 // Returns true if the extension must remain enabled at all times (e.g. a | 117 // Returns true if the extension must remain enabled at all times (e.g. a |
| 110 // compoment extension). In that case, |error| may be set to an appropriate | 118 // component extension). In that case, |error| may be set to an appropriate |
| 111 // message. | 119 // message. |
| 112 bool MustRemainEnabled(const Extension* extension, | 120 bool MustRemainEnabled(const Extension* extension, |
| 113 base::string16* error) const; | 121 base::string16* error) const; |
| 114 | 122 |
| 115 // Returns true immediately if any registered provider's MustRemainDisabled | 123 // Returns true immediately if any registered provider's MustRemainDisabled |
| 116 // function returns true. | 124 // function returns true. |
| 117 bool MustRemainDisabled(const Extension* extension, | 125 bool MustRemainDisabled(const Extension* extension, |
| 118 Extension::DisableReason* reason, | 126 Extension::DisableReason* reason, |
| 119 base::string16* error) const; | 127 base::string16* error) const; |
| 120 | 128 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 147 base::string16* error) const; | 155 base::string16* error) const; |
| 148 | 156 |
| 149 ProviderList providers_; | 157 ProviderList providers_; |
| 150 | 158 |
| 151 DISALLOW_COPY_AND_ASSIGN(ManagementPolicy); | 159 DISALLOW_COPY_AND_ASSIGN(ManagementPolicy); |
| 152 }; | 160 }; |
| 153 | 161 |
| 154 } // namespace extensions | 162 } // namespace extensions |
| 155 | 163 |
| 156 #endif // EXTENSIONS_BROWSER_MANAGEMENT_POLICY_H_ | 164 #endif // EXTENSIONS_BROWSER_MANAGEMENT_POLICY_H_ |
| OLD | NEW |