Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: net/proxy/proxy_config_service_win.cc

Issue 6597070: Allow ProxyConfigService to report "no configuration set" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 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 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_service_win.h" 5 #include "net/proxy/proxy_config_service_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <winhttp.h> 8 #include <winhttp.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 // Keep watching the registry key. 147 // Keep watching the registry key.
148 if (!(*it)->StartWatching(this)) 148 if (!(*it)->StartWatching(this))
149 keys_to_watch_.erase(it); 149 keys_to_watch_.erase(it);
150 150
151 // Have the PollingProxyConfigService test for changes. 151 // Have the PollingProxyConfigService test for changes.
152 CheckForChangesNow(); 152 CheckForChangesNow();
153 } 153 }
154 154
155 // static 155 // static
156 void ProxyConfigServiceWin::GetCurrentProxyConfig(ProxyConfig* config) { 156 ProxyConfigService::ConfigAvailability
157 ProxyConfigServiceWin::GetCurrentProxyConfig(ProxyConfig* config) {
157 WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ie_config = {0}; 158 WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ie_config = {0};
158 if (!WinHttpGetIEProxyConfigForCurrentUser(&ie_config)) { 159 if (!WinHttpGetIEProxyConfigForCurrentUser(&ie_config)) {
159 LOG(ERROR) << "WinHttpGetIEProxyConfigForCurrentUser failed: " << 160 LOG(ERROR) << "WinHttpGetIEProxyConfigForCurrentUser failed: " <<
160 GetLastError(); 161 GetLastError();
161 *config = ProxyConfig::CreateDirect(); 162 *config = ProxyConfig::CreateDirect();
162 return; 163 return CONFIG_UNSET;
eroman 2011/03/16 01:30:00 See my previous comment -- i don't think we should
Mattias Nissler (ping if slow) 2011/03/16 17:40:00 Done.
163 } 164 }
164 SetFromIEConfig(config, ie_config); 165 SetFromIEConfig(config, ie_config);
165 FreeIEConfig(&ie_config); 166 FreeIEConfig(&ie_config);
167 return CONFIG_VALID;
166 } 168 }
167 169
168 // static 170 // static
169 void ProxyConfigServiceWin::SetFromIEConfig( 171 void ProxyConfigServiceWin::SetFromIEConfig(
170 ProxyConfig* config, 172 ProxyConfig* config,
171 const WINHTTP_CURRENT_USER_IE_PROXY_CONFIG& ie_config) { 173 const WINHTTP_CURRENT_USER_IE_PROXY_CONFIG& ie_config) {
172 if (ie_config.fAutoDetect) 174 if (ie_config.fAutoDetect)
173 config->set_auto_detect(true); 175 config->set_auto_detect(true);
174 if (ie_config.lpszProxy) { 176 if (ie_config.lpszProxy) {
175 // lpszProxy may be a single proxy, or a proxy per scheme. The format 177 // lpszProxy may be a single proxy, or a proxy per scheme. The format
176 // is compatible with ProxyConfig::ProxyRules's string format. 178 // is compatible with ProxyConfig::ProxyRules's string format.
177 config->proxy_rules().ParseFromString(WideToASCII(ie_config.lpszProxy)); 179 config->proxy_rules().ParseFromString(WideToASCII(ie_config.lpszProxy));
178 } 180 }
179 if (ie_config.lpszProxyBypass) { 181 if (ie_config.lpszProxyBypass) {
180 std::string proxy_bypass = WideToASCII(ie_config.lpszProxyBypass); 182 std::string proxy_bypass = WideToASCII(ie_config.lpszProxyBypass);
181 183
182 StringTokenizer proxy_server_bypass_list(proxy_bypass, "; \t\n\r"); 184 StringTokenizer proxy_server_bypass_list(proxy_bypass, "; \t\n\r");
183 while (proxy_server_bypass_list.GetNext()) { 185 while (proxy_server_bypass_list.GetNext()) {
184 std::string bypass_url_domain = proxy_server_bypass_list.token(); 186 std::string bypass_url_domain = proxy_server_bypass_list.token();
185 config->proxy_rules().bypass_rules.AddRuleFromString(bypass_url_domain); 187 config->proxy_rules().bypass_rules.AddRuleFromString(bypass_url_domain);
186 } 188 }
187 } 189 }
188 if (ie_config.lpszAutoConfigUrl) 190 if (ie_config.lpszAutoConfigUrl)
189 config->set_pac_url(GURL(ie_config.lpszAutoConfigUrl)); 191 config->set_pac_url(GURL(ie_config.lpszAutoConfigUrl));
190 } 192 }
191 193
192 } // namespace net 194 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698