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"
17 namespace extensions
{
19 // Implements additional checks for policies that are lists of extension IDs.
20 class ExtensionListPolicyHandler
21 : public policy::TypeCheckingPolicyHandler
{
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
;
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
);
43 const char* pref_path_
;
44 bool allow_wildcards_
;
46 DISALLOW_COPY_AND_ASSIGN(ExtensionListPolicyHandler
);
49 class ExtensionInstallForcelistPolicyHandler
50 : public policy::TypeCheckingPolicyHandler
{
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
;
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
72 class ExtensionURLPatternListPolicyHandler
73 : public policy::TypeCheckingPolicyHandler
{
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
;
86 const char* pref_path_
;
88 DISALLOW_COPY_AND_ASSIGN(ExtensionURLPatternListPolicyHandler
);
91 } // namespace extensions
93 #endif // CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_