| 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 #include "net/proxy/proxy_config.h" | 5 #include "net/proxy/proxy_config.h" |
| 6 | 6 |
| 7 #include "base/string_tokenizer.h" | 7 #include "base/string_tokenizer.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 namespace { | 168 namespace { |
| 169 | 169 |
| 170 // Helper to stringize a ProxyServer. | 170 // Helper to stringize a ProxyServer. |
| 171 std::ostream& operator<<(std::ostream& out, | 171 std::ostream& operator<<(std::ostream& out, |
| 172 const net::ProxyServer& proxy_server) { | 172 const net::ProxyServer& proxy_server) { |
| 173 if (proxy_server.is_valid()) | 173 if (proxy_server.is_valid()) |
| 174 out << proxy_server.ToURI(); | 174 out << proxy_server.ToURI(); |
| 175 return out; | 175 return out; |
| 176 } | 176 } |
| 177 | 177 |
| 178 const char* BoolToYesNoString(bool b) { |
| 179 return b ? "Yes" : "No"; |
| 180 } |
| 181 |
| 178 } // namespace | 182 } // namespace |
| 179 | 183 |
| 180 std::ostream& operator<<(std::ostream& out, | 184 std::ostream& operator<<(std::ostream& out, |
| 181 const net::ProxyConfig::ProxyRules& rules) { | 185 const net::ProxyConfig::ProxyRules& rules) { |
| 182 // Stringize the type enum. | 186 // Stringize the type enum. |
| 183 std::string type; | 187 std::string type; |
| 184 switch (rules.type) { | 188 switch (rules.type) { |
| 185 case net::ProxyConfig::ProxyRules::TYPE_NO_RULES: | 189 case net::ProxyConfig::ProxyRules::TYPE_NO_RULES: |
| 186 type = "TYPE_NO_RULES"; | 190 type = "TYPE_NO_RULES"; |
| 187 break; | 191 break; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 199 << " type: " << type << "\n" | 203 << " type: " << type << "\n" |
| 200 << " single_proxy: " << rules.single_proxy << "\n" | 204 << " single_proxy: " << rules.single_proxy << "\n" |
| 201 << " proxy_for_http: " << rules.proxy_for_http << "\n" | 205 << " proxy_for_http: " << rules.proxy_for_http << "\n" |
| 202 << " proxy_for_https: " << rules.proxy_for_https << "\n" | 206 << " proxy_for_https: " << rules.proxy_for_https << "\n" |
| 203 << " proxy_for_ftp: " << rules.proxy_for_ftp << "\n" | 207 << " proxy_for_ftp: " << rules.proxy_for_ftp << "\n" |
| 204 << " socks_proxy: " << rules.socks_proxy << "\n" | 208 << " socks_proxy: " << rules.socks_proxy << "\n" |
| 205 << " }"; | 209 << " }"; |
| 206 } | 210 } |
| 207 | 211 |
| 208 std::ostream& operator<<(std::ostream& out, const net::ProxyConfig& config) { | 212 std::ostream& operator<<(std::ostream& out, const net::ProxyConfig& config) { |
| 209 out << "{\n" | 213 // "Automatic" settings. |
| 210 << " auto_detect: " << config.auto_detect << "\n" | 214 out << "Automatic settings:\n"; |
| 211 << " pac_url: " << config.pac_url << "\n" | 215 out << " Auto-detect: " << BoolToYesNoString(config.auto_detect) << "\n"; |
| 212 << " proxy_rules:\n" << config.proxy_rules << "\n" | 216 out << " Custom PAC script: "; |
| 213 << " proxy_bypass_local_names: " << config.proxy_bypass_local_names | 217 if (config.pac_url.is_valid()) |
| 214 << "\n" | 218 out << config.pac_url; |
| 215 << " proxy_bypass_list:\n"; | 219 else |
| 220 out << "[None]"; |
| 221 out << "\n"; |
| 216 | 222 |
| 217 // Print out the proxy bypass list. | 223 // "Manual" settings. |
| 218 if (!config.proxy_bypass.empty()) { | 224 out << "Manual settings:\n"; |
| 219 out << " {\n"; | 225 out << " Proxy server: "; |
| 226 |
| 227 switch (config.proxy_rules.type) { |
| 228 case net::ProxyConfig::ProxyRules::TYPE_NO_RULES: |
| 229 out << "[None]\n"; |
| 230 break; |
| 231 case net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY: |
| 232 out << config.proxy_rules.single_proxy; |
| 233 out << "\n"; |
| 234 break; |
| 235 case net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME: |
| 236 out << "\n"; |
| 237 if (config.proxy_rules.proxy_for_http.is_valid()) |
| 238 out << " HTTP: " << config.proxy_rules.proxy_for_http << "\n"; |
| 239 if (config.proxy_rules.proxy_for_https.is_valid()) |
| 240 out << " HTTPS: " << config.proxy_rules.proxy_for_https << "\n"; |
| 241 if (config.proxy_rules.proxy_for_ftp.is_valid()) |
| 242 out << " FTP: " << config.proxy_rules.proxy_for_ftp << "\n"; |
| 243 if (config.proxy_rules.socks_proxy.is_valid()) |
| 244 out << " SOCKS: " << config.proxy_rules.socks_proxy << "\n"; |
| 245 break; |
| 246 } |
| 247 |
| 248 out << " Bypass list: "; |
| 249 if (config.proxy_bypass.empty()) { |
| 250 out << "[None]\n"; |
| 251 } else { |
| 252 out << "\n"; |
| 220 std::vector<std::string>::const_iterator it; | 253 std::vector<std::string>::const_iterator it; |
| 221 for (it = config.proxy_bypass.begin(); | 254 for (it = config.proxy_bypass.begin(); |
| 222 it != config.proxy_bypass.end(); ++it) { | 255 it != config.proxy_bypass.end(); ++it) { |
| 223 out << " " << *it << "\n"; | 256 out << " " << *it << "\n"; |
| 224 } | 257 } |
| 225 out << " }\n"; | |
| 226 } | 258 } |
| 227 | 259 |
| 228 out << " id: " << config.id() << "\n" | 260 out << " Bypass local names: " |
| 229 << "}"; | 261 << BoolToYesNoString(config.proxy_bypass_local_names); |
| 230 return out; | 262 return out; |
| 231 } | 263 } |
| OLD | NEW |