proxy_prefs.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright (c) 2011 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_PREFS_H_
  5. #define COMPONENTS_PROXY_CONFIG_PROXY_PREFS_H_
  6. #include <string>
  7. #include "components/proxy_config/proxy_config_export.h"
  8. namespace ProxyPrefs {
  9. // Possible types of specifying proxy settings. Do not change the order of
  10. // the constants, because numeric values are exposed to users.
  11. // If you add an enum constant, you should also add a string to
  12. // kProxyModeNames in the .cc file.
  13. enum ProxyMode {
  14. // Direct connection to the network, other proxy preferences are ignored.
  15. MODE_DIRECT = 0,
  16. // Try to auto-detect the PAC script location.
  17. // On Windows and Chrome OS, DHCP is tried first (DHCP Option 252), and DNS
  18. // (resolving http://wpad/wpad.dat) is tried second.
  19. // On other platforms, only DNS is tried.
  20. // If no PAC script can be found by this method, fall back to direct
  21. // connection.
  22. MODE_AUTO_DETECT = 1,
  23. // Try to retrieve a PAC script from kProxyPacURL or fall back to direct
  24. // connection.
  25. MODE_PAC_SCRIPT = 2,
  26. // Use the settings specified in kProxyServer and kProxyBypassList.
  27. MODE_FIXED_SERVERS = 3,
  28. // The system's proxy settings are used, other proxy preferences are
  29. // ignored.
  30. MODE_SYSTEM = 4,
  31. kModeCount
  32. };
  33. // State of proxy configuration.
  34. enum ConfigState {
  35. // Configuration is from policy.
  36. CONFIG_POLICY,
  37. // Configuration is from extension.
  38. CONFIG_EXTENSION,
  39. // Configuration is not from policy or extension but still precedes others.
  40. CONFIG_OTHER_PRECEDE,
  41. // Configuration is from system.
  42. CONFIG_SYSTEM,
  43. // Configuration is recommended i.e there's a fallback configuration.
  44. CONFIG_FALLBACK,
  45. // Configuration is known to be not set.
  46. CONFIG_UNSET,
  47. };
  48. // Constants for string values used to specify the proxy mode through externally
  49. // visible APIs, e.g. through policy or the proxy extension API.
  50. PROXY_CONFIG_EXPORT extern const char kDirectProxyModeName[];
  51. PROXY_CONFIG_EXPORT extern const char kAutoDetectProxyModeName[];
  52. PROXY_CONFIG_EXPORT extern const char kPacScriptProxyModeName[];
  53. PROXY_CONFIG_EXPORT extern const char kFixedServersProxyModeName[];
  54. PROXY_CONFIG_EXPORT extern const char kSystemProxyModeName[];
  55. PROXY_CONFIG_EXPORT bool IntToProxyMode(int in_value, ProxyMode* out_value);
  56. PROXY_CONFIG_EXPORT bool StringToProxyMode(const std::string& in_value,
  57. ProxyMode* out_value);
  58. // Ownership of the return value is NOT passed to the caller.
  59. PROXY_CONFIG_EXPORT const char* ProxyModeToString(ProxyMode mode);
  60. PROXY_CONFIG_EXPORT std::string ConfigStateToDebugString(ConfigState state);
  61. } // namespace ProxyPrefs
  62. #endif // COMPONENTS_PROXY_CONFIG_PROXY_PREFS_H_