proxy_policy_handler.h 2.3 KB

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