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. 4 5 #ifndef CHROME_BROWSER_NET_PROXY_POLICY_HANDLER_H_ 6 #define CHROME_BROWSER_NET_PROXY_POLICY_HANDLER_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 #include "components/policy/core/browser/configuration_policy_handler.h" 12 13 namespace policy { 14 15 class ProxyMap; 16 class ProxyErrorMap; 17 18 // ConfigurationPolicyHandler for the proxy policies. 19 class ProxyPolicyHandler : public ConfigurationPolicyHandler { 20 public: 21 // Constants for the "Proxy Server Mode" defined in the policies. 22 // Note that these diverge from internal presentation defined in 23 // ProxyPrefs::ProxyMode for legacy reasons. The following four 24 // PolicyProxyModeType types were not very precise and had overlapping use 25 // cases. 26 enum ProxyModeType { 27 // Disable Proxy, connect directly. 28 PROXY_SERVER_MODE = 0, 29 // Auto detect proxy or use specific PAC script if given. 30 PROXY_AUTO_DETECT_PROXY_SERVER_MODE = 1, 31 // Use manually configured proxy servers (fixed servers). 32 PROXY_MANUALLY_CONFIGURED_PROXY_SERVER_MODE = 2, 33 // Use system proxy server. 34 PROXY_USE_SYSTEM_PROXY_SERVER_MODE = 3, 35 36 MODE_COUNT 37 }; 38 39 ProxyPolicyHandler(); 40 virtual ~ProxyPolicyHandler(); 41 42 // ConfigurationPolicyHandler methods: 43 virtual bool CheckPolicySettings(const PolicyMap& policies, 44 PolicyErrorMap* errors) OVERRIDE; 45 virtual void ApplyPolicySettings(const PolicyMap& policies, 46 PrefValueMap* prefs) OVERRIDE; 47 48 private: 49 const base::Value* GetProxyPolicyValue(const PolicyMap& policies, 50 const char* policy_name); 51 52 // Converts the deprecated ProxyServerMode policy value to a ProxyMode value 53 // and places the result in |mode_value|. Returns whether the conversion 54 // succeeded. 55 bool CheckProxyModeAndServerMode(const PolicyMap& policies, 56 PolicyErrorMap* errors, 57 std::string* mode_value); 58 59 DISALLOW_COPY_AND_ASSIGN(ProxyPolicyHandler); 60 }; 61 62 } // namespace policy 63 64 #endif // CHROME_BROWSER_NET_PROXY_POLICY_HANDLER_H_ 65