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 <windows.h> | 5 #include <windows.h> |
6 #include <shlwapi.h> | 6 #include <shlwapi.h> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/environment.h" | 11 #include "base/environment.h" |
12 #include "base/file_version_info.h" | 12 #include "base/file_version_info.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "base/version.h" | 20 #include "base/version.h" |
21 #include "base/win/scoped_handle.h" | 21 #include "base/win/scoped_handle.h" |
22 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" |
23 #include "chrome/app/chrome_crash_reporter_client.h" | 23 #include "chrome/app/chrome_crash_reporter_client.h" |
| 24 #include "chrome/app/chrome_watcher_client_win.h" |
24 #include "chrome/app/chrome_watcher_command_line_win.h" | 25 #include "chrome/app/chrome_watcher_command_line_win.h" |
25 #include "chrome/app/client_util.h" | 26 #include "chrome/app/client_util.h" |
26 #include "chrome/app/image_pre_reader_win.h" | 27 #include "chrome/app/image_pre_reader_win.h" |
27 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" | 28 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" |
28 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" |
29 #include "chrome/common/chrome_result_codes.h" | 30 #include "chrome/common/chrome_result_codes.h" |
30 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
31 #include "chrome/common/env_vars.h" | 32 #include "chrome/common/env_vars.h" |
32 #include "chrome/installer/util/google_update_constants.h" | 33 #include "chrome/installer/util/google_update_constants.h" |
33 #include "chrome/installer/util/google_update_settings.h" | 34 #include "chrome/installer/util/google_update_settings.h" |
34 #include "chrome/installer/util/install_util.h" | 35 #include "chrome/installer/util/install_util.h" |
35 #include "chrome/installer/util/util_constants.h" | 36 #include "chrome/installer/util/util_constants.h" |
36 #include "components/browser_watcher/watcher_client_win.h" | |
37 #include "components/crash/app/breakpad_win.h" | 37 #include "components/crash/app/breakpad_win.h" |
38 #include "components/crash/app/crash_reporter_client.h" | 38 #include "components/crash/app/crash_reporter_client.h" |
39 #include "components/metrics/client_info.h" | 39 #include "components/metrics/client_info.h" |
40 #include "content/public/app/startup_helper_win.h" | 40 #include "content/public/app/startup_helper_win.h" |
41 #include "sandbox/win/src/sandbox.h" | 41 #include "sandbox/win/src/sandbox.h" |
42 | 42 |
43 namespace { | 43 namespace { |
44 // The entry point signature of chrome.dll. | 44 // The entry point signature of chrome.dll. |
45 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); | 45 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); |
46 | 46 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 HMODULE metro_dll = Load(&version, &file); | 172 HMODULE metro_dll = Load(&version, &file); |
173 if (!metro_dll) | 173 if (!metro_dll) |
174 return chrome::RESULT_CODE_MISSING_DATA; | 174 return chrome::RESULT_CODE_MISSING_DATA; |
175 | 175 |
176 InitMetro chrome_metro_main = | 176 InitMetro chrome_metro_main = |
177 reinterpret_cast<InitMetro>(::GetProcAddress(metro_dll, "InitMetro")); | 177 reinterpret_cast<InitMetro>(::GetProcAddress(metro_dll, "InitMetro")); |
178 return chrome_metro_main(); | 178 return chrome_metro_main(); |
179 } | 179 } |
180 | 180 |
181 if (process_type_ == "watcher") { | 181 if (process_type_ == "watcher") { |
182 base::win::ScopedHandle parent_process = | 182 base::win::ScopedHandle parent_process; |
183 InterpretChromeWatcherCommandLine(cmd_line); | 183 base::win::ScopedHandle on_initialized_event; |
184 if (!parent_process.IsValid()) | 184 if (!InterpretChromeWatcherCommandLine(cmd_line, &parent_process, |
| 185 &on_initialized_event)) { |
185 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; | 186 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; |
| 187 } |
186 | 188 |
187 // Intentionally leaked. | 189 // Intentionally leaked. |
188 HMODULE watcher_dll = Load(&version, &file); | 190 HMODULE watcher_dll = Load(&version, &file); |
189 if (!watcher_dll) | 191 if (!watcher_dll) |
190 return chrome::RESULT_CODE_MISSING_DATA; | 192 return chrome::RESULT_CODE_MISSING_DATA; |
191 | 193 |
192 ChromeWatcherMainFunction watcher_main = | 194 ChromeWatcherMainFunction watcher_main = |
193 reinterpret_cast<ChromeWatcherMainFunction>( | 195 reinterpret_cast<ChromeWatcherMainFunction>( |
194 ::GetProcAddress(watcher_dll, kChromeWatcherDLLEntrypoint)); | 196 ::GetProcAddress(watcher_dll, kChromeWatcherDLLEntrypoint)); |
195 return watcher_main(chrome::kBrowserExitCodesRegistryPath, | 197 return watcher_main(chrome::kBrowserExitCodesRegistryPath, |
196 parent_process.Take()); | 198 parent_process.Take(), on_initialized_event.Take()); |
197 } | 199 } |
198 | 200 |
199 // Initialize the sandbox services. | 201 // Initialize the sandbox services. |
200 sandbox::SandboxInterfaceInfo sandbox_info = {0}; | 202 sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
201 content::InitializeSandboxInfo(&sandbox_info); | 203 content::InitializeSandboxInfo(&sandbox_info); |
202 | 204 |
203 crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer()); | 205 crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer()); |
204 bool exit_now = true; | 206 bool exit_now = true; |
205 if (process_type_.empty()) { | 207 if (process_type_.empty()) { |
206 if (breakpad::ShowRestartDialogIfCrashed(&exit_now)) { | 208 if (breakpad::ShowRestartDialogIfCrashed(&exit_now)) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 255 |
254 void ChromeDllLoader::OnBeforeLaunch(const std::string& process_type, | 256 void ChromeDllLoader::OnBeforeLaunch(const std::string& process_type, |
255 const base::FilePath& dll_path) { | 257 const base::FilePath& dll_path) { |
256 if (process_type.empty()) { | 258 if (process_type.empty()) { |
257 RecordDidRun(dll_path); | 259 RecordDidRun(dll_path); |
258 | 260 |
259 // Launch the watcher process if stats collection consent has been granted. | 261 // Launch the watcher process if stats collection consent has been granted. |
260 if (g_chrome_crash_client.Get().GetCollectStatsConsent()) { | 262 if (g_chrome_crash_client.Get().GetCollectStatsConsent()) { |
261 base::char16 exe_path[MAX_PATH]; | 263 base::char16 exe_path[MAX_PATH]; |
262 ::GetModuleFileNameW(nullptr, exe_path, arraysize(exe_path)); | 264 ::GetModuleFileNameW(nullptr, exe_path, arraysize(exe_path)); |
263 | 265 ChromeWatcherClient watcher_client(base::Bind( |
264 browser_watcher::WatcherClient watcher_client(base::Bind( | |
265 &GenerateChromeWatcherCommandLine, base::FilePath(exe_path))); | 266 &GenerateChromeWatcherCommandLine, base::FilePath(exe_path))); |
266 watcher_client.LaunchWatcher(); | 267 watcher_client.LaunchWatcher(); |
267 } | 268 } |
268 } | 269 } |
269 } | 270 } |
270 | 271 |
271 int ChromeDllLoader::OnBeforeExit(int return_code, | 272 int ChromeDllLoader::OnBeforeExit(int return_code, |
272 const base::FilePath& dll_path) { | 273 const base::FilePath& dll_path) { |
273 // NORMAL_EXIT_CANCEL is used for experiments when the user cancels | 274 // NORMAL_EXIT_CANCEL is used for experiments when the user cancels |
274 // so we need to reset the did_run signal so omaha does not count | 275 // so we need to reset the did_run signal so omaha does not count |
(...skipping 15 matching lines...) Expand all Loading... |
290 } | 291 } |
291 }; | 292 }; |
292 | 293 |
293 MainDllLoader* MakeMainDllLoader() { | 294 MainDllLoader* MakeMainDllLoader() { |
294 #if defined(GOOGLE_CHROME_BUILD) | 295 #if defined(GOOGLE_CHROME_BUILD) |
295 return new ChromeDllLoader(); | 296 return new ChromeDllLoader(); |
296 #else | 297 #else |
297 return new ChromiumDllLoader(); | 298 return new ChromiumDllLoader(); |
298 #endif | 299 #endif |
299 } | 300 } |
OLD | NEW |