Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / extensions / policy_handlers.h
blobc2636b2f5a263bea106aa61ab4a542f89cd772d4
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 CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_
6 #define CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h"
10 #include "components/policy/core/browser/configuration_policy_handler.h"
12 namespace policy {
13 class PolicyMap;
14 class PolicyErrorMap;
15 class Schema;
16 } // namespace policy
18 namespace extensions {
20 // Implements additional checks for policies that are lists of extension IDs.
21 class ExtensionListPolicyHandler
22 : public policy::TypeCheckingPolicyHandler {
23 public:
24 ExtensionListPolicyHandler(const char* policy_name,
25 const char* pref_path,
26 bool allow_wildcards);
27 ~ExtensionListPolicyHandler() override;
29 // ConfigurationPolicyHandler methods:
30 bool CheckPolicySettings(const policy::PolicyMap& policies,
31 policy::PolicyErrorMap* errors) override;
32 void ApplyPolicySettings(const policy::PolicyMap& policies,
33 PrefValueMap* prefs) override;
35 protected:
36 const char* pref_path() const;
38 // Runs sanity checks on the policy value and returns it in |extension_ids|.
39 bool CheckAndGetList(const policy::PolicyMap& policies,
40 policy::PolicyErrorMap* errors,
41 scoped_ptr<base::ListValue>* extension_ids);
43 private:
44 const char* pref_path_;
45 bool allow_wildcards_;
47 DISALLOW_COPY_AND_ASSIGN(ExtensionListPolicyHandler);
50 class ExtensionInstallForcelistPolicyHandler
51 : public policy::TypeCheckingPolicyHandler {
52 public:
53 ExtensionInstallForcelistPolicyHandler();
54 ~ExtensionInstallForcelistPolicyHandler() override;
56 // ConfigurationPolicyHandler methods:
57 bool CheckPolicySettings(const policy::PolicyMap& policies,
58 policy::PolicyErrorMap* errors) override;
59 void ApplyPolicySettings(const policy::PolicyMap& policies,
60 PrefValueMap* prefs) override;
62 private:
63 // Parses the data in |policy_value| and writes them to |extension_dict|.
64 bool ParseList(const base::Value* policy_value,
65 base::DictionaryValue* extension_dict,
66 policy::PolicyErrorMap* errors);
68 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallForcelistPolicyHandler);
71 // Implements additional checks for policies that are lists of extension
72 // URLPatterns.
73 class ExtensionURLPatternListPolicyHandler
74 : public policy::TypeCheckingPolicyHandler {
75 public:
76 ExtensionURLPatternListPolicyHandler(const char* policy_name,
77 const char* pref_path);
78 ~ExtensionURLPatternListPolicyHandler() override;
80 // ConfigurationPolicyHandler methods:
81 bool CheckPolicySettings(const policy::PolicyMap& policies,
82 policy::PolicyErrorMap* errors) override;
83 void ApplyPolicySettings(const policy::PolicyMap& policies,
84 PrefValueMap* prefs) override;
86 private:
87 const char* pref_path_;
89 DISALLOW_COPY_AND_ASSIGN(ExtensionURLPatternListPolicyHandler);
92 class ExtensionSettingsPolicyHandler
93 : public policy::SchemaValidatingPolicyHandler {
94 public:
95 explicit ExtensionSettingsPolicyHandler(const policy::Schema& chrome_schema);
96 ~ExtensionSettingsPolicyHandler() override;
98 // ConfigurationPolicyHandler methods:
99 bool CheckPolicySettings(const policy::PolicyMap& policies,
100 policy::PolicyErrorMap* errors) override;
101 void ApplyPolicySettings(const policy::PolicyMap& policies,
102 PrefValueMap* prefs) override;
104 private:
105 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsPolicyHandler);
108 } // namespace extensions
110 #endif // CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_