| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/stl_util-inl.h" | 13 #include "base/stl_util-inl.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/task.h" |
| 15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/content_settings/host_content_settings_map.h" | 17 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 17 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 18 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 19 #include "chrome/browser/extensions/extension_info_map.h" |
| 18 #include "chrome/browser/extensions/extension_protocols.h" | 20 #include "chrome/browser/extensions/extension_protocols.h" |
| 19 #include "chrome/browser/io_thread.h" | 21 #include "chrome/browser/io_thread.h" |
| 20 #include "chrome/browser/media/media_internals.h" | 22 #include "chrome/browser/media/media_internals.h" |
| 21 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 23 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 22 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" | 24 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" |
| 23 #include "chrome/browser/net/chrome_net_log.h" | 25 #include "chrome/browser/net/chrome_net_log.h" |
| 24 #include "chrome/browser/net/chrome_network_delegate.h" | 26 #include "chrome/browser/net/chrome_network_delegate.h" |
| 25 #include "chrome/browser/net/pref_proxy_config_service.h" | 27 #include "chrome/browser/net/pref_proxy_config_service.h" |
| 26 #include "chrome/browser/net/proxy_service_factory.h" | 28 #include "chrome/browser/net/proxy_service_factory.h" |
| 27 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 29 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 28 #include "chrome/browser/prefs/pref_service.h" | 30 #include "chrome/browser/prefs/pref_service.h" |
| 29 #include "chrome/browser/prerender/prerender_manager.h" | 31 #include "chrome/browser/prerender/prerender_manager.h" |
| 30 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" | 33 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" |
| 32 #include "chrome/common/chrome_notification_types.h" | 34 #include "chrome/common/chrome_notification_types.h" |
| 33 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
| 38 #include "content/browser/appcache/chrome_appcache_service.h" |
| 36 #include "content/browser/browser_thread.h" | 39 #include "content/browser/browser_thread.h" |
| 40 #include "content/browser/chrome_blob_storage_context.h" |
| 37 #include "content/browser/host_zoom_map.h" | 41 #include "content/browser/host_zoom_map.h" |
| 38 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 42 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 39 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 43 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 40 #include "content/browser/resource_context.h" | 44 #include "content/browser/resource_context.h" |
| 41 #include "content/common/notification_service.h" | 45 #include "content/common/notification_service.h" |
| 42 #include "net/http/http_transaction_factory.h" | 46 #include "net/http/http_transaction_factory.h" |
| 43 #include "net/http/http_util.h" | 47 #include "net/http/http_util.h" |
| 44 #include "net/proxy/proxy_config_service_fixed.h" | 48 #include "net/proxy/proxy_config_service_fixed.h" |
| 45 #include "net/proxy/proxy_script_fetcher_impl.h" | 49 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 46 #include "net/proxy/proxy_service.h" | 50 #include "net/proxy/proxy_service.h" |
| 47 #include "net/url_request/url_request.h" | 51 #include "net/url_request/url_request.h" |
| 48 #include "webkit/blob/blob_data.h" | 52 #include "webkit/blob/blob_data.h" |
| 49 #include "webkit/blob/blob_url_request_job_factory.h" | 53 #include "webkit/blob/blob_url_request_job_factory.h" |
| 54 #include "webkit/fileapi/file_system_context.h" |
| 50 #include "webkit/fileapi/file_system_url_request_job_factory.h" | 55 #include "webkit/fileapi/file_system_url_request_job_factory.h" |
| 51 #include "webkit/database/database_tracker.h" | 56 #include "webkit/database/database_tracker.h" |
| 52 #include "webkit/quota/quota_manager.h" | 57 #include "webkit/quota/quota_manager.h" |
| 53 | 58 |
| 54 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
| 55 #include "chrome/browser/chromeos/gview_request_interceptor.h" | 60 #include "chrome/browser/chromeos/gview_request_interceptor.h" |
| 56 #endif // defined(OS_CHROMEOS) | 61 #endif // defined(OS_CHROMEOS) |
| 57 | 62 |
| 58 namespace { | 63 namespace { |
| 59 | 64 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 profile(NULL) {} | 301 profile(NULL) {} |
| 297 ProfileIOData::ProfileParams::~ProfileParams() {} | 302 ProfileIOData::ProfileParams::~ProfileParams() {} |
| 298 | 303 |
| 299 ProfileIOData::ProfileIOData(bool is_incognito) | 304 ProfileIOData::ProfileIOData(bool is_incognito) |
| 300 : initialized_(false), | 305 : initialized_(false), |
| 301 ALLOW_THIS_IN_INITIALIZER_LIST(resource_context_(this)) { | 306 ALLOW_THIS_IN_INITIALIZER_LIST(resource_context_(this)) { |
| 302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 303 } | 308 } |
| 304 | 309 |
| 305 ProfileIOData::~ProfileIOData() { | 310 ProfileIOData::~ProfileIOData() { |
| 306 // If we have never initialized ProfileIOData, then Handle may hold the only | 311 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
| 307 // reference to it. The important thing is to make sure it hasn't been | |
| 308 // initialized yet, because the lazily initialized variables are supposed to | |
| 309 // live on the IO thread. | |
| 310 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) | |
| 311 DCHECK(!initialized_); | |
| 312 else | |
| 313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 314 } | 313 } |
| 315 | 314 |
| 316 // static | 315 // static |
| 317 bool ProfileIOData::IsHandledProtocol(const std::string& scheme) { | 316 bool ProfileIOData::IsHandledProtocol(const std::string& scheme) { |
| 318 DCHECK_EQ(scheme, StringToLowerASCII(scheme)); | 317 DCHECK_EQ(scheme, StringToLowerASCII(scheme)); |
| 319 static const char* const kProtocolList[] = { | 318 static const char* const kProtocolList[] = { |
| 320 chrome::kExtensionScheme, | 319 chrome::kExtensionScheme, |
| 321 chrome::kChromeUIScheme, | 320 chrome::kChromeUIScheme, |
| 322 chrome::kChromeDevToolsScheme, | 321 chrome::kChromeDevToolsScheme, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 335 | 334 |
| 336 bool ProfileIOData::IsHandledURL(const GURL& url) { | 335 bool ProfileIOData::IsHandledURL(const GURL& url) { |
| 337 if (!url.is_valid()) { | 336 if (!url.is_valid()) { |
| 338 // We handle error cases. | 337 // We handle error cases. |
| 339 return true; | 338 return true; |
| 340 } | 339 } |
| 341 | 340 |
| 342 return IsHandledProtocol(url.scheme()); | 341 return IsHandledProtocol(url.scheme()); |
| 343 } | 342 } |
| 344 | 343 |
| 344 const content::ResourceContext& ProfileIOData::GetResourceContext() const { |
| 345 return resource_context_; |
| 346 } |
| 347 |
| 348 ChromeURLDataManagerBackend* |
| 349 ProfileIOData::GetChromeURLDataManagerBackend() const { |
| 350 LazyInitialize(); |
| 351 return chrome_url_data_manager_backend_.get(); |
| 352 } |
| 353 |
| 345 scoped_refptr<ChromeURLRequestContext> | 354 scoped_refptr<ChromeURLRequestContext> |
| 346 ProfileIOData::GetMainRequestContext() const { | 355 ProfileIOData::GetMainRequestContext() const { |
| 347 LazyInitialize(); | 356 LazyInitialize(); |
| 348 scoped_refptr<RequestContext> context = main_request_context_; | 357 scoped_refptr<RequestContext> context = main_request_context_; |
| 349 context->set_profile_io_data(const_cast<ProfileIOData*>(this)); | 358 context->set_profile_io_data(const_cast<ProfileIOData*>(this)); |
| 350 main_request_context_ = NULL; | 359 main_request_context_ = NULL; |
| 351 return context; | 360 return context; |
| 352 } | 361 } |
| 353 | 362 |
| 354 scoped_refptr<ChromeURLRequestContext> | 363 scoped_refptr<ChromeURLRequestContext> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 382 scoped_refptr<RequestContext> request_context = | 391 scoped_refptr<RequestContext> request_context = |
| 383 AcquireIsolatedAppRequestContext(main_context, app_id); | 392 AcquireIsolatedAppRequestContext(main_context, app_id); |
| 384 request_context->set_profile_io_data(const_cast<ProfileIOData*>(this)); | 393 request_context->set_profile_io_data(const_cast<ProfileIOData*>(this)); |
| 385 app_request_context_map_[app_id] = request_context; | 394 app_request_context_map_[app_id] = request_context; |
| 386 context = request_context; | 395 context = request_context; |
| 387 } | 396 } |
| 388 DCHECK(context); | 397 DCHECK(context); |
| 389 return context; | 398 return context; |
| 390 } | 399 } |
| 391 | 400 |
| 392 const content::ResourceContext& ProfileIOData::GetResourceContext() const { | |
| 393 return resource_context_; | |
| 394 } | |
| 395 | |
| 396 ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const { | 401 ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const { |
| 397 return extension_info_map_; | 402 return extension_info_map_; |
| 398 } | 403 } |
| 399 | 404 |
| 400 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { | 405 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { |
| 401 return host_content_settings_map_; | 406 return host_content_settings_map_; |
| 402 } | 407 } |
| 403 | 408 |
| 404 DesktopNotificationService* ProfileIOData::GetNotificationService() const { | 409 DesktopNotificationService* ProfileIOData::GetNotificationService() const { |
| 405 return notification_service_; | 410 return notification_service_; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 } | 467 } |
| 463 bool set_protocol = job_factory_->SetProtocolHandler( | 468 bool set_protocol = job_factory_->SetProtocolHandler( |
| 464 chrome::kExtensionScheme, | 469 chrome::kExtensionScheme, |
| 465 CreateExtensionProtocolHandler(profile_params_->is_incognito, | 470 CreateExtensionProtocolHandler(profile_params_->is_incognito, |
| 466 profile_params_->extension_info_map)); | 471 profile_params_->extension_info_map)); |
| 467 DCHECK(set_protocol); | 472 DCHECK(set_protocol); |
| 468 set_protocol = job_factory_->SetProtocolHandler( | 473 set_protocol = job_factory_->SetProtocolHandler( |
| 469 chrome::kChromeUIScheme, | 474 chrome::kChromeUIScheme, |
| 470 ChromeURLDataManagerBackend::CreateProtocolHandler( | 475 ChromeURLDataManagerBackend::CreateProtocolHandler( |
| 471 chrome_url_data_manager_backend_.get(), | 476 chrome_url_data_manager_backend_.get(), |
| 472 profile_params_->appcache_service)); | 477 profile_params_->appcache_service, |
| 478 profile_params_->blob_storage_context->controller())); |
| 473 DCHECK(set_protocol); | 479 DCHECK(set_protocol); |
| 474 set_protocol = job_factory_->SetProtocolHandler( | 480 set_protocol = job_factory_->SetProtocolHandler( |
| 475 chrome::kChromeDevToolsScheme, | 481 chrome::kChromeDevToolsScheme, |
| 476 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get())); | 482 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get())); |
| 477 DCHECK(set_protocol); | 483 DCHECK(set_protocol); |
| 478 set_protocol = job_factory_->SetProtocolHandler( | 484 set_protocol = job_factory_->SetProtocolHandler( |
| 479 chrome::kBlobScheme, | 485 chrome::kBlobScheme, |
| 480 new ChromeBlobProtocolHandler( | 486 new ChromeBlobProtocolHandler( |
| 481 profile_params_->blob_storage_context->controller(), | 487 profile_params_->blob_storage_context->controller(), |
| 482 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); | 488 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 534 |
| 529 void ProfileIOData::ApplyProfileParamsToContext( | 535 void ProfileIOData::ApplyProfileParamsToContext( |
| 530 ChromeURLRequestContext* context) const { | 536 ChromeURLRequestContext* context) const { |
| 531 context->set_is_incognito(profile_params_->is_incognito); | 537 context->set_is_incognito(profile_params_->is_incognito); |
| 532 context->set_accept_language(profile_params_->accept_language); | 538 context->set_accept_language(profile_params_->accept_language); |
| 533 context->set_accept_charset(profile_params_->accept_charset); | 539 context->set_accept_charset(profile_params_->accept_charset); |
| 534 context->set_referrer_charset(profile_params_->referrer_charset); | 540 context->set_referrer_charset(profile_params_->referrer_charset); |
| 535 context->set_transport_security_state( | 541 context->set_transport_security_state( |
| 536 profile_params_->transport_security_state); | 542 profile_params_->transport_security_state); |
| 537 context->set_ssl_config_service(profile_params_->ssl_config_service); | 543 context->set_ssl_config_service(profile_params_->ssl_config_service); |
| 538 context->set_appcache_service(profile_params_->appcache_service); | |
| 539 context->set_blob_storage_context(profile_params_->blob_storage_context); | |
| 540 context->set_file_system_context(profile_params_->file_system_context); | |
| 541 context->set_extension_info_map(profile_params_->extension_info_map); | |
| 542 } | 544 } |
| 543 | 545 |
| 544 void ProfileIOData::ShutdownOnUIThread() { | 546 void ProfileIOData::ShutdownOnUIThread() { |
| 545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 547 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 546 enable_referrers_.Destroy(); | 548 enable_referrers_.Destroy(); |
| 547 clear_local_state_on_exit_.Destroy(); | 549 clear_local_state_on_exit_.Destroy(); |
| 548 safe_browsing_enabled_.Destroy(); | 550 safe_browsing_enabled_.Destroy(); |
| 551 bool posted = BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 552 new ReleaseTask<ProfileIOData>(this)); |
| 553 if (!posted) |
| 554 Release(); |
| 549 } | 555 } |
| OLD | NEW |