OLD | NEW |
1 // Copyright (c) 2011 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_resolver_mac.h" | 5 #include "net/proxy/proxy_resolver_mac.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 class ProxyResolverMac : public ProxyResolver { | 184 class ProxyResolverMac : public ProxyResolver { |
185 public: | 185 public: |
186 explicit ProxyResolverMac( | 186 explicit ProxyResolverMac( |
187 const scoped_refptr<ProxyResolverScriptData>& script_data); | 187 const scoped_refptr<ProxyResolverScriptData>& script_data); |
188 ~ProxyResolverMac() override; | 188 ~ProxyResolverMac() override; |
189 | 189 |
190 // ProxyResolver methods: | 190 // ProxyResolver methods: |
191 int GetProxyForURL(const GURL& url, | 191 int GetProxyForURL(const GURL& url, |
192 ProxyInfo* results, | 192 ProxyInfo* results, |
193 const CompletionCallback& callback, | 193 const CompletionCallback& callback, |
194 RequestHandle* request, | 194 std::unique_ptr<Request>* request, |
195 const NetLogWithSource& net_log) override; | 195 const NetLogWithSource& net_log) override; |
196 | 196 |
197 void CancelRequest(RequestHandle request) override; | |
198 | |
199 LoadState GetLoadState(RequestHandle request) const override; | |
200 | |
201 private: | 197 private: |
202 const scoped_refptr<ProxyResolverScriptData> script_data_; | 198 const scoped_refptr<ProxyResolverScriptData> script_data_; |
203 }; | 199 }; |
204 | 200 |
205 ProxyResolverMac::ProxyResolverMac( | 201 ProxyResolverMac::ProxyResolverMac( |
206 const scoped_refptr<ProxyResolverScriptData>& script_data) | 202 const scoped_refptr<ProxyResolverScriptData>& script_data) |
207 : script_data_(script_data) { | 203 : script_data_(script_data) { |
208 } | 204 } |
209 | 205 |
210 ProxyResolverMac::~ProxyResolverMac() {} | 206 ProxyResolverMac::~ProxyResolverMac() {} |
211 | 207 |
212 // Gets the proxy information for a query URL from a PAC. Implementation | 208 // Gets the proxy information for a query URL from a PAC. Implementation |
213 // inspired by http://developer.apple.com/samplecode/CFProxySupportTool/ | 209 // inspired by http://developer.apple.com/samplecode/CFProxySupportTool/ |
214 int ProxyResolverMac::GetProxyForURL(const GURL& query_url, | 210 int ProxyResolverMac::GetProxyForURL(const GURL& query_url, |
215 ProxyInfo* results, | 211 ProxyInfo* results, |
216 const CompletionCallback& /*callback*/, | 212 const CompletionCallback& /*callback*/, |
217 RequestHandle* /*request*/, | 213 std::unique_ptr<Request>* /*request*/, |
218 const NetLogWithSource& net_log) { | 214 const NetLogWithSource& net_log) { |
219 base::ScopedCFTypeRef<CFStringRef> query_ref( | 215 base::ScopedCFTypeRef<CFStringRef> query_ref( |
220 base::SysUTF8ToCFStringRef(query_url.spec())); | 216 base::SysUTF8ToCFStringRef(query_url.spec())); |
221 base::ScopedCFTypeRef<CFURLRef> query_url_ref( | 217 base::ScopedCFTypeRef<CFURLRef> query_url_ref( |
222 CFURLCreateWithString(kCFAllocatorDefault, query_ref.get(), NULL)); | 218 CFURLCreateWithString(kCFAllocatorDefault, query_ref.get(), NULL)); |
223 if (!query_url_ref.get()) | 219 if (!query_url_ref.get()) |
224 return ERR_FAILED; | 220 return ERR_FAILED; |
225 base::ScopedCFTypeRef<CFStringRef> pac_ref(base::SysUTF8ToCFStringRef( | 221 base::ScopedCFTypeRef<CFStringRef> pac_ref(base::SysUTF8ToCFStringRef( |
226 script_data_->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT | 222 script_data_->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT |
227 ? std::string() | 223 ? std::string() |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 proxy_uri_list += proxy_server.ToURI(); | 331 proxy_uri_list += proxy_server.ToURI(); |
336 } | 332 } |
337 | 333 |
338 if (!proxy_uri_list.empty()) | 334 if (!proxy_uri_list.empty()) |
339 results->UseNamedProxy(proxy_uri_list); | 335 results->UseNamedProxy(proxy_uri_list); |
340 // Else do nothing (results is already guaranteed to be in the default state). | 336 // Else do nothing (results is already guaranteed to be in the default state). |
341 | 337 |
342 return OK; | 338 return OK; |
343 } | 339 } |
344 | 340 |
345 void ProxyResolverMac::CancelRequest(RequestHandle request) { | |
346 NOTREACHED(); | |
347 } | |
348 | |
349 LoadState ProxyResolverMac::GetLoadState(RequestHandle request) const { | |
350 NOTREACHED(); | |
351 return LOAD_STATE_IDLE; | |
352 } | |
353 | |
354 } // namespace | 341 } // namespace |
355 | 342 |
356 ProxyResolverFactoryMac::ProxyResolverFactoryMac() | 343 ProxyResolverFactoryMac::ProxyResolverFactoryMac() |
357 : ProxyResolverFactory(false /*expects_pac_bytes*/) { | 344 : ProxyResolverFactory(false /*expects_pac_bytes*/) { |
358 } | 345 } |
359 | 346 |
360 int ProxyResolverFactoryMac::CreateProxyResolver( | 347 int ProxyResolverFactoryMac::CreateProxyResolver( |
361 const scoped_refptr<ProxyResolverScriptData>& pac_script, | 348 const scoped_refptr<ProxyResolverScriptData>& pac_script, |
362 std::unique_ptr<ProxyResolver>* resolver, | 349 std::unique_ptr<ProxyResolver>* resolver, |
363 const CompletionCallback& callback, | 350 const CompletionCallback& callback, |
364 std::unique_ptr<Request>* request) { | 351 std::unique_ptr<Request>* request) { |
365 resolver->reset(new ProxyResolverMac(pac_script)); | 352 resolver->reset(new ProxyResolverMac(pac_script)); |
366 return OK; | 353 return OK; |
367 } | 354 } |
368 | 355 |
369 } // namespace net | 356 } // namespace net |
OLD | NEW |