| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_PROXY_PROXY_CONFIG_H_ | 5 #ifndef NET_PROXY_PROXY_CONFIG_H_ |
| 6 #define NET_PROXY_PROXY_CONFIG_H_ | 6 #define NET_PROXY_PROXY_CONFIG_H_ |
| 7 | 7 |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // <url-scheme>"="<proxy-uri> | 61 // <url-scheme>"="<proxy-uri> |
| 62 // | 62 // |
| 63 // For example: | 63 // For example: |
| 64 // "http=foopy:80;ftp=foopy2" -- use HTTP proxy "foopy:80" for http URLs, | 64 // "http=foopy:80;ftp=foopy2" -- use HTTP proxy "foopy:80" for http URLs, |
| 65 // and HTTP proxy "foopy2:80" for ftp URLs. | 65 // and HTTP proxy "foopy2:80" for ftp URLs. |
| 66 // "foopy:80" -- use HTTP proxy "foopy:80" for all URLs. | 66 // "foopy:80" -- use HTTP proxy "foopy:80" for all URLs. |
| 67 // "socks4://foopy" -- use SOCKS v4 proxy "foopy:1080" for all | 67 // "socks4://foopy" -- use SOCKS v4 proxy "foopy:1080" for all |
| 68 // URLs. | 68 // URLs. |
| 69 void ParseFromString(const std::string& proxy_rules); | 69 void ParseFromString(const std::string& proxy_rules); |
| 70 | 70 |
| 71 // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp}, | 71 // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp, |
| 72 // or NULL if it is a scheme that we don't have a mapping for. Should only | 72 // &socks_proxy}, or NULL if it is a scheme that we don't have a mapping |
| 73 // call this if the type is TYPE_PROXY_PER_SCHEME. | 73 // for. If the scheme mapping is not present and socks_proxy is defined, |
| 74 const ProxyServer* MapSchemeToProxy(const std::string& scheme) const; | 74 // we fall back to using socks_proxy. |
| 75 // Should only call this if the type is TYPE_PROXY_PER_SCHEME. |
| 76 const ProxyServer* MapUrlSchemeToProxy(const std::string& url_scheme) const; |
| 75 | 77 |
| 76 bool operator==(const ProxyRules& other) const { | 78 bool operator==(const ProxyRules& other) const { |
| 77 return type == other.type && | 79 return type == other.type && |
| 78 single_proxy == other.single_proxy && | 80 single_proxy == other.single_proxy && |
| 79 proxy_for_http == other.proxy_for_http && | 81 proxy_for_http == other.proxy_for_http && |
| 80 proxy_for_https == other.proxy_for_https && | 82 proxy_for_https == other.proxy_for_https && |
| 81 proxy_for_ftp == other.proxy_for_ftp; | 83 proxy_for_ftp == other.proxy_for_ftp && |
| 84 socks_proxy == other.socks_proxy; |
| 82 } | 85 } |
| 83 | 86 |
| 84 Type type; | 87 Type type; |
| 85 | 88 |
| 86 // Set if |type| is TYPE_SINGLE_PROXY. | 89 // Set if |type| is TYPE_SINGLE_PROXY. |
| 87 ProxyServer single_proxy; | 90 ProxyServer single_proxy; |
| 88 | 91 |
| 89 // Set if |type| is TYPE_PROXY_PER_SCHEME. | 92 // Set if |type| is TYPE_PROXY_PER_SCHEME. |
| 90 ProxyServer proxy_for_http; | 93 ProxyServer proxy_for_http; |
| 91 ProxyServer proxy_for_https; | 94 ProxyServer proxy_for_https; |
| 92 ProxyServer proxy_for_ftp; | 95 ProxyServer proxy_for_ftp; |
| 96 |
| 97 // Set if configuration has SOCKS proxy. |
| 98 ProxyServer socks_proxy; |
| 99 private: |
| 100 // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp, |
| 101 // &socks_proxy}, or NULL if it is a scheme that we don't have a mapping |
| 102 // for. Should only call this if the type is TYPE_PROXY_PER_SCHEME. |
| 103 ProxyServer* MapSchemeToProxy(const std::string& scheme); |
| 93 }; | 104 }; |
| 94 | 105 |
| 95 ProxyRules proxy_rules; | 106 ProxyRules proxy_rules; |
| 96 | 107 |
| 97 // Parses entries from a comma-separated list of hosts for which proxy | 108 // Parses entries from a comma-separated list of hosts for which proxy |
| 98 // configurations should be bypassed. Clears proxy_bypass and sets it to the | 109 // configurations should be bypassed. Clears proxy_bypass and sets it to the |
| 99 // resulting list. | 110 // resulting list. |
| 100 void ParseNoProxyList(const std::string& no_proxy); | 111 void ParseNoProxyList(const std::string& no_proxy); |
| 101 | 112 |
| 102 // Indicates a list of hosts that should bypass any proxy configuration. For | 113 // Indicates a list of hosts that should bypass any proxy configuration. For |
| (...skipping 21 matching lines...) Expand all Loading... |
| 124 // Dumps a human-readable string representation of the configuration to |out|; | 135 // Dumps a human-readable string representation of the configuration to |out|; |
| 125 // used when logging the configuration changes. | 136 // used when logging the configuration changes. |
| 126 std::ostream& operator<<(std::ostream& out, const net::ProxyConfig& config); | 137 std::ostream& operator<<(std::ostream& out, const net::ProxyConfig& config); |
| 127 | 138 |
| 128 // Dumps a human-readable string representation of the |rules| to |out|; | 139 // Dumps a human-readable string representation of the |rules| to |out|; |
| 129 // used for logging and for better unittest failure output. | 140 // used for logging and for better unittest failure output. |
| 130 std::ostream& operator<<(std::ostream& out, | 141 std::ostream& operator<<(std::ostream& out, |
| 131 const net::ProxyConfig::ProxyRules& rules); | 142 const net::ProxyConfig::ProxyRules& rules); |
| 132 | 143 |
| 133 #endif // NET_PROXY_PROXY_CONFIG_H_ | 144 #endif // NET_PROXY_PROXY_CONFIG_H_ |
| OLD | NEW |