| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_EXTENSIONS_MANAGEMENT_POLICY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_MANAGEMENT_POLICY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_MANAGEMENT_POLICY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_MANAGEMENT_POLICY_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 string16* error) const; | 61 string16* error) const; |
| 62 | 62 |
| 63 // Providers should return true if the |extension| must always remain | 63 // Providers should return true if the |extension| must always remain |
| 64 // enabled. This is distinct from UserMayModifySettings() in that the latter | 64 // enabled. This is distinct from UserMayModifySettings() in that the latter |
| 65 // also prohibits enabling the extension if it is currently disabled. | 65 // also prohibits enabling the extension if it is currently disabled. |
| 66 // Providers implementing this method should also implement the others | 66 // Providers implementing this method should also implement the others |
| 67 // above, if they wish to completely lock in an extension. | 67 // above, if they wish to completely lock in an extension. |
| 68 virtual bool MustRemainEnabled(const Extension* extension, | 68 virtual bool MustRemainEnabled(const Extension* extension, |
| 69 string16* error) const; | 69 string16* error) const; |
| 70 | 70 |
| 71 // Similar to MustRemainEnabled, but for whether an extension must remain |
| 72 // disabled, and returns an error and/or reason if the caller needs it. |
| 73 virtual bool MustRemainDisabled(const Extension* extension, |
| 74 Extension::DisableReason* reason, |
| 75 string16* error) const; |
| 76 |
| 71 private: | 77 private: |
| 72 DISALLOW_COPY_AND_ASSIGN(Provider); | 78 DISALLOW_COPY_AND_ASSIGN(Provider); |
| 73 }; | 79 }; |
| 74 | 80 |
| 75 ManagementPolicy(); | 81 ManagementPolicy(); |
| 76 ~ManagementPolicy(); | 82 ~ManagementPolicy(); |
| 77 | 83 |
| 78 // Registers or unregisters a provider, causing it to be added to or removed | 84 // Registers or unregisters a provider, causing it to be added to or removed |
| 79 // from the list of providers queried. Ownership of the provider remains with | 85 // from the list of providers queried. Ownership of the provider remains with |
| 80 // the caller. Providers do not need to be unregistered on shutdown. | 86 // the caller. Providers do not need to be unregistered on shutdown. |
| 81 void RegisterProvider(Provider* provider); | 87 void RegisterProvider(Provider* provider); |
| 82 void UnregisterProvider(Provider* provider); | 88 void UnregisterProvider(Provider* provider); |
| 83 | 89 |
| 84 // Returns true if the user is permitted to install, load, and run the given | 90 // Returns true if the user is permitted to install, load, and run the given |
| 85 // extension. If not, |error| may be set to an appropriate message. | 91 // extension. If not, |error| may be set to an appropriate message. |
| 86 bool UserMayLoad(const Extension* extension, string16* error) const; | 92 bool UserMayLoad(const Extension* extension, string16* error) const; |
| 87 | 93 |
| 88 // Returns true if the user is permitted to enable, disable, or uninstall the | 94 // Returns true if the user is permitted to enable, disable, or uninstall the |
| 89 // given extension, or change the extension's usage options (incognito mode, | 95 // given extension, or change the extension's usage options (incognito mode, |
| 90 // file access, etc.). If not, |error| may be set to an appropriate message. | 96 // file access, etc.). If not, |error| may be set to an appropriate message. |
| 91 bool UserMayModifySettings(const Extension* extension, | 97 bool UserMayModifySettings(const Extension* extension, |
| 92 string16* error) const; | 98 string16* error) const; |
| 93 | 99 |
| 94 // Returns true if the extension must remain enabled at all times (e.g. a | 100 // Returns true if the extension must remain enabled at all times (e.g. a |
| 95 // compoment extension). In that case, |error| may be set to an appropriate | 101 // compoment extension). In that case, |error| may be set to an appropriate |
| 96 // message. | 102 // message. |
| 97 bool MustRemainEnabled(const Extension* extension, | 103 bool MustRemainEnabled(const Extension* extension, |
| 98 string16* error) const; | 104 string16* error) const; |
| 99 | 105 |
| 106 // Returns true immediately if any registered provider's MustRemainDisabled |
| 107 // function returns true. |
| 108 bool MustRemainDisabled(const Extension* extension, |
| 109 Extension::DisableReason* reason, |
| 110 string16* error) const; |
| 111 |
| 100 // For use in testing. | 112 // For use in testing. |
| 101 void UnregisterAllProviders(); | 113 void UnregisterAllProviders(); |
| 102 int GetNumProviders() const; | 114 int GetNumProviders() const; |
| 103 | 115 |
| 104 private: | 116 private: |
| 105 // This is a pointer to a function in the Provider interface, used in | 117 // This is a pointer to a function in the Provider interface, used in |
| 106 // ApplyToProviderList. | 118 // ApplyToProviderList. |
| 107 typedef bool (Provider::*ProviderFunction)(const Extension*, string16*) const; | 119 typedef bool (Provider::*ProviderFunction)(const Extension*, string16*) const; |
| 108 | 120 |
| 109 typedef std::set<Provider*> ProviderList; | 121 typedef std::set<Provider*> ProviderList; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 120 string16* error) const; | 132 string16* error) const; |
| 121 | 133 |
| 122 ProviderList providers_; | 134 ProviderList providers_; |
| 123 | 135 |
| 124 DISALLOW_COPY_AND_ASSIGN(ManagementPolicy); | 136 DISALLOW_COPY_AND_ASSIGN(ManagementPolicy); |
| 125 }; | 137 }; |
| 126 | 138 |
| 127 } // namespace extensions | 139 } // namespace extensions |
| 128 | 140 |
| 129 #endif // CHROME_BROWSER_EXTENSIONS_MANAGEMENT_POLICY_H_ | 141 #endif // CHROME_BROWSER_EXTENSIONS_MANAGEMENT_POLICY_H_ |
| OLD | NEW |