- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / policy / configuration_policy_handler_chromeos.h
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 "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"
12
13 namespace base {
14 class DictionaryValue;
15 class Value;
16 }
17
18 namespace policy {
19
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 {
24  public:
25   static NetworkConfigurationPolicyHandler* CreateForUserPolicy();
26   static NetworkConfigurationPolicyHandler* CreateForDevicePolicy();
27
28   virtual ~NetworkConfigurationPolicyHandler();
29
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;
36
37  private:
38   explicit NetworkConfigurationPolicyHandler(
39       const char* policy_name,
40       ::onc::ONCSource onc_source,
41       const char* pref_path);
42
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);
48
49   // The kind of ONC source that this handler represents. ONCSource
50   // distinguishes between user and device policy.
51   const ::onc::ONCSource onc_source_;
52
53   // The name of the pref to apply the policy to.
54   const char* pref_path_;
55
56   DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationPolicyHandler);
57 };
58
59 // Maps the PinnedLauncherApps policy to the corresponding pref.
60 class PinnedLauncherAppsPolicyHandler
61     : public extensions::ExtensionListPolicyHandler {
62  public:
63   PinnedLauncherAppsPolicyHandler();
64   virtual ~PinnedLauncherAppsPolicyHandler();
65
66   // ExtensionListPolicyHandler methods:
67   virtual void ApplyPolicySettings(const PolicyMap& policies,
68                                    PrefValueMap* prefs) OVERRIDE;
69
70  private:
71   DISALLOW_COPY_AND_ASSIGN(PinnedLauncherAppsPolicyHandler);
72 };
73
74 class ScreenMagnifierPolicyHandler : public IntRangePolicyHandlerBase {
75  public:
76   ScreenMagnifierPolicyHandler();
77   virtual ~ScreenMagnifierPolicyHandler();
78
79   // IntRangePolicyHandlerBase:
80   virtual void ApplyPolicySettings(const PolicyMap& policies,
81                                    PrefValueMap* prefs) OVERRIDE;
82
83  private:
84   DISALLOW_COPY_AND_ASSIGN(ScreenMagnifierPolicyHandler);
85 };
86
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 {
92  public:
93   LoginScreenPowerManagementPolicyHandler();
94   virtual ~LoginScreenPowerManagementPolicyHandler();
95
96   // TypeCheckingPolicyHandler:
97   virtual bool CheckPolicySettings(const PolicyMap& policies,
98                                    PolicyErrorMap* errors) OVERRIDE;
99   virtual void ApplyPolicySettings(const PolicyMap& policies,
100                                    PrefValueMap* prefs) OVERRIDE;
101
102  private:
103   DISALLOW_COPY_AND_ASSIGN(LoginScreenPowerManagementPolicyHandler);
104 };
105
106 // Handles the deprecated IdleAction policy, so both kIdleActionBattery and
107 // kIdleActionAC fall back to the deprecated action.
108 class DeprecatedIdleActionHandler : public IntRangePolicyHandlerBase {
109  public:
110   DeprecatedIdleActionHandler();
111   virtual ~DeprecatedIdleActionHandler();
112
113   // ConfigurationPolicyHandler methods:
114   virtual void ApplyPolicySettings(const PolicyMap& policies,
115                                    PrefValueMap* prefs) OVERRIDE;
116
117  private:
118   DISALLOW_COPY_AND_ASSIGN(DeprecatedIdleActionHandler);
119 };
120
121 }  // namespace policy
122
123 #endif  // CHROME_BROWSER_CHROMEOS_POLICY_CONFIGURATION_POLICY_HANDLER_CHROMEOS_H_