| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 #include "net/socket/client_socket_pool_manager.h" | 86 #include "net/socket/client_socket_pool_manager.h" |
| 87 #include "net/url_request/url_request_context_getter.h" | 87 #include "net/url_request/url_request_context_getter.h" |
| 88 #include "ui/base/l10n/l10n_util.h" | 88 #include "ui/base/l10n/l10n_util.h" |
| 89 | 89 |
| 90 #if defined(ENABLE_CONFIGURATION_POLICY) | 90 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 91 #include "chrome/browser/policy/browser_policy_connector.h" | 91 #include "chrome/browser/policy/browser_policy_connector.h" |
| 92 #else | 92 #else |
| 93 #include "chrome/browser/policy/policy_service_stub.h" | 93 #include "chrome/browser/policy/policy_service_stub.h" |
| 94 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 94 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
| 95 | 95 |
| 96 #if defined(ENABLE_MESSAGE_CENTER) && defined(USE_ASH) | |
| 97 #include "ash/shell.h" | |
| 98 #endif | |
| 99 | |
| 100 #if defined(ENABLE_MESSAGE_CENTER) | 96 #if defined(ENABLE_MESSAGE_CENTER) |
| 101 #include "ui/message_center/message_center.h" | 97 #include "ui/message_center/message_center.h" |
| 102 #endif | 98 #endif |
| 103 | 99 |
| 104 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
| 105 #include "base/win/windows_version.h" | 101 #include "base/win/windows_version.h" |
| 106 #include "ui/views/focus/view_storage.h" | 102 #include "ui/views/focus/view_storage.h" |
| 107 #if defined(USE_AURA) | 103 #if defined(USE_AURA) |
| 108 #include "chrome/browser/metro_viewer/metro_viewer_process_host_win.h" | 104 #include "chrome/browser/metro_viewer/metro_viewer_process_host_win.h" |
| 109 #endif | 105 #endif |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 BrowserProcessImpl::BrowserProcessImpl( | 148 BrowserProcessImpl::BrowserProcessImpl( |
| 153 base::SequencedTaskRunner* local_state_task_runner, | 149 base::SequencedTaskRunner* local_state_task_runner, |
| 154 const CommandLine& command_line) | 150 const CommandLine& command_line) |
| 155 : created_metrics_service_(false), | 151 : created_metrics_service_(false), |
| 156 created_watchdog_thread_(false), | 152 created_watchdog_thread_(false), |
| 157 created_browser_policy_connector_(false), | 153 created_browser_policy_connector_(false), |
| 158 created_profile_manager_(false), | 154 created_profile_manager_(false), |
| 159 created_local_state_(false), | 155 created_local_state_(false), |
| 160 created_icon_manager_(false), | 156 created_icon_manager_(false), |
| 161 created_notification_ui_manager_(false), | 157 created_notification_ui_manager_(false), |
| 162 #if defined(ENABLE_MESSAGE_CENTER) && !defined(USE_ASH) | |
| 163 created_message_center_(false), | |
| 164 #endif | |
| 165 created_safe_browsing_service_(false), | 158 created_safe_browsing_service_(false), |
| 166 module_ref_count_(0), | 159 module_ref_count_(0), |
| 167 did_start_(false), | 160 did_start_(false), |
| 168 checked_for_new_frames_(false), | 161 checked_for_new_frames_(false), |
| 169 using_new_frames_(false), | 162 using_new_frames_(false), |
| 170 render_widget_snapshot_taker_(new RenderWidgetSnapshotTaker), | 163 render_widget_snapshot_taker_(new RenderWidgetSnapshotTaker), |
| 171 download_status_updater_(new DownloadStatusUpdater), | 164 download_status_updater_(new DownloadStatusUpdater), |
| 172 local_state_task_runner_(local_state_task_runner) { | 165 local_state_task_runner_(local_state_task_runner) { |
| 173 g_browser_process = this; | 166 g_browser_process = this; |
| 174 | 167 |
| 175 #if defined(ENABLE_PRINTING) | 168 #if defined(ENABLE_PRINTING) |
| 176 // Must be created after the NotificationService. | 169 // Must be created after the NotificationService. |
| 177 print_job_manager_.reset(new printing::PrintJobManager); | 170 print_job_manager_.reset(new printing::PrintJobManager); |
| 178 #endif | 171 #endif |
| 179 | 172 |
| 180 net_log_.reset(new ChromeNetLog); | 173 net_log_.reset(new ChromeNetLog); |
| 181 | 174 |
| 182 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | 175 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
| 183 extensions::kExtensionScheme); | 176 extensions::kExtensionScheme); |
| 184 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | 177 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
| 185 chrome::kExtensionResourceScheme); | 178 chrome::kExtensionResourceScheme); |
| 186 | 179 |
| 187 #if defined(OS_MACOSX) | 180 #if defined(OS_MACOSX) |
| 188 InitIdleMonitor(); | 181 InitIdleMonitor(); |
| 189 #endif | 182 #endif |
| 190 | 183 |
| 191 extension_event_router_forwarder_ = new extensions::EventRouterForwarder; | 184 extension_event_router_forwarder_ = new extensions::EventRouterForwarder; |
| 192 | 185 |
| 193 ExtensionRendererState::GetInstance()->Init(); | 186 ExtensionRendererState::GetInstance()->Init(); |
| 187 |
| 188 #if defined(ENABLE_MESSAGE_CENTER) |
| 189 message_center::MessageCenter::Initialize(); |
| 190 #endif |
| 194 } | 191 } |
| 195 | 192 |
| 196 BrowserProcessImpl::~BrowserProcessImpl() { | 193 BrowserProcessImpl::~BrowserProcessImpl() { |
| 197 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); | 194 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); |
| 198 | 195 |
| 199 g_browser_process = NULL; | 196 g_browser_process = NULL; |
| 200 } | 197 } |
| 201 | 198 |
| 202 void BrowserProcessImpl::StartTearDown() { | 199 void BrowserProcessImpl::StartTearDown() { |
| 203 #if defined(ENABLE_AUTOMATION) | 200 #if defined(ENABLE_AUTOMATION) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // Need to clear profiles (download managers) before the io_thread_. | 237 // Need to clear profiles (download managers) before the io_thread_. |
| 241 profile_manager_.reset(); | 238 profile_manager_.reset(); |
| 242 | 239 |
| 243 #if !defined(OS_ANDROID) | 240 #if !defined(OS_ANDROID) |
| 244 // Debugger must be cleaned up before IO thread and NotificationService. | 241 // Debugger must be cleaned up before IO thread and NotificationService. |
| 245 remote_debugging_server_.reset(); | 242 remote_debugging_server_.reset(); |
| 246 #endif | 243 #endif |
| 247 | 244 |
| 248 ExtensionRendererState::GetInstance()->Shutdown(); | 245 ExtensionRendererState::GetInstance()->Shutdown(); |
| 249 | 246 |
| 247 #if defined(ENABLE_MESSAGE_CENTER) |
| 248 message_center::MessageCenter::Shutdown(); |
| 249 #endif |
| 250 |
| 250 #if defined(ENABLE_CONFIGURATION_POLICY) | 251 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 251 // The policy providers managed by |browser_policy_connector_| need to shut | 252 // The policy providers managed by |browser_policy_connector_| need to shut |
| 252 // down while the IO and FILE threads are still alive. | 253 // down while the IO and FILE threads are still alive. |
| 253 if (browser_policy_connector_) | 254 if (browser_policy_connector_) |
| 254 browser_policy_connector_->Shutdown(); | 255 browser_policy_connector_->Shutdown(); |
| 255 #endif | 256 #endif |
| 256 | 257 |
| 257 // Stop the watchdog thread before stopping other threads. | 258 // Stop the watchdog thread before stopping other threads. |
| 258 watchdog_thread_.reset(); | 259 watchdog_thread_.reset(); |
| 259 | 260 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { | 455 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { |
| 455 DCHECK(CalledOnValidThread()); | 456 DCHECK(CalledOnValidThread()); |
| 456 if (!created_notification_ui_manager_) | 457 if (!created_notification_ui_manager_) |
| 457 CreateNotificationUIManager(); | 458 CreateNotificationUIManager(); |
| 458 return notification_ui_manager_.get(); | 459 return notification_ui_manager_.get(); |
| 459 } | 460 } |
| 460 | 461 |
| 461 #if defined(ENABLE_MESSAGE_CENTER) | 462 #if defined(ENABLE_MESSAGE_CENTER) |
| 462 message_center::MessageCenter* BrowserProcessImpl::message_center() { | 463 message_center::MessageCenter* BrowserProcessImpl::message_center() { |
| 463 DCHECK(CalledOnValidThread()); | 464 DCHECK(CalledOnValidThread()); |
| 464 #if defined(USE_ASH) | 465 return message_center::MessageCenter::Get(); |
| 465 return ash::Shell::GetInstance()->message_center(); | |
| 466 #else | |
| 467 if (!created_message_center_) | |
| 468 CreateMessageCenter(); | |
| 469 return message_center_.get(); | |
| 470 #endif | |
| 471 } | 466 } |
| 472 #endif | 467 #endif |
| 473 | 468 |
| 474 policy::BrowserPolicyConnector* BrowserProcessImpl::browser_policy_connector() { | 469 policy::BrowserPolicyConnector* BrowserProcessImpl::browser_policy_connector() { |
| 475 DCHECK(CalledOnValidThread()); | 470 DCHECK(CalledOnValidThread()); |
| 476 #if defined(ENABLE_CONFIGURATION_POLICY) | 471 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 477 if (!created_browser_policy_connector_) { | 472 if (!created_browser_policy_connector_) { |
| 478 DCHECK(!browser_policy_connector_); | 473 DCHECK(!browser_policy_connector_); |
| 479 browser_policy_connector_.reset(new policy::BrowserPolicyConnector()); | 474 browser_policy_connector_.reset(new policy::BrowserPolicyConnector()); |
| 480 created_browser_policy_connector_ = true; | 475 created_browser_policy_connector_ = true; |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 } | 902 } |
| 908 | 903 |
| 909 void BrowserProcessImpl::CreateNotificationUIManager() { | 904 void BrowserProcessImpl::CreateNotificationUIManager() { |
| 910 #if defined(ENABLE_NOTIFICATIONS) | 905 #if defined(ENABLE_NOTIFICATIONS) |
| 911 DCHECK(notification_ui_manager_.get() == NULL); | 906 DCHECK(notification_ui_manager_.get() == NULL); |
| 912 notification_ui_manager_.reset(NotificationUIManager::Create(local_state())); | 907 notification_ui_manager_.reset(NotificationUIManager::Create(local_state())); |
| 913 created_notification_ui_manager_ = true; | 908 created_notification_ui_manager_ = true; |
| 914 #endif | 909 #endif |
| 915 } | 910 } |
| 916 | 911 |
| 917 #if defined(ENABLE_MESSAGE_CENTER) && !defined(USE_ASH) | |
| 918 void BrowserProcessImpl::CreateMessageCenter() { | |
| 919 DCHECK(message_center_.get() == NULL); | |
| 920 message_center_.reset(new message_center::MessageCenter()); | |
| 921 created_message_center_ = true; | |
| 922 } | |
| 923 #endif | |
| 924 | |
| 925 void BrowserProcessImpl::CreateBackgroundModeManager() { | 912 void BrowserProcessImpl::CreateBackgroundModeManager() { |
| 926 DCHECK(background_mode_manager_.get() == NULL); | 913 DCHECK(background_mode_manager_.get() == NULL); |
| 927 background_mode_manager_.reset( | 914 background_mode_manager_.reset( |
| 928 new BackgroundModeManager(CommandLine::ForCurrentProcess(), | 915 new BackgroundModeManager(CommandLine::ForCurrentProcess(), |
| 929 &profile_manager()->GetProfileInfoCache())); | 916 &profile_manager()->GetProfileInfoCache())); |
| 930 } | 917 } |
| 931 | 918 |
| 932 void BrowserProcessImpl::CreateStatusTray() { | 919 void BrowserProcessImpl::CreateStatusTray() { |
| 933 DCHECK(status_tray_.get() == NULL); | 920 DCHECK(status_tray_.get() == NULL); |
| 934 status_tray_.reset(StatusTray::Create()); | 921 status_tray_.reset(StatusTray::Create()); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 } | 1027 } |
| 1041 | 1028 |
| 1042 void BrowserProcessImpl::OnAutoupdateTimer() { | 1029 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 1043 if (CanAutorestartForUpdate()) { | 1030 if (CanAutorestartForUpdate()) { |
| 1044 DLOG(WARNING) << "Detected update. Restarting browser."; | 1031 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 1045 RestartBackgroundInstance(); | 1032 RestartBackgroundInstance(); |
| 1046 } | 1033 } |
| 1047 } | 1034 } |
| 1048 | 1035 |
| 1049 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1036 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |