Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 #include "net/proxy/proxy_bypass_rules.h" | 12 #include "net/proxy/proxy_bypass_rules.h" |
| 13 #include "net/proxy/proxy_config_source.h" | 13 #include "net/proxy/proxy_config_source.h" |
| 14 #include "net/proxy/proxy_list.h" | |
| 14 #include "net/proxy/proxy_server.h" | 15 #include "net/proxy/proxy_server.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class Value; | 18 class Value; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 | 22 |
| 22 class ProxyInfo; | 23 class ProxyInfo; |
| 23 | 24 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 45 | 46 |
| 46 // Note that the default of TYPE_NO_RULES results in direct connections | 47 // Note that the default of TYPE_NO_RULES results in direct connections |
| 47 // being made when using this ProxyConfig. | 48 // being made when using this ProxyConfig. |
| 48 ProxyRules(); | 49 ProxyRules(); |
| 49 ~ProxyRules(); | 50 ~ProxyRules(); |
| 50 | 51 |
| 51 bool empty() const { | 52 bool empty() const { |
| 52 return type == TYPE_NO_RULES; | 53 return type == TYPE_NO_RULES; |
| 53 } | 54 } |
| 54 | 55 |
| 55 // Sets |result| with the proxy to use for |url| based on the current rules. | 56 // Sets |result| with the proxies to use for |url| based on the current |
| 57 // rules. | |
| 56 void Apply(const GURL& url, ProxyInfo* result) const; | 58 void Apply(const GURL& url, ProxyInfo* result) const; |
| 57 | 59 |
| 58 // Parses the rules from a string, indicating which proxies to use. | 60 // Parses the rules from a string, indicating which proxies to use. |
| 59 // | 61 // |
| 60 // proxy-uri = [<proxy-scheme>"://"]<proxy-host>[":"<proxy-port>] | 62 // proxy-uri = [<proxy-scheme>"://"]<proxy-host>[":"<proxy-port>] |
| 61 // | 63 // |
| 64 // proxy-uri-list = <proxy-uri>[","<proxy-uri-list>] | |
| 65 // | |
| 62 // If the proxy to use depends on the scheme of the URL, can instead specify | 66 // If the proxy to use depends on the scheme of the URL, can instead specify |
| 63 // a semicolon separated list of: | 67 // a semicolon separated list of: |
| 64 // | 68 // |
| 65 // <url-scheme>"="<proxy-uri> | 69 // <url-scheme>"="<proxy-uri-list> |
| 70 // | |
| 71 // If 'socks' is specified as a scheme, any schemes left without proxies | |
| 72 // specified will have that 'socks' server added. | |
| 66 // | 73 // |
| 67 // For example: | 74 // For example: |
| 68 // "http=foopy:80;ftp=foopy2" -- use HTTP proxy "foopy:80" for http:// | 75 // "http=foopy:80;ftp=foopy2" -- use HTTP proxy "foopy:80" for http:// |
| 69 // URLs, and HTTP proxy "foopy2:80" for | 76 // URLs, and HTTP proxy "foopy2:80" for |
| 70 // ftp:// URLs. | 77 // ftp:// URLs. |
| 71 // "foopy:80" -- use HTTP proxy "foopy:80" for all URLs. | 78 // "foopy:80" -- use HTTP proxy "foopy:80" for all URLs. |
|
eroman
2013/03/01 00:05:13
It would make sense for proxy-uri-list to also be
marq_use_my_chromium_address
2013/03/04 18:04:20
Done.
| |
| 72 // "socks4://foopy" -- use SOCKS v4 proxy "foopy:1080" for all | 79 // "socks4://foopy" -- use SOCKS v4 proxy "foopy:1080" for all |
| 73 // URLs. | 80 // URLs. |
| 81 // "http=foopy,bar.com -- use HTTP proxy "foopy" for http URLs, | |
| 82 // and fail over to "bar.com" if "foopy" | |
| 83 // is unavailable. | |
| 84 // "http=foopy,direct:// -- use HTTP proxy "foopy" for http URLs, | |
| 85 // and use no proxy if "foopy" is | |
| 86 // unavailable. | |
| 87 // "http=foopy;socks=foopy2 -- use HTTP proxy "foopy" for http URLs, | |
| 88 // and use socks4://foopy2 for all other | |
| 89 // URLs. | |
| 74 void ParseFromString(const std::string& proxy_rules); | 90 void ParseFromString(const std::string& proxy_rules); |
| 75 | 91 |
| 76 // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp, | 92 // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp, |
|
eroman
2013/03/01 00:05:13
Please update this comment to reflect new names.
marq_use_my_chromium_address
2013/03/04 18:04:20
Done.
| |
| 77 // &fallback_proxy}, or NULL if there is no proxy to use. | 93 // &fallback_proxy}, or NULL if there is no proxy to use. |
| 78 // Should only call this if the type is TYPE_PROXY_PER_SCHEME. | 94 // Should only call this if the type is TYPE_PROXY_PER_SCHEME. |
| 79 const ProxyServer* MapUrlSchemeToProxy(const std::string& url_scheme) const; | 95 const ProxyList* MapUrlSchemeToProxy(const std::string& url_scheme) const; |
|
eroman
2013/03/01 00:05:13
Can you rename "ToProxy" --> "ToProxies" or "ToPro
marq_use_my_chromium_address
2013/03/04 18:04:20
Done.
| |
| 80 | 96 |
| 81 // Returns true if |*this| describes the same configuration as |other|. | 97 // Returns true if |*this| describes the same configuration as |other|. |
| 82 bool Equals(const ProxyRules& other) const; | 98 bool Equals(const ProxyRules& other) const; |
| 83 | 99 |
| 84 // Exceptions for when not to use a proxy. | 100 // Exceptions for when not to use a proxy. |
| 85 ProxyBypassRules bypass_rules; | 101 ProxyBypassRules bypass_rules; |
| 86 | 102 |
| 87 // Reverse the meaning of |bypass_rules|. | 103 // Reverse the meaning of |bypass_rules|. |
| 88 bool reverse_bypass; | 104 bool reverse_bypass; |
| 89 | 105 |
| 90 Type type; | 106 Type type; |
| 91 | 107 |
| 92 // Set if |type| is TYPE_SINGLE_PROXY. | 108 // Set if |type| is TYPE_SINGLE_PROXY. |
| 93 ProxyServer single_proxy; | 109 ProxyList single_proxies; |
|
eroman
2013/03/01 00:05:13
Side-comment [no action necessary]: Can probably j
marq_use_my_chromium_address
2013/03/04 18:04:20
Ack.
| |
| 94 | 110 |
| 95 // Set if |type| is TYPE_PROXY_PER_SCHEME. | 111 // Set if |type| is TYPE_PROXY_PER_SCHEME. |
| 96 ProxyServer proxy_for_http; | 112 ProxyList proxies_for_http; |
| 97 ProxyServer proxy_for_https; | 113 ProxyList proxies_for_https; |
| 98 ProxyServer proxy_for_ftp; | 114 ProxyList proxies_for_ftp; |
| 99 | 115 |
| 100 // Used when there isn't a more specific per-scheme proxy server. | 116 // Used when a fallback has been defined and the url to be proxied doesn't |
| 101 ProxyServer fallback_proxy; | 117 // match any of the standard schemes. |
| 118 ProxyList fallback_proxies; | |
| 102 | 119 |
| 103 private: | 120 private: |
| 104 // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp} | 121 // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp} |
|
eroman
2013/03/01 00:05:13
Please update this comment.
marq_use_my_chromium_address
2013/03/04 18:04:20
Done.
| |
| 105 // or NULL if it is a scheme that we don't have a mapping | 122 // or NULL if it is a scheme that we don't have a mapping |
| 106 // for. Should only call this if the type is TYPE_PROXY_PER_SCHEME. | 123 // for. Should only call this if the type is TYPE_PROXY_PER_SCHEME. |
| 107 ProxyServer* MapUrlSchemeToProxyNoFallback(const std::string& scheme); | 124 ProxyList* MapUrlSchemeToProxyNoFallback(const std::string& scheme); |
|
eroman
2013/03/01 00:05:13
See earlier rename suggestion.
marq_use_my_chromium_address
2013/03/04 18:04:20
Done.
| |
| 108 }; | 125 }; |
| 109 | 126 |
| 110 typedef int ID; | 127 typedef int ID; |
| 111 | 128 |
| 112 // Indicates an invalid proxy config. | 129 // Indicates an invalid proxy config. |
| 113 static const ID kInvalidConfigID = 0; | 130 static const ID kInvalidConfigID = 0; |
| 114 | 131 |
| 115 ProxyConfig(); | 132 ProxyConfig(); |
| 116 ProxyConfig(const ProxyConfig& config); | 133 ProxyConfig(const ProxyConfig& config); |
| 117 ~ProxyConfig(); | 134 ~ProxyConfig(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 ProxyConfigSource source_; | 235 ProxyConfigSource source_; |
| 219 | 236 |
| 220 ID id_; | 237 ID id_; |
| 221 }; | 238 }; |
| 222 | 239 |
| 223 } // namespace net | 240 } // namespace net |
| 224 | 241 |
| 225 | 242 |
| 226 | 243 |
| 227 #endif // NET_PROXY_PROXY_CONFIG_H_ | 244 #endif // NET_PROXY_PROXY_CONFIG_H_ |
| OLD | NEW |