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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 static const int kEndSessionTimeoutSeconds = 10; | 158 static const int kEndSessionTimeoutSeconds = 10; |
159 #endif | 159 #endif |
160 | 160 |
161 using content::BrowserThread; | 161 using content::BrowserThread; |
162 using content::ChildProcessSecurityPolicy; | 162 using content::ChildProcessSecurityPolicy; |
163 using content::PluginService; | 163 using content::PluginService; |
164 using content::ResourceDispatcherHost; | 164 using content::ResourceDispatcherHost; |
165 | 165 |
166 BrowserProcessImpl::BrowserProcessImpl( | 166 BrowserProcessImpl::BrowserProcessImpl( |
167 base::SequencedTaskRunner* local_state_task_runner, | 167 base::SequencedTaskRunner* local_state_task_runner, |
168 const CommandLine& command_line) | 168 const base::CommandLine& command_line) |
169 : created_watchdog_thread_(false), | 169 : created_watchdog_thread_(false), |
170 created_browser_policy_connector_(false), | 170 created_browser_policy_connector_(false), |
171 created_profile_manager_(false), | 171 created_profile_manager_(false), |
172 created_local_state_(false), | 172 created_local_state_(false), |
173 created_icon_manager_(false), | 173 created_icon_manager_(false), |
174 created_notification_ui_manager_(false), | 174 created_notification_ui_manager_(false), |
175 created_safe_browsing_service_(false), | 175 created_safe_browsing_service_(false), |
176 module_ref_count_(0), | 176 module_ref_count_(0), |
177 did_start_(false), | 177 did_start_(false), |
178 download_status_updater_(new DownloadStatusUpdater), | 178 download_status_updater_(new DownloadStatusUpdater), |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 return prerender_tracker_.get(); | 858 return prerender_tracker_.get(); |
859 } | 859 } |
860 | 860 |
861 component_updater::ComponentUpdateService* | 861 component_updater::ComponentUpdateService* |
862 BrowserProcessImpl::component_updater() { | 862 BrowserProcessImpl::component_updater() { |
863 if (!component_updater_.get()) { | 863 if (!component_updater_.get()) { |
864 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) | 864 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) |
865 return NULL; | 865 return NULL; |
866 component_updater::Configurator* configurator = | 866 component_updater::Configurator* configurator = |
867 component_updater::MakeChromeComponentUpdaterConfigurator( | 867 component_updater::MakeChromeComponentUpdaterConfigurator( |
868 CommandLine::ForCurrentProcess(), | 868 base::CommandLine::ForCurrentProcess(), |
869 io_thread()->system_url_request_context_getter()); | 869 io_thread()->system_url_request_context_getter()); |
870 // Creating the component updater does not do anything, components | 870 // Creating the component updater does not do anything, components |
871 // need to be registered and Start() needs to be called. | 871 // need to be registered and Start() needs to be called. |
872 component_updater_.reset(ComponentUpdateServiceFactory(configurator)); | 872 component_updater_.reset(ComponentUpdateServiceFactory(configurator)); |
873 } | 873 } |
874 return component_updater_.get(); | 874 return component_updater_.get(); |
875 } | 875 } |
876 | 876 |
877 CRLSetFetcher* BrowserProcessImpl::crl_set_fetcher() { | 877 CRLSetFetcher* BrowserProcessImpl::crl_set_fetcher() { |
878 if (!crl_set_fetcher_.get()) | 878 if (!crl_set_fetcher_.get()) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 #endif | 995 #endif |
996 | 996 |
997 #if defined(ENABLE_PLUGINS) | 997 #if defined(ENABLE_PLUGINS) |
998 PluginService* plugin_service = PluginService::GetInstance(); | 998 PluginService* plugin_service = PluginService::GetInstance(); |
999 plugin_service->SetFilter(ChromePluginServiceFilter::GetInstance()); | 999 plugin_service->SetFilter(ChromePluginServiceFilter::GetInstance()); |
1000 plugin_service->StartWatchingPlugins(); | 1000 plugin_service->StartWatchingPlugins(); |
1001 | 1001 |
1002 #if defined(OS_POSIX) | 1002 #if defined(OS_POSIX) |
1003 // Also find plugins in a user-specific plugins dir, | 1003 // Also find plugins in a user-specific plugins dir, |
1004 // e.g. ~/.config/chromium/Plugins. | 1004 // e.g. ~/.config/chromium/Plugins. |
1005 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 1005 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess(); |
1006 if (!cmd_line.HasSwitch(switches::kDisablePluginsDiscovery)) { | 1006 if (!cmd_line.HasSwitch(switches::kDisablePluginsDiscovery)) { |
1007 base::FilePath user_data_dir; | 1007 base::FilePath user_data_dir; |
1008 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | 1008 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) |
1009 plugin_service->AddExtraPluginDir(user_data_dir.Append("Plugins")); | 1009 plugin_service->AddExtraPluginDir(user_data_dir.Append("Plugins")); |
1010 } | 1010 } |
1011 #endif | 1011 #endif |
1012 | 1012 |
1013 // Triggers initialization of the singleton instance on UI thread. | 1013 // Triggers initialization of the singleton instance on UI thread. |
1014 PluginFinder::GetInstance()->Init(); | 1014 PluginFinder::GetInstance()->Init(); |
1015 | 1015 |
1016 #if defined(ENABLE_PLUGIN_INSTALLATION) | 1016 #if defined(ENABLE_PLUGIN_INSTALLATION) |
1017 DCHECK(!plugins_resource_service_.get()); | 1017 DCHECK(!plugins_resource_service_.get()); |
1018 plugins_resource_service_ = new PluginsResourceService(local_state()); | 1018 plugins_resource_service_ = new PluginsResourceService(local_state()); |
1019 plugins_resource_service_->Init(); | 1019 plugins_resource_service_->Init(); |
1020 #endif | 1020 #endif |
1021 #endif // defined(ENABLE_PLUGINS) | 1021 #endif // defined(ENABLE_PLUGINS) |
1022 | 1022 |
1023 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1023 const base::CommandLine& command_line = |
| 1024 *base::CommandLine::ForCurrentProcess(); |
1024 if (!command_line.HasSwitch(switches::kDisableWebResources)) { | 1025 if (!command_line.HasSwitch(switches::kDisableWebResources)) { |
1025 DCHECK(!promo_resource_service_.get()); | 1026 DCHECK(!promo_resource_service_.get()); |
1026 promo_resource_service_ = new PromoResourceService; | 1027 promo_resource_service_ = new PromoResourceService; |
1027 promo_resource_service_->StartAfterDelay(); | 1028 promo_resource_service_->StartAfterDelay(); |
1028 } | 1029 } |
1029 | 1030 |
1030 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 1031 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
1031 storage_monitor::StorageMonitor::Create(); | 1032 storage_monitor::StorageMonitor::Create(); |
1032 #endif | 1033 #endif |
1033 | 1034 |
(...skipping 18 matching lines...) Expand all Loading... |
1052 DCHECK(notification_ui_manager_.get() == NULL); | 1053 DCHECK(notification_ui_manager_.get() == NULL); |
1053 notification_ui_manager_.reset(NotificationUIManager::Create(local_state())); | 1054 notification_ui_manager_.reset(NotificationUIManager::Create(local_state())); |
1054 created_notification_ui_manager_ = true; | 1055 created_notification_ui_manager_ = true; |
1055 #endif | 1056 #endif |
1056 } | 1057 } |
1057 | 1058 |
1058 void BrowserProcessImpl::CreateBackgroundModeManager() { | 1059 void BrowserProcessImpl::CreateBackgroundModeManager() { |
1059 #if defined(ENABLE_BACKGROUND) | 1060 #if defined(ENABLE_BACKGROUND) |
1060 DCHECK(background_mode_manager_.get() == NULL); | 1061 DCHECK(background_mode_manager_.get() == NULL); |
1061 background_mode_manager_.reset( | 1062 background_mode_manager_.reset( |
1062 new BackgroundModeManager(CommandLine::ForCurrentProcess(), | 1063 new BackgroundModeManager(base::CommandLine::ForCurrentProcess(), |
1063 &profile_manager()->GetProfileInfoCache())); | 1064 &profile_manager()->GetProfileInfoCache())); |
1064 #endif | 1065 #endif |
1065 } | 1066 } |
1066 | 1067 |
1067 void BrowserProcessImpl::CreateStatusTray() { | 1068 void BrowserProcessImpl::CreateStatusTray() { |
1068 DCHECK(status_tray_.get() == NULL); | 1069 DCHECK(status_tray_.get() == NULL); |
1069 status_tray_.reset(StatusTray::Create()); | 1070 status_tray_.reset(StatusTray::Create()); |
1070 } | 1071 } |
1071 | 1072 |
1072 void BrowserProcessImpl::CreatePrintPreviewDialogController() { | 1073 void BrowserProcessImpl::CreatePrintPreviewDialogController() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 return chrome::GetTotalBrowserCount() == 0 && chrome::WillKeepAlive() && | 1157 return chrome::GetTotalBrowserCount() == 0 && chrome::WillKeepAlive() && |
1157 upgrade_util::IsUpdatePendingRestart(); | 1158 upgrade_util::IsUpdatePendingRestart(); |
1158 } | 1159 } |
1159 | 1160 |
1160 // Switches to add when auto-restarting Chrome. | 1161 // Switches to add when auto-restarting Chrome. |
1161 const char* const kSwitchesToAddOnAutorestart[] = { | 1162 const char* const kSwitchesToAddOnAutorestart[] = { |
1162 switches::kNoStartupWindow | 1163 switches::kNoStartupWindow |
1163 }; | 1164 }; |
1164 | 1165 |
1165 void BrowserProcessImpl::RestartBackgroundInstance() { | 1166 void BrowserProcessImpl::RestartBackgroundInstance() { |
1166 CommandLine* old_cl = CommandLine::ForCurrentProcess(); | 1167 base::CommandLine* old_cl = base::CommandLine::ForCurrentProcess(); |
1167 scoped_ptr<CommandLine> new_cl(new CommandLine(old_cl->GetProgram())); | 1168 scoped_ptr<base::CommandLine> new_cl( |
| 1169 new base::CommandLine(old_cl->GetProgram())); |
1168 | 1170 |
1169 std::map<std::string, CommandLine::StringType> switches = | 1171 std::map<std::string, base::CommandLine::StringType> switches = |
1170 old_cl->GetSwitches(); | 1172 old_cl->GetSwitches(); |
1171 | 1173 |
1172 switches::RemoveSwitchesForAutostart(&switches); | 1174 switches::RemoveSwitchesForAutostart(&switches); |
1173 | 1175 |
1174 // Append the rest of the switches (along with their values, if any) | 1176 // Append the rest of the switches (along with their values, if any) |
1175 // to the new command line | 1177 // to the new command line |
1176 for (std::map<std::string, CommandLine::StringType>::const_iterator i = | 1178 for (std::map<std::string, base::CommandLine::StringType>::const_iterator i = |
1177 switches.begin(); i != switches.end(); ++i) { | 1179 switches.begin(); |
1178 CommandLine::StringType switch_value = i->second; | 1180 i != switches.end(); ++i) { |
| 1181 base::CommandLine::StringType switch_value = i->second; |
1179 if (switch_value.length() > 0) { | 1182 if (switch_value.length() > 0) { |
1180 new_cl->AppendSwitchNative(i->first, i->second); | 1183 new_cl->AppendSwitchNative(i->first, i->second); |
1181 } else { | 1184 } else { |
1182 new_cl->AppendSwitch(i->first); | 1185 new_cl->AppendSwitch(i->first); |
1183 } | 1186 } |
1184 } | 1187 } |
1185 | 1188 |
1186 // Ensure that our desired switches are set on the new process. | 1189 // Ensure that our desired switches are set on the new process. |
1187 for (size_t i = 0; i < arraysize(kSwitchesToAddOnAutorestart); ++i) { | 1190 for (size_t i = 0; i < arraysize(kSwitchesToAddOnAutorestart); ++i) { |
1188 if (!new_cl->HasSwitch(kSwitchesToAddOnAutorestart[i])) | 1191 if (!new_cl->HasSwitch(kSwitchesToAddOnAutorestart[i])) |
1189 new_cl->AppendSwitch(kSwitchesToAddOnAutorestart[i]); | 1192 new_cl->AppendSwitch(kSwitchesToAddOnAutorestart[i]); |
1190 } | 1193 } |
1191 | 1194 |
1192 DLOG(WARNING) << "Shutting down current instance of the browser."; | 1195 DLOG(WARNING) << "Shutting down current instance of the browser."; |
1193 chrome::AttemptExit(); | 1196 chrome::AttemptExit(); |
1194 | 1197 |
1195 // Transfer ownership to Upgrade. | 1198 // Transfer ownership to Upgrade. |
1196 upgrade_util::SetNewCommandLine(new_cl.release()); | 1199 upgrade_util::SetNewCommandLine(new_cl.release()); |
1197 } | 1200 } |
1198 | 1201 |
1199 void BrowserProcessImpl::OnAutoupdateTimer() { | 1202 void BrowserProcessImpl::OnAutoupdateTimer() { |
1200 if (CanAutorestartForUpdate()) { | 1203 if (CanAutorestartForUpdate()) { |
1201 DLOG(WARNING) << "Detected update. Restarting browser."; | 1204 DLOG(WARNING) << "Detected update. Restarting browser."; |
1202 RestartBackgroundInstance(); | 1205 RestartBackgroundInstance(); |
1203 } | 1206 } |
1204 } | 1207 } |
1205 | 1208 |
1206 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1209 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |