| 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 "chrome/browser/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 #include "content/public/browser/browser_thread.h" | 110 #include "content/public/browser/browser_thread.h" |
| 111 #include "content/public/browser/child_process_security_policy.h" | 111 #include "content/public/browser/child_process_security_policy.h" |
| 112 #include "content/public/browser/notification_details.h" | 112 #include "content/public/browser/notification_details.h" |
| 113 #include "content/public/browser/plugin_service.h" | 113 #include "content/public/browser/plugin_service.h" |
| 114 #include "content/public/browser/render_process_host.h" | 114 #include "content/public/browser/render_process_host.h" |
| 115 #include "content/public/browser/resource_dispatcher_host.h" | 115 #include "content/public/browser/resource_dispatcher_host.h" |
| 116 #include "content/public/browser/service_worker_context.h" | 116 #include "content/public/browser/service_worker_context.h" |
| 117 #include "content/public/browser/storage_partition.h" | 117 #include "content/public/browser/storage_partition.h" |
| 118 #include "content/public/common/content_switches.h" | 118 #include "content/public/common/content_switches.h" |
| 119 #include "extensions/common/constants.h" | 119 #include "extensions/common/constants.h" |
| 120 #include "extensions/features/features.h" |
| 120 #include "net/socket/client_socket_pool_manager.h" | 121 #include "net/socket/client_socket_pool_manager.h" |
| 121 #include "net/url_request/url_request_context_getter.h" | 122 #include "net/url_request/url_request_context_getter.h" |
| 122 #include "printing/features/features.h" | 123 #include "printing/features/features.h" |
| 123 #include "ui/base/idle/idle.h" | 124 #include "ui/base/idle/idle.h" |
| 124 #include "ui/base/l10n/l10n_util.h" | 125 #include "ui/base/l10n/l10n_util.h" |
| 125 #include "ui/message_center/message_center.h" | 126 #include "ui/message_center/message_center.h" |
| 126 | 127 |
| 127 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
| 128 #include "base/win/windows_version.h" | 129 #include "base/win/windows_version.h" |
| 129 #include "ui/views/focus/view_storage.h" | 130 #include "ui/views/focus/view_storage.h" |
| 130 #elif defined(OS_MACOSX) | 131 #elif defined(OS_MACOSX) |
| 131 #include "chrome/browser/chrome_browser_main_mac.h" | 132 #include "chrome/browser/chrome_browser_main_mac.h" |
| 132 #endif | 133 #endif |
| 133 | 134 |
| 134 #if !defined(OS_ANDROID) | 135 #if !defined(OS_ANDROID) |
| 135 #include "chrome/browser/lifetime/keep_alive_registry.h" | 136 #include "chrome/browser/lifetime/keep_alive_registry.h" |
| 136 #include "chrome/browser/services/gcm/gcm_product_util.h" | 137 #include "chrome/browser/services/gcm/gcm_product_util.h" |
| 137 #include "chrome/browser/ui/user_manager.h" | 138 #include "chrome/browser/ui/user_manager.h" |
| 138 #include "components/gcm_driver/gcm_client_factory.h" | 139 #include "components/gcm_driver/gcm_client_factory.h" |
| 139 #include "components/gcm_driver/gcm_desktop_utils.h" | 140 #include "components/gcm_driver/gcm_desktop_utils.h" |
| 140 #endif | 141 #endif |
| 141 | 142 |
| 142 #if BUILDFLAG(ENABLE_BACKGROUND) | 143 #if BUILDFLAG(ENABLE_BACKGROUND) |
| 143 #include "chrome/browser/background/background_mode_manager.h" | 144 #include "chrome/browser/background/background_mode_manager.h" |
| 144 #endif | 145 #endif |
| 145 | 146 |
| 146 #if defined(ENABLE_EXTENSIONS) | 147 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 147 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" | 148 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" |
| 148 #include "chrome/browser/extensions/event_router_forwarder.h" | 149 #include "chrome/browser/extensions/event_router_forwarder.h" |
| 149 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 150 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
| 150 #include "chrome/browser/ui/apps/chrome_app_window_client.h" | 151 #include "chrome/browser/ui/apps/chrome_app_window_client.h" |
| 151 #include "components/storage_monitor/storage_monitor.h" | 152 #include "components/storage_monitor/storage_monitor.h" |
| 152 #include "extensions/common/extension_l10n_util.h" | 153 #include "extensions/common/extension_l10n_util.h" |
| 153 #endif | 154 #endif |
| 154 | 155 |
| 155 #if !defined(DISABLE_NACL) | 156 #if !defined(DISABLE_NACL) |
| 156 #include "chrome/browser/component_updater/pnacl_component_installer.h" | 157 #include "chrome/browser/component_updater/pnacl_component_installer.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 230 |
| 230 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | 231 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
| 231 chrome::kChromeSearchScheme); | 232 chrome::kChromeSearchScheme); |
| 232 | 233 |
| 233 #if defined(OS_MACOSX) | 234 #if defined(OS_MACOSX) |
| 234 ui::InitIdleMonitor(); | 235 ui::InitIdleMonitor(); |
| 235 #endif | 236 #endif |
| 236 | 237 |
| 237 device_client_.reset(new ChromeDeviceClient); | 238 device_client_.reset(new ChromeDeviceClient); |
| 238 | 239 |
| 239 #if defined(ENABLE_EXTENSIONS) | 240 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 240 // Athena sets its own instance during Athena's init process. | 241 // Athena sets its own instance during Athena's init process. |
| 241 extensions::AppWindowClient::Set(ChromeAppWindowClient::GetInstance()); | 242 extensions::AppWindowClient::Set(ChromeAppWindowClient::GetInstance()); |
| 242 | 243 |
| 243 extension_event_router_forwarder_ = new extensions::EventRouterForwarder; | 244 extension_event_router_forwarder_ = new extensions::EventRouterForwarder; |
| 244 | 245 |
| 245 extensions::ExtensionsClient::Set( | 246 extensions::ExtensionsClient::Set( |
| 246 extensions::ChromeExtensionsClient::GetInstance()); | 247 extensions::ChromeExtensionsClient::GetInstance()); |
| 247 | 248 |
| 248 extensions_browser_client_.reset( | 249 extensions_browser_client_.reset( |
| 249 new extensions::ChromeExtensionsBrowserClient); | 250 new extensions::ChromeExtensionsBrowserClient); |
| 250 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); | 251 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); |
| 251 #endif | 252 #endif |
| 252 | 253 |
| 253 message_center::MessageCenter::Initialize(); | 254 message_center::MessageCenter::Initialize(); |
| 254 | 255 |
| 255 update_client::UpdateQueryParams::SetDelegate( | 256 update_client::UpdateQueryParams::SetDelegate( |
| 256 ChromeUpdateQueryParamsDelegate::GetInstance()); | 257 ChromeUpdateQueryParamsDelegate::GetInstance()); |
| 257 | 258 |
| 258 #if !defined(OS_ANDROID) | 259 #if !defined(OS_ANDROID) |
| 259 KeepAliveRegistry::GetInstance()->AddObserver(this); | 260 KeepAliveRegistry::GetInstance()->AddObserver(this); |
| 260 #endif // !defined(OS_ANDROID) | 261 #endif // !defined(OS_ANDROID) |
| 261 } | 262 } |
| 262 | 263 |
| 263 BrowserProcessImpl::~BrowserProcessImpl() { | 264 BrowserProcessImpl::~BrowserProcessImpl() { |
| 264 #if defined(ENABLE_EXTENSIONS) | 265 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 265 extensions::ExtensionsBrowserClient::Set(nullptr); | 266 extensions::ExtensionsBrowserClient::Set(nullptr); |
| 266 #endif | 267 #endif |
| 267 | 268 |
| 268 #if !defined(OS_ANDROID) | 269 #if !defined(OS_ANDROID) |
| 269 KeepAliveRegistry::GetInstance()->RemoveObserver(this); | 270 KeepAliveRegistry::GetInstance()->RemoveObserver(this); |
| 270 #endif // !defined(OS_ANDROID) | 271 #endif // !defined(OS_ANDROID) |
| 271 | 272 |
| 272 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); | 273 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); |
| 273 | 274 |
| 274 g_browser_process = NULL; | 275 g_browser_process = NULL; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 TRACE_EVENT0("shutdown", | 318 TRACE_EVENT0("shutdown", |
| 318 "BrowserProcessImpl::StartTearDown:ProfileManager"); | 319 "BrowserProcessImpl::StartTearDown:ProfileManager"); |
| 319 // The desktop User Manager needs to be closed before the guest profile | 320 // The desktop User Manager needs to be closed before the guest profile |
| 320 // can be destroyed. | 321 // can be destroyed. |
| 321 UserManager::Hide(); | 322 UserManager::Hide(); |
| 322 profile_manager_.reset(); | 323 profile_manager_.reset(); |
| 323 } | 324 } |
| 324 | 325 |
| 325 child_process_watcher_.reset(); | 326 child_process_watcher_.reset(); |
| 326 | 327 |
| 327 #if defined(ENABLE_EXTENSIONS) | 328 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 328 media_file_system_registry_.reset(); | 329 media_file_system_registry_.reset(); |
| 329 // Remove the global instance of the Storage Monitor now. Otherwise the | 330 // Remove the global instance of the Storage Monitor now. Otherwise the |
| 330 // FILE thread would be gone when we try to release it in the dtor and | 331 // FILE thread would be gone when we try to release it in the dtor and |
| 331 // Valgrind would report a leak on almost every single browser_test. | 332 // Valgrind would report a leak on almost every single browser_test. |
| 332 // TODO(gbillock): Make this unnecessary. | 333 // TODO(gbillock): Make this unnecessary. |
| 333 storage_monitor::StorageMonitor::Destroy(); | 334 storage_monitor::StorageMonitor::Destroy(); |
| 334 #endif | 335 #endif |
| 335 | 336 |
| 336 message_center::MessageCenter::Shutdown(); | 337 message_center::MessageCenter::Shutdown(); |
| 337 | 338 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 DCHECK(CalledOnValidThread()); | 566 DCHECK(CalledOnValidThread()); |
| 566 return GetMetricsServicesManager()->GetVariationsService(); | 567 return GetMetricsServicesManager()->GetVariationsService(); |
| 567 } | 568 } |
| 568 | 569 |
| 569 BrowserProcessPlatformPart* BrowserProcessImpl::platform_part() { | 570 BrowserProcessPlatformPart* BrowserProcessImpl::platform_part() { |
| 570 return platform_part_.get(); | 571 return platform_part_.get(); |
| 571 } | 572 } |
| 572 | 573 |
| 573 extensions::EventRouterForwarder* | 574 extensions::EventRouterForwarder* |
| 574 BrowserProcessImpl::extension_event_router_forwarder() { | 575 BrowserProcessImpl::extension_event_router_forwarder() { |
| 575 #if defined(ENABLE_EXTENSIONS) | 576 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 576 return extension_event_router_forwarder_.get(); | 577 return extension_event_router_forwarder_.get(); |
| 577 #else | 578 #else |
| 578 return NULL; | 579 return NULL; |
| 579 #endif | 580 #endif |
| 580 } | 581 } |
| 581 | 582 |
| 582 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { | 583 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { |
| 583 DCHECK(CalledOnValidThread()); | 584 DCHECK(CalledOnValidThread()); |
| 584 // TODO(miguelg) return NULL for MAC as well once native notifications | 585 // TODO(miguelg) return NULL for MAC as well once native notifications |
| 585 // are enabled by default. | 586 // are enabled by default. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 return intranet_redirect_detector_.get(); | 711 return intranet_redirect_detector_.get(); |
| 711 } | 712 } |
| 712 | 713 |
| 713 const std::string& BrowserProcessImpl::GetApplicationLocale() { | 714 const std::string& BrowserProcessImpl::GetApplicationLocale() { |
| 714 DCHECK(!locale_.empty()); | 715 DCHECK(!locale_.empty()); |
| 715 return locale_; | 716 return locale_; |
| 716 } | 717 } |
| 717 | 718 |
| 718 void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) { | 719 void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) { |
| 719 locale_ = locale; | 720 locale_ = locale; |
| 720 #if defined(ENABLE_EXTENSIONS) | 721 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 721 extension_l10n_util::SetProcessLocale(locale); | 722 extension_l10n_util::SetProcessLocale(locale); |
| 722 #endif | 723 #endif |
| 723 ChromeContentBrowserClient::SetApplicationLocale(locale); | 724 ChromeContentBrowserClient::SetApplicationLocale(locale); |
| 724 translate::TranslateDownloadManager::GetInstance()->set_application_locale( | 725 translate::TranslateDownloadManager::GetInstance()->set_application_locale( |
| 725 locale); | 726 locale); |
| 726 } | 727 } |
| 727 | 728 |
| 728 DownloadStatusUpdater* BrowserProcessImpl::download_status_updater() { | 729 DownloadStatusUpdater* BrowserProcessImpl::download_status_updater() { |
| 729 return download_status_updater_.get(); | 730 return download_status_updater_.get(); |
| 730 } | 731 } |
| 731 | 732 |
| 732 MediaFileSystemRegistry* BrowserProcessImpl::media_file_system_registry() { | 733 MediaFileSystemRegistry* BrowserProcessImpl::media_file_system_registry() { |
| 733 #if defined(ENABLE_EXTENSIONS) | 734 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 734 if (!media_file_system_registry_) | 735 if (!media_file_system_registry_) |
| 735 media_file_system_registry_.reset(new MediaFileSystemRegistry()); | 736 media_file_system_registry_.reset(new MediaFileSystemRegistry()); |
| 736 return media_file_system_registry_.get(); | 737 return media_file_system_registry_.get(); |
| 737 #else | 738 #else |
| 738 return NULL; | 739 return NULL; |
| 739 #endif | 740 #endif |
| 740 } | 741 } |
| 741 | 742 |
| 742 bool BrowserProcessImpl::created_local_state() const { | 743 bool BrowserProcessImpl::created_local_state() const { |
| 743 return created_local_state_; | 744 return created_local_state_; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 | 1030 |
| 1030 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); | 1031 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); |
| 1031 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( | 1032 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( |
| 1032 net::HttpNetworkSession::NORMAL_SOCKET_POOL, | 1033 net::HttpNetworkSession::NORMAL_SOCKET_POOL, |
| 1033 std::max(std::min(max_per_proxy, 99), | 1034 std::max(std::min(max_per_proxy, 99), |
| 1034 net::ClientSocketPoolManager::max_sockets_per_group( | 1035 net::ClientSocketPoolManager::max_sockets_per_group( |
| 1035 net::HttpNetworkSession::NORMAL_SOCKET_POOL))); | 1036 net::HttpNetworkSession::NORMAL_SOCKET_POOL))); |
| 1036 } | 1037 } |
| 1037 | 1038 |
| 1038 void BrowserProcessImpl::PreCreateThreads() { | 1039 void BrowserProcessImpl::PreCreateThreads() { |
| 1039 #if defined(ENABLE_EXTENSIONS) | 1040 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 1040 // Register the chrome-extension scheme to reflect the extension process | 1041 // Register the chrome-extension scheme to reflect the extension process |
| 1041 // model. Controlled by a field trial, so we can't do this earlier. | 1042 // model. Controlled by a field trial, so we can't do this earlier. |
| 1042 base::FieldTrialList::FindFullName("SiteIsolationExtensions"); | 1043 base::FieldTrialList::FindFullName("SiteIsolationExtensions"); |
| 1043 if (extensions::IsIsolateExtensionsEnabled()) { | 1044 if (extensions::IsIsolateExtensionsEnabled()) { |
| 1044 // chrome-extension:// URLs are safe to request anywhere, but may only | 1045 // chrome-extension:// URLs are safe to request anywhere, but may only |
| 1045 // commit (including in iframes) in extension processes. | 1046 // commit (including in iframes) in extension processes. |
| 1046 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeIsolatedScheme( | 1047 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeIsolatedScheme( |
| 1047 extensions::kExtensionScheme, true); | 1048 extensions::kExtensionScheme, true); |
| 1048 // TODO(nick): Kill off kExtensionResourceScheme. | 1049 // TODO(nick): Kill off kExtensionResourceScheme. |
| 1049 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeIsolatedScheme( | 1050 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeIsolatedScheme( |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 } | 1400 } |
| 1400 | 1401 |
| 1401 void BrowserProcessImpl::OnAutoupdateTimer() { | 1402 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 1402 if (CanAutorestartForUpdate()) { | 1403 if (CanAutorestartForUpdate()) { |
| 1403 DLOG(WARNING) << "Detected update. Restarting browser."; | 1404 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 1404 RestartBackgroundInstance(); | 1405 RestartBackgroundInstance(); |
| 1405 } | 1406 } |
| 1406 } | 1407 } |
| 1407 | 1408 |
| 1408 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1409 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |