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