| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "android_webview/browser/net/aw_url_request_context_getter.h" | 5 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" |
| 10 #include "android_webview/browser/aw_content_browser_client.h" | 10 #include "android_webview/browser/aw_content_browser_client.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "content/public/common/url_constants.h" | 27 #include "content/public/common/url_constants.h" |
| 28 #include "net/base/cache_type.h" | 28 #include "net/base/cache_type.h" |
| 29 #include "net/cookies/cookie_store.h" | 29 #include "net/cookies/cookie_store.h" |
| 30 #include "net/dns/mapped_host_resolver.h" | 30 #include "net/dns/mapped_host_resolver.h" |
| 31 #include "net/http/http_cache.h" | 31 #include "net/http/http_cache.h" |
| 32 #include "net/http/http_stream_factory.h" | 32 #include "net/http/http_stream_factory.h" |
| 33 #include "net/proxy/proxy_service.h" | 33 #include "net/proxy/proxy_service.h" |
| 34 #include "net/socket/next_proto.h" | 34 #include "net/socket/next_proto.h" |
| 35 #include "net/url_request/data_protocol_handler.h" | 35 #include "net/url_request/data_protocol_handler.h" |
| 36 #include "net/url_request/file_protocol_handler.h" | 36 #include "net/url_request/file_protocol_handler.h" |
| 37 #include "net/url_request/protocol_intercept_job_factory.h" | |
| 38 #include "net/url_request/url_request_context_builder.h" | 37 #include "net/url_request/url_request_context_builder.h" |
| 39 #include "net/url_request/url_request_context.h" | 38 #include "net/url_request/url_request_context.h" |
| 39 #include "net/url_request/url_request_intercepting_job_factory.h" |
| 40 #include "net/url_request/url_request_interceptor.h" |
| 40 | 41 |
| 41 using content::BrowserThread; | 42 using content::BrowserThread; |
| 42 using data_reduction_proxy::DataReductionProxySettings; | 43 using data_reduction_proxy::DataReductionProxySettings; |
| 43 | 44 |
| 44 namespace android_webview { | 45 namespace android_webview { |
| 45 | 46 |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| 48 | 49 |
| 49 void ApplyCmdlineOverridesToURLRequestContextBuilder( | 50 void ApplyCmdlineOverridesToURLRequestContextBuilder( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 (*protocol_handlers)[content::kChromeUIScheme].release()); | 126 (*protocol_handlers)[content::kChromeUIScheme].release()); |
| 126 DCHECK(set_protocol); | 127 DCHECK(set_protocol); |
| 127 set_protocol = aw_job_factory->SetProtocolHandler( | 128 set_protocol = aw_job_factory->SetProtocolHandler( |
| 128 content::kChromeDevToolsScheme, | 129 content::kChromeDevToolsScheme, |
| 129 (*protocol_handlers)[content::kChromeDevToolsScheme].release()); | 130 (*protocol_handlers)[content::kChromeDevToolsScheme].release()); |
| 130 DCHECK(set_protocol); | 131 DCHECK(set_protocol); |
| 131 protocol_handlers->clear(); | 132 protocol_handlers->clear(); |
| 132 | 133 |
| 133 // Create a chain of URLRequestJobFactories. The handlers will be invoked | 134 // Create a chain of URLRequestJobFactories. The handlers will be invoked |
| 134 // in the order in which they appear in the protocol_handlers vector. | 135 // in the order in which they appear in the protocol_handlers vector. |
| 135 typedef std::vector<net::URLRequestJobFactory::ProtocolHandler*> | 136 typedef std::vector<net::URLRequestInterceptor*> |
| 136 ProtocolHandlerVector; | 137 URLRequestInterceptorVector; |
| 137 ProtocolHandlerVector protocol_interceptors; | 138 URLRequestInterceptorVector request_interceptors; |
| 138 | 139 |
| 139 // Note that even though the content:// scheme handler is created here, | 140 // Note that even though the content:// scheme handler is created here, |
| 140 // it cannot be used by child processes until access to it is granted via | 141 // it cannot be used by child processes until access to it is granted via |
| 141 // ChildProcessSecurityPolicy::GrantScheme(). This is done in | 142 // ChildProcessSecurityPolicy::GrantScheme(). This is done in |
| 142 // AwContentBrowserClient. | 143 // AwContentBrowserClient. |
| 143 protocol_interceptors.push_back( | 144 request_interceptors.push_back( |
| 144 CreateAndroidContentProtocolHandler().release()); | 145 CreateAndroidContentRequestInterceptor().release()); |
| 145 protocol_interceptors.push_back( | 146 request_interceptors.push_back( |
| 146 CreateAndroidAssetFileProtocolHandler().release()); | 147 CreateAndroidAssetFileRequestInterceptor().release()); |
| 147 // The AwRequestInterceptor must come after the content and asset file job | 148 // The AwRequestInterceptor must come after the content and asset file job |
| 148 // factories. This for WebViewClassic compatibility where it was not | 149 // factories. This for WebViewClassic compatibility where it was not |
| 149 // possible to intercept resource loads to resolvable content:// and | 150 // possible to intercept resource loads to resolvable content:// and |
| 150 // file:// URIs. | 151 // file:// URIs. |
| 151 // This logical dependency is also the reason why the Content | 152 // This logical dependency is also the reason why the Content |
| 152 // ProtocolHandler has to be added as a ProtocolInterceptJobFactory rather | 153 // URLRequestInterceptor has to be added as an interceptor rather than as a |
| 153 // than via SetProtocolHandler. | 154 // ProtocolHandler. |
| 154 protocol_interceptors.push_back(new AwRequestInterceptor()); | 155 request_interceptors.push_back(new AwRequestInterceptor()); |
| 155 | 156 |
| 156 // The chain of responsibility will execute the handlers in reverse to the | 157 // The chain of responsibility will execute the handlers in reverse to the |
| 157 // order in which the elements of the chain are created. | 158 // order in which the elements of the chain are created. |
| 158 scoped_ptr<net::URLRequestJobFactory> job_factory(aw_job_factory.Pass()); | 159 scoped_ptr<net::URLRequestJobFactory> job_factory(aw_job_factory.Pass()); |
| 159 for (ProtocolHandlerVector::reverse_iterator | 160 for (URLRequestInterceptorVector::reverse_iterator |
| 160 i = protocol_interceptors.rbegin(); | 161 i = request_interceptors.rbegin(); |
| 161 i != protocol_interceptors.rend(); | 162 i != request_interceptors.rend(); |
| 162 ++i) { | 163 ++i) { |
| 163 job_factory.reset(new net::ProtocolInterceptJobFactory( | 164 job_factory.reset(new net::URLRequestInterceptingJobFactory( |
| 164 job_factory.Pass(), make_scoped_ptr(*i))); | 165 job_factory.Pass(), make_scoped_ptr(*i))); |
| 165 } | 166 } |
| 166 | 167 |
| 167 return job_factory.Pass(); | 168 return job_factory.Pass(); |
| 168 } | 169 } |
| 169 | 170 |
| 170 } // namespace | 171 } // namespace |
| 171 | 172 |
| 172 AwURLRequestContextGetter::AwURLRequestContextGetter( | 173 AwURLRequestContextGetter::AwURLRequestContextGetter( |
| 173 const base::FilePath& partition_path, net::CookieStore* cookie_store) | 174 const base::FilePath& partition_path, net::CookieStore* cookie_store) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 std::swap(protocol_handlers_, *protocol_handlers); | 262 std::swap(protocol_handlers_, *protocol_handlers); |
| 262 } | 263 } |
| 263 | 264 |
| 264 DataReductionProxyConfigService* | 265 DataReductionProxyConfigService* |
| 265 AwURLRequestContextGetter::proxy_config_service() { | 266 AwURLRequestContextGetter::proxy_config_service() { |
| 266 // TODO(bengr): return system config if data reduction proxy is disabled. | 267 // TODO(bengr): return system config if data reduction proxy is disabled. |
| 267 return proxy_config_service_.get(); | 268 return proxy_config_service_.get(); |
| 268 } | 269 } |
| 269 | 270 |
| 270 } // namespace android_webview | 271 } // namespace android_webview |
| OLD | NEW |