OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_shutdown.h" | 5 #include "chrome/browser/browser_shutdown.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/histogram.h" | 12 #include "base/histogram.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/process_util.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/thread.h" | 16 #include "base/thread.h" |
16 #include "base/time.h" | 17 #include "base/time.h" |
17 #include "base/waitable_event.h" | 18 #include "base/waitable_event.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chrome_thread.h" | 21 #include "chrome/browser/chrome_thread.h" |
21 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 22 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
22 #include "chrome/browser/first_run.h" | 23 #include "chrome/browser/first_run.h" |
23 #include "chrome/browser/jankometer.h" | 24 #include "chrome/browser/jankometer.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 ResourceBundle::CleanupSharedInstance(); | 158 ResourceBundle::CleanupSharedInstance(); |
158 | 159 |
159 #if defined(OS_WIN) | 160 #if defined(OS_WIN) |
160 if (!Upgrade::IsBrowserAlreadyRunning() && | 161 if (!Upgrade::IsBrowserAlreadyRunning() && |
161 shutdown_type_ != browser_shutdown::END_SESSION) { | 162 shutdown_type_ != browser_shutdown::END_SESSION) { |
162 Upgrade::SwapNewChromeExeIfPresent(); | 163 Upgrade::SwapNewChromeExeIfPresent(); |
163 } | 164 } |
164 #endif | 165 #endif |
165 | 166 |
166 if (restart_last_session) { | 167 if (restart_last_session) { |
167 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 168 #if !defined(OS_CHROMEOS) |
168 // Make sure to relaunch the browser with the same command line and add | 169 // Make sure to relaunch the browser with the same command line and add |
169 // Restore Last Session flag if session restore is not set. | 170 // Restore Last Session flag if session restore is not set. |
170 CommandLine command_line(*CommandLine::ForCurrentProcess()); | 171 CommandLine command_line(*CommandLine::ForCurrentProcess()); |
171 if (!command_line.HasSwitch(switches::kRestoreLastSession)) | 172 if (!command_line.HasSwitch(switches::kRestoreLastSession)) |
172 command_line.AppendSwitch(switches::kRestoreLastSession); | 173 command_line.AppendSwitch(switches::kRestoreLastSession); |
| 174 #if defined(OS_WIN) || defined(OS_LINUX) |
173 Upgrade::RelaunchChromeBrowser(command_line); | 175 Upgrade::RelaunchChromeBrowser(command_line); |
| 176 #endif // defined(OS_WIN) || defined(OS_LINUX) |
| 177 |
| 178 #if defined(OS_MACOSX) |
| 179 command_line.AppendSwitch(switches::kActivateOnLaunch); |
| 180 base::LaunchApp(command_line, false, false, NULL); |
| 181 #endif // defined(OS_MACOSX) |
| 182 |
174 #else | 183 #else |
175 NOTIMPLEMENTED(); | 184 NOTIMPLEMENTED(); |
176 #endif | 185 #endif // !defined(OS_CHROMEOS) |
177 } | 186 } |
178 | 187 |
179 if (shutdown_type_ > NOT_VALID && shutdown_num_processes_ > 0) { | 188 if (shutdown_type_ > NOT_VALID && shutdown_num_processes_ > 0) { |
180 // Measure total shutdown time as late in the process as possible | 189 // Measure total shutdown time as late in the process as possible |
181 // and then write it to a file to be read at startup. | 190 // and then write it to a file to be read at startup. |
182 // We can't use prefs since all services are shutdown at this point. | 191 // We can't use prefs since all services are shutdown at this point. |
183 TimeDelta shutdown_delta = Time::Now() - shutdown_started_; | 192 TimeDelta shutdown_delta = Time::Now() - shutdown_started_; |
184 std::string shutdown_ms = Int64ToString(shutdown_delta.InMilliseconds()); | 193 std::string shutdown_ms = Int64ToString(shutdown_delta.InMilliseconds()); |
185 int len = static_cast<int>(shutdown_ms.length()) + 1; | 194 int len = static_cast<int>(shutdown_ms.length()) + 1; |
186 FilePath shutdown_ms_file = GetShutdownMsPath(); | 195 FilePath shutdown_ms_file = GetShutdownMsPath(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 void SetTryingToQuit(bool quitting) { | 266 void SetTryingToQuit(bool quitting) { |
258 g_trying_to_quit = quitting; | 267 g_trying_to_quit = quitting; |
259 } | 268 } |
260 | 269 |
261 bool IsTryingToQuit() { | 270 bool IsTryingToQuit() { |
262 return g_trying_to_quit; | 271 return g_trying_to_quit; |
263 } | 272 } |
264 #endif | 273 #endif |
265 | 274 |
266 } // namespace browser_shutdown | 275 } // namespace browser_shutdown |
OLD | NEW |