configuration_policy_handler_chromeos.h revision ca12bfac764ba476d6cd062bf1dde12cc64c3f40
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/policy/configuration_policy_handler.h" 9#include "chromeos/network/network_ui_data.h" 10#include "chromeos/network/onc/onc_constants.h" 11 12namespace base { 13class DictionaryValue; 14class Value; 15} 16 17namespace policy { 18 19// ConfigurationPolicyHandler for validation of the network configuration 20// policies. These actually don't set any preferences, but the handler just 21// generates error messages. 22class NetworkConfigurationPolicyHandler : public TypeCheckingPolicyHandler { 23 public: 24 static NetworkConfigurationPolicyHandler* CreateForUserPolicy(); 25 static NetworkConfigurationPolicyHandler* CreateForDevicePolicy(); 26 27 virtual ~NetworkConfigurationPolicyHandler(); 28 29 // ConfigurationPolicyHandler methods: 30 virtual bool CheckPolicySettings(const PolicyMap& policies, 31 PolicyErrorMap* errors) OVERRIDE; 32 virtual void ApplyPolicySettings(const PolicyMap& policies, 33 PrefValueMap* prefs) OVERRIDE; 34 virtual void PrepareForDisplaying(PolicyMap* policies) const OVERRIDE; 35 36 private: 37 explicit NetworkConfigurationPolicyHandler( 38 const char* policy_name, 39 chromeos::onc::ONCSource onc_source, 40 const char* pref_path); 41 42 // Takes network policy in Value representation and produces an output Value 43 // that contains a pretty-printed and sanitized version. In particular, we 44 // remove any Passphrases that may be contained in the JSON. Ownership of the 45 // return value is transferred to the caller. 46 static base::Value* SanitizeNetworkConfig(const base::Value* config); 47 48 // The kind of ONC source that this handler represents. ONCSource 49 // distinguishes between user and device policy. 50 const chromeos::onc::ONCSource onc_source_; 51 52 // The name of the pref to apply the policy to. 53 const char* pref_path_; 54 55 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationPolicyHandler); 56}; 57 58// Maps the PinnedLauncherApps policy to the corresponding pref. 59class PinnedLauncherAppsPolicyHandler : public ExtensionListPolicyHandler { 60 public: 61 PinnedLauncherAppsPolicyHandler(); 62 virtual ~PinnedLauncherAppsPolicyHandler(); 63 64 // ExtensionListPolicyHandler methods: 65 virtual void ApplyPolicySettings(const PolicyMap& policies, 66 PrefValueMap* prefs) OVERRIDE; 67 68 private: 69 DISALLOW_COPY_AND_ASSIGN(PinnedLauncherAppsPolicyHandler); 70}; 71 72class ScreenMagnifierPolicyHandler : public IntRangePolicyHandlerBase { 73 public: 74 ScreenMagnifierPolicyHandler(); 75 virtual ~ScreenMagnifierPolicyHandler(); 76 77 // IntRangePolicyHandlerBase: 78 virtual void ApplyPolicySettings(const PolicyMap& policies, 79 PrefValueMap* prefs) OVERRIDE; 80 81 private: 82 DISALLOW_COPY_AND_ASSIGN(ScreenMagnifierPolicyHandler); 83}; 84 85// ConfigurationPolicyHandler for login screen power management settings. This 86// does not actually set any prefs, it just checks whether the settings are 87// valid and generates errors if appropriate. 88class LoginScreenPowerManagementPolicyHandler 89 : public TypeCheckingPolicyHandler { 90 public: 91 LoginScreenPowerManagementPolicyHandler(); 92 virtual ~LoginScreenPowerManagementPolicyHandler(); 93 94 // TypeCheckingPolicyHandler: 95 virtual bool CheckPolicySettings(const PolicyMap& policies, 96 PolicyErrorMap* errors) OVERRIDE; 97 virtual void ApplyPolicySettings(const PolicyMap& policies, 98 PrefValueMap* prefs) OVERRIDE; 99 100 private: 101 DISALLOW_COPY_AND_ASSIGN(LoginScreenPowerManagementPolicyHandler); 102}; 103 104} // namespace policy 105 106#endif // CHROME_BROWSER_CHROMEOS_POLICY_CONFIGURATION_POLICY_HANDLER_CHROMEOS_H_ 107