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 <tchar.h> | 6 #include <tchar.h> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug_on_start.h" | 11 #include "base/debug_on_start.h" |
12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
13 #include "base/win_util.h" | 13 #include "base/win_util.h" |
14 #include "chrome/app/breakpad.h" | 14 #include "chrome/app/breakpad.h" |
15 #include "chrome/app/client_util.h" | 15 #include "chrome/app/client_util.h" |
16 #include "chrome/app/google_update_client.h" | 16 #include "chrome/app/google_update_client.h" |
17 #include "chrome/app/result_codes.h" | 17 #include "chrome/app/result_codes.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "sandbox/src/sandbox_factory.h" | 19 #include "sandbox/src/sandbox_factory.h" |
20 #include "sandbox/src/dep.h" | 20 #include "sandbox/src/dep.h" |
21 | 21 |
22 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance, | 22 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance, |
23 wchar_t* command_line, int show_command) { | 23 wchar_t* command_line, int) { |
24 process_util::EnableTerminationOnHeapCorruption(); | 24 process_util::EnableTerminationOnHeapCorruption(); |
25 | 25 |
26 // The exit manager is in charge of calling the dtors of singletons. | 26 // The exit manager is in charge of calling the dtors of singletons. |
27 base::AtExitManager exit_manager; | 27 base::AtExitManager exit_manager; |
28 | 28 |
29 win_util::WinVersion win_version = win_util::GetWinVersion(); | 29 win_util::WinVersion win_version = win_util::GetWinVersion(); |
30 if (win_version == win_util::WINVERSION_XP || | 30 if (win_version == win_util::WINVERSION_XP || |
31 win_version == win_util::WINVERSION_SERVER_2003) { | 31 win_version == win_util::WINVERSION_SERVER_2003) { |
32 // On Vista, this is unnecessary since it is controlled through the | 32 // On Vista, this is unnecessary since it is controlled through the |
33 // /NXCOMPAT linker flag. | 33 // /NXCOMPAT linker flag. |
(...skipping 21 matching lines...) Expand all Loading... |
55 | 55 |
56 bool exit_now = false; | 56 bool exit_now = false; |
57 if (ShowRestartDialogIfCrashed(&exit_now)) { | 57 if (ShowRestartDialogIfCrashed(&exit_now)) { |
58 // We have restarted because of a previous crash. The user might | 58 // We have restarted because of a previous crash. The user might |
59 // decide that he does not want to continue. | 59 // decide that he does not want to continue. |
60 if (exit_now) | 60 if (exit_now) |
61 return ResultCodes::NORMAL_EXIT; | 61 return ResultCodes::NORMAL_EXIT; |
62 } | 62 } |
63 | 63 |
64 int ret = 0; | 64 int ret = 0; |
65 if (client.Launch(instance, &sandbox_info, command_line, show_command, | 65 if (client.Launch(instance, &sandbox_info, command_line, "ChromeMain", |
66 "ChromeMain", &ret)) { | 66 &ret)) { |
67 return ret; | 67 return ret; |
68 } | 68 } |
69 #else | 69 #else |
70 wchar_t exe_path[MAX_PATH] = {0}; | 70 wchar_t exe_path[MAX_PATH] = {0}; |
71 client_util::GetExecutablePath(exe_path); | 71 client_util::GetExecutablePath(exe_path); |
72 wchar_t *version; | 72 wchar_t *version; |
73 std::wstring dll_path; | 73 std::wstring dll_path; |
74 if (client_util::GetChromiumVersion(exe_path, L"Software\\Chromium", | 74 if (client_util::GetChromiumVersion(exe_path, L"Software\\Chromium", |
75 &version)) { | 75 &version)) { |
76 dll_path = exe_path; | 76 dll_path = exe_path; |
77 dll_path.append(version); | 77 dll_path.append(version); |
78 if (client_util::FileExists(dll_path.c_str())) | 78 if (client_util::FileExists(dll_path.c_str())) |
79 ::SetCurrentDirectory(dll_path.c_str()); | 79 ::SetCurrentDirectory(dll_path.c_str()); |
80 delete[] version; | 80 delete[] version; |
81 } | 81 } |
82 | 82 |
83 HINSTANCE dll_handle = ::LoadLibraryEx(dll_name, NULL, | 83 HINSTANCE dll_handle = ::LoadLibraryEx(dll_name, NULL, |
84 LOAD_WITH_ALTERED_SEARCH_PATH); | 84 LOAD_WITH_ALTERED_SEARCH_PATH); |
85 | 85 |
86 // Initialize the crash reporter. | 86 // Initialize the crash reporter. |
87 InitCrashReporter(client_util::GetDLLPath(dll_name, dll_path)); | 87 InitCrashReporter(client_util::GetDLLPath(dll_name, dll_path)); |
88 | 88 |
89 if (NULL != dll_handle) { | 89 if (NULL != dll_handle) { |
90 client_util::DLL_MAIN entry = reinterpret_cast<client_util::DLL_MAIN>( | 90 client_util::DLL_MAIN entry = reinterpret_cast<client_util::DLL_MAIN>( |
91 ::GetProcAddress(dll_handle, "ChromeMain")); | 91 ::GetProcAddress(dll_handle, "ChromeMain")); |
92 if (NULL != entry) | 92 if (NULL != entry) |
93 return (entry)(instance, &sandbox_info, command_line, show_command); | 93 return (entry)(instance, &sandbox_info, command_line); |
94 } | 94 } |
95 #endif | 95 #endif |
96 | 96 |
97 return ResultCodes::GOOGLE_UPDATE_LAUNCH_FAILED; | 97 return ResultCodes::GOOGLE_UPDATE_LAUNCH_FAILED; |
98 } | 98 } |
99 | 99 |
OLD | NEW |