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_TEST_MANAGEMENT_POLICY_H_ | 5 #ifndef EXTENSIONS_BROWSER_TEST_MANAGEMENT_POLICY_H_ |
6 #define EXTENSIONS_BROWSER_TEST_MANAGEMENT_POLICY_H_ | 6 #define EXTENSIONS_BROWSER_TEST_MANAGEMENT_POLICY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "extensions/browser/management_policy.h" | 11 #include "extensions/browser/management_policy.h" |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 // This class provides a simple way to create providers with specific | 15 // This class provides a simple way to create providers with specific |
16 // restrictions and a known error message, for use in testing. | 16 // restrictions and a known error message, for use in testing. |
17 class TestManagementPolicyProvider : public ManagementPolicy::Provider { | 17 class TestManagementPolicyProvider : public ManagementPolicy::Provider { |
18 public: | 18 public: |
19 enum AllowedActionFlag { | 19 enum AllowedActionFlag { |
20 ALLOW_ALL = 0, | 20 ALLOW_ALL = 0, |
21 PROHIBIT_LOAD = 1 << 0, | 21 PROHIBIT_LOAD = 1 << 0, |
22 PROHIBIT_MODIFY_STATUS = 1 << 1, | 22 PROHIBIT_MODIFY_STATUS = 1 << 1, |
23 MUST_REMAIN_ENABLED = 1 << 2, | 23 MUST_REMAIN_ENABLED = 1 << 2, |
24 MUST_REMAIN_DISABLED = 1 << 3 | 24 MUST_REMAIN_DISABLED = 1 << 3, |
| 25 MUST_REMAIN_INSTALLED = 1 << 4, |
25 }; | 26 }; |
26 | 27 |
27 static std::string expected_error() { | 28 static std::string expected_error() { |
28 return "Action prohibited by test provider."; | 29 return "Action prohibited by test provider."; |
29 } | 30 } |
30 | 31 |
31 TestManagementPolicyProvider(); | 32 TestManagementPolicyProvider(); |
32 explicit TestManagementPolicyProvider(int prohibited_actions); | 33 explicit TestManagementPolicyProvider(int prohibited_actions); |
33 | 34 |
34 void SetProhibitedActions(int prohibited_actions); | 35 void SetProhibitedActions(int prohibited_actions); |
35 void SetDisableReason(Extension::DisableReason reason); | 36 void SetDisableReason(Extension::DisableReason reason); |
36 | 37 |
37 virtual std::string GetDebugPolicyProviderName() const override; | 38 virtual std::string GetDebugPolicyProviderName() const override; |
38 | 39 |
39 virtual bool UserMayLoad(const Extension* extension, | 40 virtual bool UserMayLoad(const Extension* extension, |
40 base::string16* error) const override; | 41 base::string16* error) const override; |
41 | 42 |
42 virtual bool UserMayModifySettings(const Extension* extension, | 43 virtual bool UserMayModifySettings(const Extension* extension, |
43 base::string16* error) const override; | 44 base::string16* error) const override; |
44 | 45 |
45 virtual bool MustRemainEnabled(const Extension* extension, | 46 virtual bool MustRemainEnabled(const Extension* extension, |
46 base::string16* error) const override; | 47 base::string16* error) const override; |
47 | 48 |
48 virtual bool MustRemainDisabled(const Extension* extension, | 49 virtual bool MustRemainDisabled(const Extension* extension, |
49 Extension::DisableReason* reason, | 50 Extension::DisableReason* reason, |
50 base::string16* error) const override; | 51 base::string16* error) const override; |
51 | 52 |
| 53 virtual bool MustRemainInstalled(const Extension* extension, |
| 54 base::string16* error) const override; |
| 55 |
52 private: | 56 private: |
53 bool may_load_; | 57 bool may_load_; |
54 bool may_modify_status_; | 58 bool may_modify_status_; |
55 bool must_remain_enabled_; | 59 bool must_remain_enabled_; |
56 bool must_remain_disabled_; | 60 bool must_remain_disabled_; |
| 61 bool must_remain_installed_; |
57 Extension::DisableReason disable_reason_; | 62 Extension::DisableReason disable_reason_; |
58 | 63 |
59 base::string16 error_message_; | 64 base::string16 error_message_; |
60 }; | 65 }; |
61 | 66 |
62 } // namespace extensions | 67 } // namespace extensions |
63 | 68 |
64 #endif // EXTENSIONS_BROWSER_TEST_MANAGEMENT_POLICY_H_ | 69 #endif // EXTENSIONS_BROWSER_TEST_MANAGEMENT_POLICY_H_ |
OLD | NEW |