| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 builder.set_user_agent(GetUserAgent()); | 193 builder.set_user_agent(GetUserAgent()); |
| 194 builder.set_network_delegate(new AwNetworkDelegate()); | 194 builder.set_network_delegate(new AwNetworkDelegate()); |
| 195 #if !defined(DISABLE_FTP_SUPPORT) | 195 #if !defined(DISABLE_FTP_SUPPORT) |
| 196 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. | 196 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. |
| 197 #endif | 197 #endif |
| 198 builder.set_proxy_config_service(proxy_config_service_.release()); | 198 builder.set_proxy_config_service(proxy_config_service_.release()); |
| 199 builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader( | 199 builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader( |
| 200 AwContentBrowserClient::GetAcceptLangsImpl())); | 200 AwContentBrowserClient::GetAcceptLangsImpl())); |
| 201 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); | 201 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); |
| 202 | 202 |
| 203 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 203 |
| 204 data_reduction_proxy::DataReductionProxyParams drp_params( | |
| 205 data_reduction_proxy::DataReductionProxyParams::kAllowed); | |
| 206 builder.add_http_auth_handler_factory( | 204 builder.add_http_auth_handler_factory( |
| 207 data_reduction_proxy::HttpAuthHandlerDataReductionProxy::Scheme(), | 205 data_reduction_proxy::HttpAuthHandlerDataReductionProxy::Scheme(), |
| 208 new data_reduction_proxy::HttpAuthHandlerDataReductionProxy::Factory( | 206 new data_reduction_proxy::HttpAuthHandlerDataReductionProxy::Factory( |
| 209 drp_params.GetAllowedProxies())); | 207 DataReductionProxySettings::GetDataReductionProxies())); |
| 210 #endif | |
| 211 | 208 |
| 212 url_request_context_.reset(builder.Build()); | 209 url_request_context_.reset(builder.Build()); |
| 213 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | 210 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. |
| 214 net::HttpNetworkSession::Params network_session_params; | 211 net::HttpNetworkSession::Params network_session_params; |
| 215 | 212 |
| 216 PopulateNetworkSessionParams(url_request_context_.get(), | 213 PopulateNetworkSessionParams(url_request_context_.get(), |
| 217 &network_session_params); | 214 &network_session_params); |
| 218 | 215 |
| 219 net::HttpCache* main_cache = new net::HttpCache( | 216 net::HttpCache* main_cache = new net::HttpCache( |
| 220 network_session_params, | 217 network_session_params, |
| 221 new net::HttpCache::DefaultBackend( | 218 new net::HttpCache::DefaultBackend( |
| 222 net::DISK_CACHE, | 219 net::DISK_CACHE, |
| 223 net::CACHE_BACKEND_SIMPLE, | 220 net::CACHE_BACKEND_SIMPLE, |
| 224 partition_path_.Append(FILE_PATH_LITERAL("Cache")), | 221 partition_path_.Append(FILE_PATH_LITERAL("Cache")), |
| 225 20 * 1024 * 1024, // 20M | 222 20 * 1024 * 1024, // 20M |
| 226 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 223 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
| 227 | 224 |
| 228 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 229 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | 225 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); |
| 230 DCHECK(browser_context); | 226 DCHECK(browser_context); |
| 231 DataReductionProxySettings* drp_settings = | 227 DataReductionProxySettings* drp_settings = |
| 232 browser_context->GetDataReductionProxySettings(); | 228 browser_context->GetDataReductionProxySettings(); |
| 233 if (drp_settings) { | 229 DCHECK(drp_settings); |
| 234 std::string drp_key = drp_settings->params()->key(); | 230 std::string drp_key = drp_settings->key(); |
| 235 // Only precache credentials if a key is available at URLRequestContext | 231 // Only precache credentials if a key is available at URLRequestContext |
| 236 // initialization. | 232 // initialization. |
| 237 if (!drp_key.empty()) { | 233 if (!drp_key.empty()) { |
| 238 DataReductionProxySettings::InitDataReductionProxySession( | 234 DataReductionProxySettings::InitDataReductionProxySession( |
| 239 main_cache->GetSession(), &drp_params); | 235 main_cache->GetSession(), drp_settings->key()); |
| 240 } | |
| 241 } | 236 } |
| 242 #endif | |
| 243 | 237 |
| 244 main_http_factory_.reset(main_cache); | 238 main_http_factory_.reset(main_cache); |
| 245 url_request_context_->set_http_transaction_factory(main_cache); | 239 url_request_context_->set_http_transaction_factory(main_cache); |
| 246 url_request_context_->set_cookie_store(cookie_store_); | 240 url_request_context_->set_cookie_store(cookie_store_); |
| 247 | 241 |
| 248 job_factory_ = CreateJobFactory(&protocol_handlers_); | 242 job_factory_ = CreateJobFactory(&protocol_handlers_); |
| 249 url_request_context_->set_job_factory(job_factory_.get()); | 243 url_request_context_->set_job_factory(job_factory_.get()); |
| 250 } | 244 } |
| 251 | 245 |
| 252 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { | 246 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 267 std::swap(protocol_handlers_, *protocol_handlers); | 261 std::swap(protocol_handlers_, *protocol_handlers); |
| 268 } | 262 } |
| 269 | 263 |
| 270 DataReductionProxyConfigService* | 264 DataReductionProxyConfigService* |
| 271 AwURLRequestContextGetter::proxy_config_service() { | 265 AwURLRequestContextGetter::proxy_config_service() { |
| 272 // TODO(bengr): return system config if data reduction proxy is disabled. | 266 // TODO(bengr): return system config if data reduction proxy is disabled. |
| 273 return proxy_config_service_.get(); | 267 return proxy_config_service_.get(); |
| 274 } | 268 } |
| 275 | 269 |
| 276 } // namespace android_webview | 270 } // namespace android_webview |
| OLD | NEW |