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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CONFIGURATION_POLICY_HANDLER_CHROMEOS_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_CONFIGURATION_POLICY_HANDLER_CHROMEOS_H_
8 #include "chrome/browser/extensions/policy_handlers.h"
9 #include "chrome/browser/policy/configuration_policy_handler.h"
10 #include "chromeos/network/network_ui_data.h"
11 #include "components/onc/onc_constants.h"
14 class DictionaryValue;
20 // ConfigurationPolicyHandler for validation of the network configuration
21 // policies. These actually don't set any preferences, but the handler just
22 // generates error messages.
23 class NetworkConfigurationPolicyHandler : public TypeCheckingPolicyHandler {
25 static NetworkConfigurationPolicyHandler* CreateForUserPolicy();
26 static NetworkConfigurationPolicyHandler* CreateForDevicePolicy();
28 virtual ~NetworkConfigurationPolicyHandler();
30 // ConfigurationPolicyHandler methods:
31 virtual bool CheckPolicySettings(const PolicyMap& policies,
32 PolicyErrorMap* errors) OVERRIDE;
33 virtual void ApplyPolicySettings(const PolicyMap& policies,
34 PrefValueMap* prefs) OVERRIDE;
35 virtual void PrepareForDisplaying(PolicyMap* policies) const OVERRIDE;
38 explicit NetworkConfigurationPolicyHandler(
39 const char* policy_name,
40 ::onc::ONCSource onc_source,
41 const char* pref_path);
43 // Takes network policy in Value representation and produces an output Value
44 // that contains a pretty-printed and sanitized version. In particular, we
45 // remove any Passphrases that may be contained in the JSON. Ownership of the
46 // return value is transferred to the caller.
47 static base::Value* SanitizeNetworkConfig(const base::Value* config);
49 // The kind of ONC source that this handler represents. ONCSource
50 // distinguishes between user and device policy.
51 const ::onc::ONCSource onc_source_;
53 // The name of the pref to apply the policy to.
54 const char* pref_path_;
56 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationPolicyHandler);
59 // Maps the PinnedLauncherApps policy to the corresponding pref.
60 class PinnedLauncherAppsPolicyHandler
61 : public extensions::ExtensionListPolicyHandler {
63 PinnedLauncherAppsPolicyHandler();
64 virtual ~PinnedLauncherAppsPolicyHandler();
66 // ExtensionListPolicyHandler methods:
67 virtual void ApplyPolicySettings(const PolicyMap& policies,
68 PrefValueMap* prefs) OVERRIDE;
71 DISALLOW_COPY_AND_ASSIGN(PinnedLauncherAppsPolicyHandler);
74 class ScreenMagnifierPolicyHandler : public IntRangePolicyHandlerBase {
76 ScreenMagnifierPolicyHandler();
77 virtual ~ScreenMagnifierPolicyHandler();
79 // IntRangePolicyHandlerBase:
80 virtual void ApplyPolicySettings(const PolicyMap& policies,
81 PrefValueMap* prefs) OVERRIDE;
84 DISALLOW_COPY_AND_ASSIGN(ScreenMagnifierPolicyHandler);
87 // ConfigurationPolicyHandler for login screen power management settings. This
88 // does not actually set any prefs, it just checks whether the settings are
89 // valid and generates errors if appropriate.
90 class LoginScreenPowerManagementPolicyHandler
91 : public TypeCheckingPolicyHandler {
93 LoginScreenPowerManagementPolicyHandler();
94 virtual ~LoginScreenPowerManagementPolicyHandler();
96 // TypeCheckingPolicyHandler:
97 virtual bool CheckPolicySettings(const PolicyMap& policies,
98 PolicyErrorMap* errors) OVERRIDE;
99 virtual void ApplyPolicySettings(const PolicyMap& policies,
100 PrefValueMap* prefs) OVERRIDE;
103 DISALLOW_COPY_AND_ASSIGN(LoginScreenPowerManagementPolicyHandler);
106 // Handles the deprecated IdleAction policy, so both kIdleActionBattery and
107 // kIdleActionAC fall back to the deprecated action.
108 class DeprecatedIdleActionHandler : public IntRangePolicyHandlerBase {
110 DeprecatedIdleActionHandler();
111 virtual ~DeprecatedIdleActionHandler();
113 // ConfigurationPolicyHandler methods:
114 virtual void ApplyPolicySettings(const PolicyMap& policies,
115 PrefValueMap* prefs) OVERRIDE;
118 DISALLOW_COPY_AND_ASSIGN(DeprecatedIdleActionHandler);
121 } // namespace policy
123 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONFIGURATION_POLICY_HANDLER_CHROMEOS_H_