configuration_policy_handler_chromeos.h revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
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.
4
5#ifndef CHROME_BROWSER_CHROMEOS_POLICY_CONFIGURATION_POLICY_HANDLER_CHROMEOS_H_
6#define CHROME_BROWSER_CHROMEOS_POLICY_CONFIGURATION_POLICY_HANDLER_CHROMEOS_H_
7
8#include "base/basictypes.h"
9#include "base/compiler_specific.h"
10#include "chrome/browser/extensions/policy_handlers.h"
11#include "chromeos/network/network_ui_data.h"
12#include "components/onc/onc_constants.h"
13#include "components/policy/core/browser/configuration_policy_handler.h"
14
15namespace base {
16class DictionaryValue;
17class Value;
18}
19
20namespace policy {
21
22// ConfigurationPolicyHandler for policies referencing external data.
23class ExternalDataPolicyHandler : public TypeCheckingPolicyHandler {
24 public:
25  explicit ExternalDataPolicyHandler(const char* policy_name);
26  virtual ~ExternalDataPolicyHandler();
27
28  // TypeCheckingPolicyHandler:
29  virtual bool CheckPolicySettings(const PolicyMap& policies,
30                                   PolicyErrorMap* errors) OVERRIDE;
31
32  virtual void ApplyPolicySettings(const PolicyMap& policies,
33                                   PrefValueMap* prefs) OVERRIDE;
34
35 private:
36  DISALLOW_COPY_AND_ASSIGN(ExternalDataPolicyHandler);
37};
38
39// ConfigurationPolicyHandler for validation of the network configuration
40// policies. These actually don't set any preferences, but the handler just
41// generates error messages.
42class NetworkConfigurationPolicyHandler : public TypeCheckingPolicyHandler {
43 public:
44  static NetworkConfigurationPolicyHandler* CreateForUserPolicy();
45  static NetworkConfigurationPolicyHandler* CreateForDevicePolicy();
46
47  virtual ~NetworkConfigurationPolicyHandler();
48
49  // ConfigurationPolicyHandler methods:
50  virtual bool CheckPolicySettings(const PolicyMap& policies,
51                                   PolicyErrorMap* errors) OVERRIDE;
52  virtual void ApplyPolicySettings(const PolicyMap& policies,
53                                   PrefValueMap* prefs) OVERRIDE;
54  virtual void PrepareForDisplaying(PolicyMap* policies) const OVERRIDE;
55
56 private:
57  explicit NetworkConfigurationPolicyHandler(
58      const char* policy_name,
59      ::onc::ONCSource onc_source,
60      const char* pref_path);
61
62  // Takes network policy in Value representation and produces an output Value
63  // that contains a pretty-printed and sanitized version. In particular, we
64  // remove any Passphrases that may be contained in the JSON. Ownership of the
65  // return value is transferred to the caller.
66  static base::Value* SanitizeNetworkConfig(const base::Value* config);
67
68  // The kind of ONC source that this handler represents. ONCSource
69  // distinguishes between user and device policy.
70  const ::onc::ONCSource onc_source_;
71
72  // The name of the pref to apply the policy to.
73  const char* pref_path_;
74
75  DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationPolicyHandler);
76};
77
78// Maps the PinnedLauncherApps policy to the corresponding pref.
79class PinnedLauncherAppsPolicyHandler
80    : public extensions::ExtensionListPolicyHandler {
81 public:
82  PinnedLauncherAppsPolicyHandler();
83  virtual ~PinnedLauncherAppsPolicyHandler();
84
85  // ExtensionListPolicyHandler methods:
86  virtual void ApplyPolicySettings(const PolicyMap& policies,
87                                   PrefValueMap* prefs) OVERRIDE;
88
89 private:
90  DISALLOW_COPY_AND_ASSIGN(PinnedLauncherAppsPolicyHandler);
91};
92
93class ScreenMagnifierPolicyHandler : public IntRangePolicyHandlerBase {
94 public:
95  ScreenMagnifierPolicyHandler();
96  virtual ~ScreenMagnifierPolicyHandler();
97
98  // IntRangePolicyHandlerBase:
99  virtual void ApplyPolicySettings(const PolicyMap& policies,
100                                   PrefValueMap* prefs) OVERRIDE;
101
102 private:
103  DISALLOW_COPY_AND_ASSIGN(ScreenMagnifierPolicyHandler);
104};
105
106// ConfigurationPolicyHandler for login screen power management settings. This
107// does not actually set any prefs, it just checks whether the settings are
108// valid and generates errors if appropriate.
109class LoginScreenPowerManagementPolicyHandler
110    : public TypeCheckingPolicyHandler {
111 public:
112  LoginScreenPowerManagementPolicyHandler();
113  virtual ~LoginScreenPowerManagementPolicyHandler();
114
115  // TypeCheckingPolicyHandler:
116  virtual bool CheckPolicySettings(const PolicyMap& policies,
117                                   PolicyErrorMap* errors) OVERRIDE;
118  virtual void ApplyPolicySettings(const PolicyMap& policies,
119                                   PrefValueMap* prefs) OVERRIDE;
120
121 private:
122  DISALLOW_COPY_AND_ASSIGN(LoginScreenPowerManagementPolicyHandler);
123};
124
125// Handles the deprecated IdleAction policy, so both kIdleActionBattery and
126// kIdleActionAC fall back to the deprecated action.
127class DeprecatedIdleActionHandler : public IntRangePolicyHandlerBase {
128 public:
129  DeprecatedIdleActionHandler();
130  virtual ~DeprecatedIdleActionHandler();
131
132  // ConfigurationPolicyHandler methods:
133  virtual void ApplyPolicySettings(const PolicyMap& policies,
134                                   PrefValueMap* prefs) OVERRIDE;
135
136 private:
137  DISALLOW_COPY_AND_ASSIGN(DeprecatedIdleActionHandler);
138};
139
140}  // namespace policy
141
142#endif  // CHROME_BROWSER_CHROMEOS_POLICY_CONFIGURATION_POLICY_HANDLER_CHROMEOS_H_
143