| 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 <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_browser_context.h" | 10 #include "android_webview/browser/aw_browser_context.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 std::unique_ptr<net::URLRequestJobFactory> CreateJobFactory( | 96 std::unique_ptr<net::URLRequestJobFactory> CreateJobFactory( |
| 97 content::ProtocolHandlerMap* protocol_handlers, | 97 content::ProtocolHandlerMap* protocol_handlers, |
| 98 content::URLRequestInterceptorScopedVector request_interceptors) { | 98 content::URLRequestInterceptorScopedVector request_interceptors) { |
| 99 std::unique_ptr<AwURLRequestJobFactory> aw_job_factory( | 99 std::unique_ptr<AwURLRequestJobFactory> aw_job_factory( |
| 100 new AwURLRequestJobFactory); | 100 new AwURLRequestJobFactory); |
| 101 // Note that the registered schemes must also be specified in | 101 // Note that the registered schemes must also be specified in |
| 102 // AwContentBrowserClient::IsHandledURL. | 102 // AwContentBrowserClient::IsHandledURL. |
| 103 bool set_protocol = aw_job_factory->SetProtocolHandler( | 103 bool set_protocol = aw_job_factory->SetProtocolHandler( |
| 104 url::kFileScheme, | 104 url::kFileScheme, |
| 105 base::WrapUnique(new net::FileProtocolHandler( | 105 base::MakeUnique<net::FileProtocolHandler>( |
| 106 content::BrowserThread::GetBlockingPool() | 106 content::BrowserThread::GetBlockingPool() |
| 107 ->GetTaskRunnerWithShutdownBehavior( | 107 ->GetTaskRunnerWithShutdownBehavior( |
| 108 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); | 108 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); |
| 109 DCHECK(set_protocol); | 109 DCHECK(set_protocol); |
| 110 set_protocol = aw_job_factory->SetProtocolHandler( | 110 set_protocol = aw_job_factory->SetProtocolHandler( |
| 111 url::kDataScheme, base::WrapUnique(new net::DataProtocolHandler())); | 111 url::kDataScheme, base::MakeUnique<net::DataProtocolHandler>()); |
| 112 DCHECK(set_protocol); | 112 DCHECK(set_protocol); |
| 113 set_protocol = aw_job_factory->SetProtocolHandler( | 113 set_protocol = aw_job_factory->SetProtocolHandler( |
| 114 url::kBlobScheme, | 114 url::kBlobScheme, |
| 115 base::WrapUnique((*protocol_handlers)[url::kBlobScheme].release())); | 115 base::WrapUnique((*protocol_handlers)[url::kBlobScheme].release())); |
| 116 DCHECK(set_protocol); | 116 DCHECK(set_protocol); |
| 117 set_protocol = aw_job_factory->SetProtocolHandler( | 117 set_protocol = aw_job_factory->SetProtocolHandler( |
| 118 url::kFileSystemScheme, | 118 url::kFileSystemScheme, |
| 119 base::WrapUnique((*protocol_handlers)[url::kFileSystemScheme].release())); | 119 base::WrapUnique((*protocol_handlers)[url::kFileSystemScheme].release())); |
| 120 DCHECK(set_protocol); | 120 DCHECK(set_protocol); |
| 121 set_protocol = aw_job_factory->SetProtocolHandler( | 121 set_protocol = aw_job_factory->SetProtocolHandler( |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 void AwURLRequestContextGetter::InitializeURLRequestContext() { | 199 void AwURLRequestContextGetter::InitializeURLRequestContext() { |
| 200 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 200 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 201 DCHECK(!url_request_context_); | 201 DCHECK(!url_request_context_); |
| 202 | 202 |
| 203 net::URLRequestContextBuilder builder; | 203 net::URLRequestContextBuilder builder; |
| 204 | 204 |
| 205 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | 205 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); |
| 206 DCHECK(browser_context); | 206 DCHECK(browser_context); |
| 207 | 207 |
| 208 builder.set_network_delegate(base::WrapUnique(new AwNetworkDelegate())); | 208 builder.set_network_delegate(base::MakeUnique<AwNetworkDelegate>()); |
| 209 #if !defined(DISABLE_FTP_SUPPORT) | 209 #if !defined(DISABLE_FTP_SUPPORT) |
| 210 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. | 210 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. |
| 211 #endif | 211 #endif |
| 212 DCHECK(proxy_config_service_.get()); | 212 DCHECK(proxy_config_service_.get()); |
| 213 std::unique_ptr<net::ChannelIDService> channel_id_service; | 213 std::unique_ptr<net::ChannelIDService> channel_id_service; |
| 214 if (TokenBindingManager::GetInstance()->is_enabled()) { | 214 if (TokenBindingManager::GetInstance()->is_enabled()) { |
| 215 base::FilePath channel_id_path = | 215 base::FilePath channel_id_path = |
| 216 browser_context->GetPath().Append(kChannelIDFilename); | 216 browser_context->GetPath().Append(kChannelIDFilename); |
| 217 scoped_refptr<net::SQLiteChannelIDStore> channel_id_db; | 217 scoped_refptr<net::SQLiteChannelIDStore> channel_id_db; |
| 218 channel_id_db = new net::SQLiteChannelIDStore( | 218 channel_id_db = new net::SQLiteChannelIDStore( |
| 219 channel_id_path, | 219 channel_id_path, |
| 220 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 220 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
| 221 BrowserThread::GetBlockingPool()->GetSequenceToken())); | 221 BrowserThread::GetBlockingPool()->GetSequenceToken())); |
| 222 | 222 |
| 223 channel_id_service.reset(new net::ChannelIDService( | 223 channel_id_service.reset(new net::ChannelIDService( |
| 224 new net::DefaultChannelIDStore(channel_id_db.get()), | 224 new net::DefaultChannelIDStore(channel_id_db.get()), |
| 225 base::WorkerPool::GetTaskRunner(true))); | 225 base::WorkerPool::GetTaskRunner(true))); |
| 226 } | 226 } |
| 227 | 227 |
| 228 // Android provides a local HTTP proxy that handles all the proxying. | 228 // Android provides a local HTTP proxy that handles all the proxying. |
| 229 // Create the proxy without a resolver since we rely on this local HTTP proxy. | 229 // Create the proxy without a resolver since we rely on this local HTTP proxy. |
| 230 // TODO(sgurun) is this behavior guaranteed through SDK? | 230 // TODO(sgurun) is this behavior guaranteed through SDK? |
| 231 builder.set_proxy_service(net::ProxyService::CreateWithoutProxyResolver( | 231 builder.set_proxy_service(net::ProxyService::CreateWithoutProxyResolver( |
| 232 std::move(proxy_config_service_), net_log_.get())); | 232 std::move(proxy_config_service_), net_log_.get())); |
| 233 builder.set_net_log(net_log_.get()); | 233 builder.set_net_log(net_log_.get()); |
| 234 builder.SetCookieAndChannelIdStores( | 234 builder.SetCookieAndChannelIdStores(base::MakeUnique<AwCookieStoreWrapper>(), |
| 235 base::WrapUnique(new AwCookieStoreWrapper()), | 235 std::move(channel_id_service)); |
| 236 std::move(channel_id_service)); | |
| 237 | 236 |
| 238 net::URLRequestContextBuilder::HttpCacheParams cache_params; | 237 net::URLRequestContextBuilder::HttpCacheParams cache_params; |
| 239 cache_params.type = | 238 cache_params.type = |
| 240 net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE; | 239 net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE; |
| 241 cache_params.max_size = 20 * 1024 * 1024; // 20M | 240 cache_params.max_size = 20 * 1024 * 1024; // 20M |
| 242 cache_params.path = cache_path_; | 241 cache_params.path = cache_path_; |
| 243 builder.EnableHttpCache(cache_params); | 242 builder.EnableHttpCache(cache_params); |
| 244 builder.SetFileTaskRunner( | 243 builder.SetFileTaskRunner( |
| 245 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)); | 244 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)); |
| 246 | 245 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 http_auth_preferences_->set_server_whitelist( | 312 http_auth_preferences_->set_server_whitelist( |
| 314 auth_server_whitelist_.GetValue()); | 313 auth_server_whitelist_.GetValue()); |
| 315 } | 314 } |
| 316 | 315 |
| 317 void AwURLRequestContextGetter::UpdateAndroidAuthNegotiateAccountType() { | 316 void AwURLRequestContextGetter::UpdateAndroidAuthNegotiateAccountType() { |
| 318 http_auth_preferences_->set_auth_android_negotiate_account_type( | 317 http_auth_preferences_->set_auth_android_negotiate_account_type( |
| 319 auth_android_negotiate_account_type_.GetValue()); | 318 auth_android_negotiate_account_type_.GetValue()); |
| 320 } | 319 } |
| 321 | 320 |
| 322 } // namespace android_webview | 321 } // namespace android_webview |
| OLD | NEW |