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/aw_browser_context.h" | 5 #include "android_webview/browser/aw_browser_context.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "android_webview/browser/aw_browser_policy_connector.h" | 9 #include "android_webview/browser/aw_browser_policy_connector.h" |
8 #include "android_webview/browser/aw_form_database_service.h" | 10 #include "android_webview/browser/aw_form_database_service.h" |
9 #include "android_webview/browser/aw_permission_manager.h" | 11 #include "android_webview/browser/aw_permission_manager.h" |
10 #include "android_webview/browser/aw_pref_store.h" | 12 #include "android_webview/browser/aw_pref_store.h" |
11 #include "android_webview/browser/aw_quota_manager_bridge.h" | 13 #include "android_webview/browser/aw_quota_manager_bridge.h" |
12 #include "android_webview/browser/aw_resource_context.h" | 14 #include "android_webview/browser/aw_resource_context.h" |
13 #include "android_webview/browser/jni_dependency_factory.h" | 15 #include "android_webview/browser/jni_dependency_factory.h" |
14 #include "android_webview/browser/net/aw_url_request_context_getter.h" | 16 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
15 #include "android_webview/browser/net/init_native_callback.h" | 17 #include "android_webview/browser/net/init_native_callback.h" |
16 #include "android_webview/common/aw_content_client.h" | 18 #include "android_webview/common/aw_content_client.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 scoped_ptr<net::ProxyConfigService> config_service = | 83 scoped_ptr<net::ProxyConfigService> config_service = |
82 net::ProxyService::CreateSystemProxyConfigService( | 84 net::ProxyService::CreateSystemProxyConfigService( |
83 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 85 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
84 nullptr /* Ignored on Android */); | 86 nullptr /* Ignored on Android */); |
85 | 87 |
86 // TODO(csharrison) Architect the wrapper better so we don't need a cast for | 88 // TODO(csharrison) Architect the wrapper better so we don't need a cast for |
87 // android ProxyConfigServices. | 89 // android ProxyConfigServices. |
88 net::ProxyConfigServiceAndroid* android_config_service = | 90 net::ProxyConfigServiceAndroid* android_config_service = |
89 static_cast<net::ProxyConfigServiceAndroid*>(config_service.get()); | 91 static_cast<net::ProxyConfigServiceAndroid*>(config_service.get()); |
90 android_config_service->set_exclude_pac_url(true); | 92 android_config_service->set_exclude_pac_url(true); |
91 return config_service.Pass(); | 93 return config_service; |
92 } | 94 } |
93 | 95 |
94 bool OverrideBlacklistForURL(const GURL& url, bool* block, int* reason) { | 96 bool OverrideBlacklistForURL(const GURL& url, bool* block, int* reason) { |
95 // We don't have URLs that should never be blacklisted here. | 97 // We don't have URLs that should never be blacklisted here. |
96 return false; | 98 return false; |
97 } | 99 } |
98 | 100 |
99 policy::URLBlacklistManager* CreateURLBlackListManager( | 101 policy::URLBlacklistManager* CreateURLBlackListManager( |
100 PrefService* pref_service) { | 102 PrefService* pref_service) { |
101 policy::URLBlacklist::SegmentURLCallback segment_url_callback = | 103 policy::URLBlacklist::SegmentURLCallback segment_url_callback = |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 scoped_ptr<data_reduction_proxy::DataStore> store( | 221 scoped_ptr<data_reduction_proxy::DataStore> store( |
220 new data_reduction_proxy::DataStore()); | 222 new data_reduction_proxy::DataStore()); |
221 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 223 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
222 scoped_refptr<base::SequencedTaskRunner> db_task_runner = | 224 scoped_refptr<base::SequencedTaskRunner> db_task_runner = |
223 pool->GetSequencedTaskRunnerWithShutdownBehavior( | 225 pool->GetSequencedTaskRunnerWithShutdownBehavior( |
224 pool->GetSequenceToken(), | 226 pool->GetSequenceToken(), |
225 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 227 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
226 data_reduction_proxy_service_.reset( | 228 data_reduction_proxy_service_.reset( |
227 new data_reduction_proxy::DataReductionProxyService( | 229 new data_reduction_proxy::DataReductionProxyService( |
228 data_reduction_proxy_settings_.get(), nullptr, | 230 data_reduction_proxy_settings_.get(), nullptr, |
229 GetAwURLRequestContext(), store.Pass(), | 231 GetAwURLRequestContext(), std::move(store), |
230 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 232 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
231 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 233 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
232 db_task_runner, base::TimeDelta())); | 234 db_task_runner, base::TimeDelta())); |
233 data_reduction_proxy_io_data_->SetDataReductionProxyService( | 235 data_reduction_proxy_io_data_->SetDataReductionProxyService( |
234 data_reduction_proxy_service_->GetWeakPtr()); | 236 data_reduction_proxy_service_->GetWeakPtr()); |
235 | 237 |
236 visitedlink_master_.reset( | 238 visitedlink_master_.reset( |
237 new visitedlink::VisitedLinkMaster(this, this, false)); | 239 new visitedlink::VisitedLinkMaster(this, this, false)); |
238 visitedlink_master_->Init(); | 240 visitedlink_master_->Init(); |
239 | 241 |
240 form_database_service_.reset( | 242 form_database_service_.reset( |
241 new AwFormDatabaseService(context_storage_path_)); | 243 new AwFormDatabaseService(context_storage_path_)); |
242 | 244 |
243 // Ensure the storage partition is initialized in time for DataReductionProxy. | 245 // Ensure the storage partition is initialized in time for DataReductionProxy. |
244 EnsureResourceContextInitialized(this); | 246 EnsureResourceContextInitialized(this); |
245 | 247 |
246 // TODO(dgn) lazy init, see http://crbug.com/521542 | 248 // TODO(dgn) lazy init, see http://crbug.com/521542 |
247 data_reduction_proxy_settings_->InitDataReductionProxySettings( | 249 data_reduction_proxy_settings_->InitDataReductionProxySettings( |
248 kDataReductionProxyEnabled, | 250 kDataReductionProxyEnabled, user_pref_service_.get(), |
249 user_pref_service_.get(), data_reduction_proxy_io_data_.get(), | 251 data_reduction_proxy_io_data_.get(), |
250 data_reduction_proxy_service_.Pass()); | 252 std::move(data_reduction_proxy_service_)); |
251 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); | 253 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); |
252 | 254 |
253 blacklist_manager_.reset(CreateURLBlackListManager(user_pref_service_.get())); | 255 blacklist_manager_.reset(CreateURLBlackListManager(user_pref_service_.get())); |
254 } | 256 } |
255 | 257 |
256 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { | 258 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { |
257 DCHECK(visitedlink_master_); | 259 DCHECK(visitedlink_master_); |
258 visitedlink_master_->AddURLs(urls); | 260 visitedlink_master_->AddURLs(urls); |
259 } | 261 } |
260 | 262 |
261 net::URLRequestContextGetter* AwBrowserContext::CreateRequestContext( | 263 net::URLRequestContextGetter* AwBrowserContext::CreateRequestContext( |
262 content::ProtocolHandlerMap* protocol_handlers, | 264 content::ProtocolHandlerMap* protocol_handlers, |
263 content::URLRequestInterceptorScopedVector request_interceptors) { | 265 content::URLRequestInterceptorScopedVector request_interceptors) { |
264 // This function cannot actually create the request context because | 266 // This function cannot actually create the request context because |
265 // there is a reentrant dependency on GetResourceContext() via | 267 // there is a reentrant dependency on GetResourceContext() via |
266 // content::StoragePartitionImplMap::Create(). This is not fixable | 268 // content::StoragePartitionImplMap::Create(). This is not fixable |
267 // until http://crbug.com/159193. Until then, assert that the context | 269 // until http://crbug.com/159193. Until then, assert that the context |
268 // has already been allocated and just handle setting the protocol_handlers. | 270 // has already been allocated and just handle setting the protocol_handlers. |
269 DCHECK(url_request_context_getter_.get()); | 271 DCHECK(url_request_context_getter_.get()); |
270 url_request_context_getter_->SetHandlersAndInterceptors( | 272 url_request_context_getter_->SetHandlersAndInterceptors( |
271 protocol_handlers, request_interceptors.Pass()); | 273 protocol_handlers, std::move(request_interceptors)); |
272 return url_request_context_getter_.get(); | 274 return url_request_context_getter_.get(); |
273 } | 275 } |
274 | 276 |
275 net::URLRequestContextGetter* | 277 net::URLRequestContextGetter* |
276 AwBrowserContext::CreateRequestContextForStoragePartition( | 278 AwBrowserContext::CreateRequestContextForStoragePartition( |
277 const base::FilePath& partition_path, | 279 const base::FilePath& partition_path, |
278 bool in_memory, | 280 bool in_memory, |
279 content::ProtocolHandlerMap* protocol_handlers, | 281 content::ProtocolHandlerMap* protocol_handlers, |
280 content::URLRequestInterceptorScopedVector request_interceptors) { | 282 content::URLRequestInterceptorScopedVector request_interceptors) { |
281 NOTREACHED(); | 283 NOTREACHED(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 std::string()); | 334 std::string()); |
333 | 335 |
334 base::PrefServiceFactory pref_service_factory; | 336 base::PrefServiceFactory pref_service_factory; |
335 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); | 337 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); |
336 pref_service_factory.set_managed_prefs( | 338 pref_service_factory.set_managed_prefs( |
337 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( | 339 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( |
338 browser_policy_connector_->GetPolicyService(), | 340 browser_policy_connector_->GetPolicyService(), |
339 browser_policy_connector_->GetHandlerList(), | 341 browser_policy_connector_->GetHandlerList(), |
340 policy::POLICY_LEVEL_MANDATORY))); | 342 policy::POLICY_LEVEL_MANDATORY))); |
341 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); | 343 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); |
342 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass(); | 344 user_pref_service_ = pref_service_factory.Create(pref_registry); |
343 | 345 |
344 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); | 346 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); |
345 } | 347 } |
346 | 348 |
347 scoped_ptr<content::ZoomLevelDelegate> | 349 scoped_ptr<content::ZoomLevelDelegate> |
348 AwBrowserContext::CreateZoomLevelDelegate( | 350 AwBrowserContext::CreateZoomLevelDelegate( |
349 const base::FilePath& partition_path) { | 351 const base::FilePath& partition_path) { |
350 return nullptr; | 352 return nullptr; |
351 } | 353 } |
352 | 354 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 return; | 460 return; |
459 // We don't care about commit_delay for now. It is just a dummy value. | 461 // We don't care about commit_delay for now. It is just a dummy value. |
460 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 462 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
461 data_reduction_proxy_service->EnableCompressionStatisticsLogging( | 463 data_reduction_proxy_service->EnableCompressionStatisticsLogging( |
462 user_pref_service_.get(), | 464 user_pref_service_.get(), |
463 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 465 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
464 commit_delay); | 466 commit_delay); |
465 } | 467 } |
466 | 468 |
467 } // namespace android_webview | 469 } // namespace android_webview |
OLD | NEW |