| 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_resolver_winhttp.h" | 5 #include "net/proxy/proxy_resolver_winhttp.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <winhttp.h> | 8 #include <winhttp.h> |
| 9 | 9 |
| 10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // If we have been given an empty PAC url, then use auto-detection. | 63 // If we have been given an empty PAC url, then use auto-detection. |
| 64 // | 64 // |
| 65 // NOTE: We just use DNS-based auto-detection here like Firefox. We do this | 65 // NOTE: We just use DNS-based auto-detection here like Firefox. We do this |
| 66 // to avoid WinHTTP's auto-detection code, which while more featureful (it | 66 // to avoid WinHTTP's auto-detection code, which while more featureful (it |
| 67 // supports DHCP based auto-detection) also appears to have issues. | 67 // supports DHCP based auto-detection) also appears to have issues. |
| 68 // | 68 // |
| 69 WINHTTP_AUTOPROXY_OPTIONS options = {0}; | 69 WINHTTP_AUTOPROXY_OPTIONS options = {0}; |
| 70 options.fAutoLogonIfChallenged = FALSE; | 70 options.fAutoLogonIfChallenged = FALSE; |
| 71 options.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL; | 71 options.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL; |
| 72 std::wstring pac_url_wide = ASCIIToWide(pac_url_.spec()); | 72 std::wstring pac_url_wide = ASCIIToWide(pac_url_.spec()); |
| 73 options.lpszAutoConfigUrl = | 73 options.lpszAutoConfigUrl = pac_url_wide.c_str(); |
| 74 pac_url_wide.empty() ? L"http://wpad/wpad.dat" : pac_url_wide.c_str(); | |
| 75 | 74 |
| 76 WINHTTP_PROXY_INFO info = {0}; | 75 WINHTTP_PROXY_INFO info = {0}; |
| 77 DCHECK(session_handle_); | 76 DCHECK(session_handle_); |
| 78 | 77 |
| 79 // Per http://msdn.microsoft.com/en-us/library/aa383153(VS.85).aspx, it is | 78 // Per http://msdn.microsoft.com/en-us/library/aa383153(VS.85).aspx, it is |
| 80 // necessary to first try resolving with fAutoLogonIfChallenged set to false. | 79 // necessary to first try resolving with fAutoLogonIfChallenged set to false. |
| 81 // Otherwise, we fail over to trying it with a value of true. This way we | 80 // Otherwise, we fail over to trying it with a value of true. This way we |
| 82 // get good performance in the case where WinHTTP uses an out-of-process | 81 // get good performance in the case where WinHTTP uses an out-of-process |
| 83 // resolver. This is important for Vista and Win2k3. | 82 // resolver. This is important for Vista and Win2k3. |
| 84 BOOL ok = CallWinHttpGetProxyForUrl( | 83 BOOL ok = CallWinHttpGetProxyForUrl( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 132 |
| 134 FreeInfo(&info); | 133 FreeInfo(&info); |
| 135 return rv; | 134 return rv; |
| 136 } | 135 } |
| 137 | 136 |
| 138 void ProxyResolverWinHttp::CancelRequest(RequestHandle request) { | 137 void ProxyResolverWinHttp::CancelRequest(RequestHandle request) { |
| 139 // This is a synchronous ProxyResolver; no possibility for async requests. | 138 // This is a synchronous ProxyResolver; no possibility for async requests. |
| 140 NOTREACHED(); | 139 NOTREACHED(); |
| 141 } | 140 } |
| 142 | 141 |
| 143 void ProxyResolverWinHttp::SetPacScriptByUrlInternal(const GURL& pac_url) { | 142 int ProxyResolverWinHttp::SetPacScript(const GURL& pac_url, |
| 144 pac_url_ = pac_url; | 143 const std::string& /*pac_bytes*/, |
| 144 CompletionCallback* /*callback*/) { |
| 145 pac_url_ = pac_url.is_valid() ? pac_url : GURL("http://wpad/wpad.dat"); |
| 146 return OK; |
| 145 } | 147 } |
| 146 | 148 |
| 147 bool ProxyResolverWinHttp::OpenWinHttpSession() { | 149 bool ProxyResolverWinHttp::OpenWinHttpSession() { |
| 148 DCHECK(!session_handle_); | 150 DCHECK(!session_handle_); |
| 149 session_handle_ = WinHttpOpen(NULL, | 151 session_handle_ = WinHttpOpen(NULL, |
| 150 WINHTTP_ACCESS_TYPE_NO_PROXY, | 152 WINHTTP_ACCESS_TYPE_NO_PROXY, |
| 151 WINHTTP_NO_PROXY_NAME, | 153 WINHTTP_NO_PROXY_NAME, |
| 152 WINHTTP_NO_PROXY_BYPASS, | 154 WINHTTP_NO_PROXY_BYPASS, |
| 153 0); | 155 0); |
| 154 if (!session_handle_) | 156 if (!session_handle_) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 165 } | 167 } |
| 166 | 168 |
| 167 void ProxyResolverWinHttp::CloseWinHttpSession() { | 169 void ProxyResolverWinHttp::CloseWinHttpSession() { |
| 168 if (session_handle_) { | 170 if (session_handle_) { |
| 169 WinHttpCloseHandle(session_handle_); | 171 WinHttpCloseHandle(session_handle_); |
| 170 session_handle_ = NULL; | 172 session_handle_ = NULL; |
| 171 } | 173 } |
| 172 } | 174 } |
| 173 | 175 |
| 174 } // namespace net | 176 } // namespace net |
| OLD | NEW |