Add ICU message format support
[chromium-blink-merge.git] / extensions / browser / test_management_policy.h
blobcf91143cdeae993fa5407f3156a09466f65ad4b5
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_TEST_MANAGEMENT_POLICY_H_
6 #define EXTENSIONS_BROWSER_TEST_MANAGEMENT_POLICY_H_
8 #include <string>
10 #include "base/strings/string16.h"
11 #include "extensions/browser/management_policy.h"
13 namespace extensions {
15 // This class provides a simple way to create providers with specific
16 // restrictions and a known error message, for use in testing.
17 class TestManagementPolicyProvider : public ManagementPolicy::Provider {
18 public:
19 enum AllowedActionFlag {
20 ALLOW_ALL = 0,
21 PROHIBIT_LOAD = 1 << 0,
22 PROHIBIT_MODIFY_STATUS = 1 << 1,
23 MUST_REMAIN_ENABLED = 1 << 2,
24 MUST_REMAIN_DISABLED = 1 << 3,
25 MUST_REMAIN_INSTALLED = 1 << 4,
28 static std::string expected_error() {
29 return "Action prohibited by test provider.";
32 TestManagementPolicyProvider();
33 explicit TestManagementPolicyProvider(int prohibited_actions);
35 void SetProhibitedActions(int prohibited_actions);
36 void SetDisableReason(Extension::DisableReason reason);
38 std::string GetDebugPolicyProviderName() const override;
40 bool UserMayLoad(const Extension* extension,
41 base::string16* error) const override;
43 bool UserMayModifySettings(const Extension* extension,
44 base::string16* error) const override;
46 bool MustRemainEnabled(const Extension* extension,
47 base::string16* error) const override;
49 bool MustRemainDisabled(const Extension* extension,
50 Extension::DisableReason* reason,
51 base::string16* error) const override;
53 bool MustRemainInstalled(const Extension* extension,
54 base::string16* error) const override;
56 private:
57 bool may_load_;
58 bool may_modify_status_;
59 bool must_remain_enabled_;
60 bool must_remain_disabled_;
61 bool must_remain_installed_;
62 Extension::DisableReason disable_reason_;
64 base::string16 error_message_;
67 } // namespace extensions
69 #endif // EXTENSIONS_BROWSER_TEST_MANAGEMENT_POLICY_H_