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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 class ProxyResolverMac : public ProxyResolver { | 66 class ProxyResolverMac : public ProxyResolver { |
67 public: | 67 public: |
68 explicit ProxyResolverMac( | 68 explicit ProxyResolverMac( |
69 const scoped_refptr<ProxyResolverScriptData>& script_data); | 69 const scoped_refptr<ProxyResolverScriptData>& script_data); |
70 ~ProxyResolverMac() override; | 70 ~ProxyResolverMac() override; |
71 | 71 |
72 // ProxyResolver methods: | 72 // ProxyResolver methods: |
73 int GetProxyForURL(const GURL& url, | 73 int GetProxyForURL(const GURL& url, |
74 ProxyInfo* results, | 74 ProxyInfo* results, |
75 const CompletionCallback& callback, | 75 const CompletionCallback& callback, |
76 scoped_ptr<Request>* request, | 76 RequestHandle* request, |
77 const BoundNetLog& net_log) override; | 77 const BoundNetLog& net_log) override; |
78 | 78 |
| 79 void CancelRequest(RequestHandle request) override; |
| 80 |
| 81 LoadState GetLoadState(RequestHandle request) const override; |
| 82 |
79 private: | 83 private: |
80 const scoped_refptr<ProxyResolverScriptData> script_data_; | 84 const scoped_refptr<ProxyResolverScriptData> script_data_; |
81 }; | 85 }; |
82 | 86 |
83 ProxyResolverMac::ProxyResolverMac( | 87 ProxyResolverMac::ProxyResolverMac( |
84 const scoped_refptr<ProxyResolverScriptData>& script_data) | 88 const scoped_refptr<ProxyResolverScriptData>& script_data) |
85 : script_data_(script_data) { | 89 : script_data_(script_data) { |
86 } | 90 } |
87 | 91 |
88 ProxyResolverMac::~ProxyResolverMac() {} | 92 ProxyResolverMac::~ProxyResolverMac() {} |
89 | 93 |
90 // Gets the proxy information for a query URL from a PAC. Implementation | 94 // Gets the proxy information for a query URL from a PAC. Implementation |
91 // inspired by http://developer.apple.com/samplecode/CFProxySupportTool/ | 95 // inspired by http://developer.apple.com/samplecode/CFProxySupportTool/ |
92 int ProxyResolverMac::GetProxyForURL(const GURL& query_url, | 96 int ProxyResolverMac::GetProxyForURL(const GURL& query_url, |
93 ProxyInfo* results, | 97 ProxyInfo* results, |
94 const CompletionCallback& /*callback*/, | 98 const CompletionCallback& /*callback*/, |
95 scoped_ptr<Request>* /*request*/, | 99 RequestHandle* /*request*/, |
96 const BoundNetLog& net_log) { | 100 const BoundNetLog& net_log) { |
97 base::ScopedCFTypeRef<CFStringRef> query_ref( | 101 base::ScopedCFTypeRef<CFStringRef> query_ref( |
98 base::SysUTF8ToCFStringRef(query_url.spec())); | 102 base::SysUTF8ToCFStringRef(query_url.spec())); |
99 base::ScopedCFTypeRef<CFURLRef> query_url_ref( | 103 base::ScopedCFTypeRef<CFURLRef> query_url_ref( |
100 CFURLCreateWithString(kCFAllocatorDefault, query_ref.get(), NULL)); | 104 CFURLCreateWithString(kCFAllocatorDefault, query_ref.get(), NULL)); |
101 if (!query_url_ref.get()) | 105 if (!query_url_ref.get()) |
102 return ERR_FAILED; | 106 return ERR_FAILED; |
103 base::ScopedCFTypeRef<CFStringRef> pac_ref(base::SysUTF8ToCFStringRef( | 107 base::ScopedCFTypeRef<CFStringRef> pac_ref(base::SysUTF8ToCFStringRef( |
104 script_data_->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT | 108 script_data_->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT |
105 ? std::string() | 109 ? std::string() |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 proxy_uri_list += proxy_server.ToURI(); | 196 proxy_uri_list += proxy_server.ToURI(); |
193 } | 197 } |
194 | 198 |
195 if (!proxy_uri_list.empty()) | 199 if (!proxy_uri_list.empty()) |
196 results->UseNamedProxy(proxy_uri_list); | 200 results->UseNamedProxy(proxy_uri_list); |
197 // Else do nothing (results is already guaranteed to be in the default state). | 201 // Else do nothing (results is already guaranteed to be in the default state). |
198 | 202 |
199 return OK; | 203 return OK; |
200 } | 204 } |
201 | 205 |
| 206 void ProxyResolverMac::CancelRequest(RequestHandle request) { |
| 207 NOTREACHED(); |
| 208 } |
| 209 |
| 210 LoadState ProxyResolverMac::GetLoadState(RequestHandle request) const { |
| 211 NOTREACHED(); |
| 212 return LOAD_STATE_IDLE; |
| 213 } |
| 214 |
202 } // namespace | 215 } // namespace |
203 | 216 |
204 ProxyResolverFactoryMac::ProxyResolverFactoryMac() | 217 ProxyResolverFactoryMac::ProxyResolverFactoryMac() |
205 : ProxyResolverFactory(false /*expects_pac_bytes*/) { | 218 : ProxyResolverFactory(false /*expects_pac_bytes*/) { |
206 } | 219 } |
207 | 220 |
208 int ProxyResolverFactoryMac::CreateProxyResolver( | 221 int ProxyResolverFactoryMac::CreateProxyResolver( |
209 const scoped_refptr<ProxyResolverScriptData>& pac_script, | 222 const scoped_refptr<ProxyResolverScriptData>& pac_script, |
210 scoped_ptr<ProxyResolver>* resolver, | 223 scoped_ptr<ProxyResolver>* resolver, |
211 const CompletionCallback& callback, | 224 const CompletionCallback& callback, |
212 scoped_ptr<Request>* request) { | 225 scoped_ptr<Request>* request) { |
213 resolver->reset(new ProxyResolverMac(pac_script)); | 226 resolver->reset(new ProxyResolverMac(pac_script)); |
214 return OK; | 227 return OK; |
215 } | 228 } |
216 | 229 |
217 } // namespace net | 230 } // namespace net |
OLD | NEW |