OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <windows.h> | 5 #include <windows.h> |
6 #include <shellapi.h> | 6 #include <shellapi.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 NOTREACHED(); | 212 NOTREACHED(); |
213 } | 213 } |
214 return true; | 214 return true; |
215 } | 215 } |
216 | 216 |
217 bool CreateUniqueChromeEvent() { | 217 bool CreateUniqueChromeEvent() { |
218 std::wstring exe; | 218 std::wstring exe; |
219 PathService::Get(base::FILE_EXE, &exe); | 219 PathService::Get(base::FILE_EXE, &exe); |
220 std::replace(exe.begin(), exe.end(), '\\', '!'); | 220 std::replace(exe.begin(), exe.end(), '\\', '!'); |
221 std::transform(exe.begin(), exe.end(), exe.begin(), tolower); | 221 std::transform(exe.begin(), exe.end(), exe.begin(), tolower); |
| 222 exe = L"Global\\" + exe; |
222 HANDLE handle = CreateEvent(NULL, TRUE, TRUE, exe.c_str()); | 223 HANDLE handle = CreateEvent(NULL, TRUE, TRUE, exe.c_str()); |
223 bool already_running = false; | 224 int error = GetLastError(); |
224 if (GetLastError() == ERROR_ALREADY_EXISTS) { | 225 return (error == ERROR_ALREADY_EXISTS || error == ERROR_ACCESS_DENIED); |
225 already_running = true; | |
226 CloseHandle(handle); | |
227 } | |
228 return already_running; | |
229 } | 226 } |
230 | 227 |
231 // Check if there is any machine level Chrome installed on the current | 228 // Check if there is any machine level Chrome installed on the current |
232 // machine. If yes and the current Chrome process is user level, we do not | 229 // machine. If yes and the current Chrome process is user level, we do not |
233 // allow the user level Chrome to run. So we notify the user and uninstall | 230 // allow the user level Chrome to run. So we notify the user and uninstall |
234 // user level Chrome. | 231 // user level Chrome. |
235 bool CheckMachineLevelInstall() { | 232 bool CheckMachineLevelInstall() { |
236 scoped_ptr<installer::Version> version(InstallUtil::GetChromeVersion(true)); | 233 scoped_ptr<installer::Version> version(InstallUtil::GetChromeVersion(true)); |
237 if (version.get()) { | 234 if (version.get()) { |
238 std::wstring exe; | 235 std::wstring exe; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 428 |
432 // Importing other browser settings is done in a browser-like process | 429 // Importing other browser settings is done in a browser-like process |
433 // that exits when this task has finished. | 430 // that exits when this task has finished. |
434 if (parsed_command_line.HasSwitch(switches::kImport)) | 431 if (parsed_command_line.HasSwitch(switches::kImport)) |
435 return FirstRun::ImportNow(profile, parsed_command_line); | 432 return FirstRun::ImportNow(profile, parsed_command_line); |
436 | 433 |
437 // When another process is running, use it instead of starting us. | 434 // When another process is running, use it instead of starting us. |
438 if (message_window.NotifyOtherProcess(show_command)) | 435 if (message_window.NotifyOtherProcess(show_command)) |
439 return ResultCodes::NORMAL_EXIT; | 436 return ResultCodes::NORMAL_EXIT; |
440 | 437 |
441 // Sometimes we end up killing browser process (http://b/1308130) so make | |
442 // sure we recreate unique event to indicate running browser process. | |
443 message_window.HuntForZombieChromeProcesses(); | 438 message_window.HuntForZombieChromeProcesses(); |
444 already_running = (already_running && CreateUniqueChromeEvent()); | |
445 | 439 |
446 // Do the tasks if chrome has been upgraded while it was last running. | 440 // Do the tasks if chrome has been upgraded while it was last running. |
447 if (!already_running && DoUpgradeTasks(parsed_command_line)) { | 441 if (!already_running && DoUpgradeTasks(parsed_command_line)) { |
448 return ResultCodes::NORMAL_EXIT; | 442 return ResultCodes::NORMAL_EXIT; |
449 } | 443 } |
450 | 444 |
451 // Check if there is any machine level Chrome installed on the current | 445 // Check if there is any machine level Chrome installed on the current |
452 // machine. If yes and the current Chrome process is user level, we do not | 446 // machine. If yes and the current Chrome process is user level, we do not |
453 // allow the user level Chrome to run. So we notify the user and uninstall | 447 // allow the user level Chrome to run. So we notify the user and uninstall |
454 // user level Chrome. | 448 // user level Chrome. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 // The following should ONLY be called when in single threaded mode. It is | 594 // The following should ONLY be called when in single threaded mode. It is |
601 // unsafe to do this cleanup if other threads are still active. | 595 // unsafe to do this cleanup if other threads are still active. |
602 // It is also very unnecessary, so I'm only doing this in debug to satisfy | 596 // It is also very unnecessary, so I'm only doing this in debug to satisfy |
603 // purify. | 597 // purify. |
604 if (tracking_objects) | 598 if (tracking_objects) |
605 tracked_objects::ThreadData::ShutdownSingleThreadedCleanup(); | 599 tracked_objects::ThreadData::ShutdownSingleThreadedCleanup(); |
606 #endif // NDEBUG | 600 #endif // NDEBUG |
607 | 601 |
608 return result_code; | 602 return result_code; |
609 } | 603 } |
OLD | NEW |