Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / policy_handlers.h
blob7460d670f141b0235f05a043a3b7dc8aea7c60bd
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 } // namespace policy
17 namespace extensions {
19 // Implements additional checks for policies that are lists of extension IDs.
20 class ExtensionListPolicyHandler
21 : public policy::TypeCheckingPolicyHandler {
22 public:
23 ExtensionListPolicyHandler(const char* policy_name,
24 const char* pref_path,
25 bool allow_wildcards);
26 virtual ~ExtensionListPolicyHandler();
28 // ConfigurationPolicyHandler methods:
29 virtual bool CheckPolicySettings(const policy::PolicyMap& policies,
30 policy::PolicyErrorMap* errors) OVERRIDE;
31 virtual void ApplyPolicySettings(const policy::PolicyMap& policies,
32 PrefValueMap* prefs) OVERRIDE;
34 protected:
35 const char* pref_path() const;
37 // Runs sanity checks on the policy value and returns it in |extension_ids|.
38 bool CheckAndGetList(const policy::PolicyMap& policies,
39 policy::PolicyErrorMap* errors,
40 scoped_ptr<base::ListValue>* extension_ids);
42 private:
43 const char* pref_path_;
44 bool allow_wildcards_;
46 DISALLOW_COPY_AND_ASSIGN(ExtensionListPolicyHandler);
49 class ExtensionInstallForcelistPolicyHandler
50 : public policy::TypeCheckingPolicyHandler {
51 public:
52 ExtensionInstallForcelistPolicyHandler();
53 virtual ~ExtensionInstallForcelistPolicyHandler();
55 // ConfigurationPolicyHandler methods:
56 virtual bool CheckPolicySettings(const policy::PolicyMap& policies,
57 policy::PolicyErrorMap* errors) OVERRIDE;
58 virtual void ApplyPolicySettings(const policy::PolicyMap& policies,
59 PrefValueMap* prefs) OVERRIDE;
61 private:
62 // Parses the data in |policy_value| and writes them to |extension_dict|.
63 bool ParseList(const base::Value* policy_value,
64 base::DictionaryValue* extension_dict,
65 policy::PolicyErrorMap* errors);
67 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallForcelistPolicyHandler);
70 // Implements additional checks for policies that are lists of extension
71 // URLPatterns.
72 class ExtensionURLPatternListPolicyHandler
73 : public policy::TypeCheckingPolicyHandler {
74 public:
75 ExtensionURLPatternListPolicyHandler(const char* policy_name,
76 const char* pref_path);
77 virtual ~ExtensionURLPatternListPolicyHandler();
79 // ConfigurationPolicyHandler methods:
80 virtual bool CheckPolicySettings(const policy::PolicyMap& policies,
81 policy::PolicyErrorMap* errors) OVERRIDE;
82 virtual void ApplyPolicySettings(const policy::PolicyMap& policies,
83 PrefValueMap* prefs) OVERRIDE;
85 private:
86 const char* pref_path_;
88 DISALLOW_COPY_AND_ASSIGN(ExtensionURLPatternListPolicyHandler);
91 } // namespace extensions
93 #endif // CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_