| 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_request_interceptor.h" | 11 #include "android_webview/browser/aw_request_interceptor.h" |
| 11 #include "android_webview/browser/net/aw_network_delegate.h" | 12 #include "android_webview/browser/net/aw_network_delegate.h" |
| 12 #include "android_webview/browser/net/aw_url_request_job_factory.h" | 13 #include "android_webview/browser/net/aw_url_request_job_factory.h" |
| 13 #include "android_webview/browser/net/init_native_callback.h" | 14 #include "android_webview/browser/net/init_native_callback.h" |
| 14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/content_browser_client.h" | 16 #include "content/public/browser/content_browser_client.h" |
| 16 #include "content/public/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
| 17 #include "content/public/common/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
| 18 #include "net/cookies/cookie_store.h" | 19 #include "net/cookies/cookie_store.h" |
| 19 #include "net/http/http_cache.h" | 20 #include "net/http/http_cache.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 void AwURLRequestContextGetter::Init() { | 50 void AwURLRequestContextGetter::Init() { |
| 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 51 | 52 |
| 52 net::URLRequestContextBuilder builder; | 53 net::URLRequestContextBuilder builder; |
| 53 builder.set_user_agent(content::GetUserAgent(GURL())); | 54 builder.set_user_agent(content::GetUserAgent(GURL())); |
| 54 builder.set_network_delegate(new AwNetworkDelegate()); | 55 builder.set_network_delegate(new AwNetworkDelegate()); |
| 55 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. | 56 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. |
| 56 builder.set_proxy_config_service(proxy_config_service_.release()); | 57 builder.set_proxy_config_service(proxy_config_service_.release()); |
| 57 builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader( | 58 builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader( |
| 58 content::GetContentClient()->browser()->GetAcceptLangs( | 59 AwContentBrowserClient::GetAcceptLangsImpl())); |
| 59 browser_context_))); | |
| 60 | 60 |
| 61 url_request_context_.reset(builder.Build()); | 61 url_request_context_.reset(builder.Build()); |
| 62 | 62 |
| 63 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | 63 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. |
| 64 net::HttpNetworkSession::Params network_session_params; | 64 net::HttpNetworkSession::Params network_session_params; |
| 65 PopulateNetworkSessionParams(&network_session_params); | 65 PopulateNetworkSessionParams(&network_session_params); |
| 66 net::HttpCache* main_cache = new net::HttpCache( | 66 net::HttpCache* main_cache = new net::HttpCache( |
| 67 network_session_params, | 67 network_session_params, |
| 68 new net::HttpCache::DefaultBackend( | 68 new net::HttpCache::DefaultBackend( |
| 69 net::DISK_CACHE, | 69 net::DISK_CACHE, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 AwURLRequestContextGetter::GetNetworkTaskRunner() const { | 166 AwURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 167 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 167 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void AwURLRequestContextGetter::SetProtocolHandlers( | 170 void AwURLRequestContextGetter::SetProtocolHandlers( |
| 171 content::ProtocolHandlerMap* protocol_handlers) { | 171 content::ProtocolHandlerMap* protocol_handlers) { |
| 172 std::swap(protocol_handlers_, *protocol_handlers); | 172 std::swap(protocol_handlers_, *protocol_handlers); |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace android_webview | 175 } // namespace android_webview |
| OLD | NEW |