| Index: chrome/app/client_util.cc
|
| diff --git a/chrome/app/client_util.cc b/chrome/app/client_util.cc
|
| index 0b487242030821d74cb945c75485a65ff568dbab..2459fd0d27a236a1d30c60e7b1bd573126bafd08 100644
|
| --- a/chrome/app/client_util.cc
|
| +++ b/chrome/app/client_util.cc
|
| @@ -10,14 +10,18 @@
|
| #include "base/debug/trace_event.h"
|
| #include "base/environment.h"
|
| #include "base/file_version_info.h"
|
| +#include "base/files/file_path.h"
|
| #include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/process/launch.h"
|
| #include "base/strings/string16.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/version.h"
|
| +#include "base/win/scoped_process_information.h"
|
| +#include "base/win/startup_information.h"
|
| #include "base/win/windows_version.h"
|
| #include "chrome/app/chrome_crash_reporter_client.h"
|
| #include "chrome/app/client_util.h"
|
| @@ -30,6 +34,8 @@
|
| #include "chrome/installer/util/google_update_settings.h"
|
| #include "chrome/installer/util/install_util.h"
|
| #include "chrome/installer/util/util_constants.h"
|
| +#include "components/browser_watcher/watcher_client_win.h"
|
| +#include "components/browser_watcher/watcher_main_api_win.h"
|
| #include "components/crash/app/breakpad_win.h"
|
| #include "components/crash/app/crash_reporter_client.h"
|
| #include "components/metrics/client_info.h"
|
| @@ -125,15 +131,22 @@ HMODULE MainDllLoader::Load(base::string16* version,
|
| const base::string16 executable_dir(GetExecutablePath());
|
| *out_file = executable_dir;
|
|
|
| - const wchar_t* dll_name = metro_mode_ ?
|
| - installer::kChromeMetroDll :
|
| -#if !defined(CHROME_MULTIPLE_DLL)
|
| - installer::kChromeDll;
|
| + const wchar_t* dll_name = NULL;
|
| + if (metro_mode_)
|
| + dll_name = installer::kChromeMetroDll;
|
| +
|
| + if (process_type_ == "service" || process_type_.empty()) {
|
| + dll_name = installer::kChromeDll;
|
| + } else if (process_type_ == "watcher") {
|
| + dll_name = browser_watcher::kWatcherDll;
|
| + } else {
|
| +#if defined(CHROME_MULTIPLE_DLL)
|
| + dll_name = installer::kChromeChildDll;
|
| #else
|
| - (process_type_ == "service") || process_type_.empty() ?
|
| - installer::kChromeDll :
|
| - installer::kChromeChildDll;
|
| + dll_name = installer::kChromeDll;
|
| #endif
|
| + }
|
| +
|
| const bool pre_read = !metro_mode_;
|
| HMODULE dll = LoadModuleWithDirectory(out_file, dll_name, pre_read);
|
| if (!dll) {
|
| @@ -176,6 +189,22 @@ int MainDllLoader::Launch(HINSTANCE instance) {
|
| return chrome_metro_main();
|
| }
|
|
|
| + if (process_type_ == "watcher") {
|
| + HMODULE watcher_dll = Load(&version, &file);
|
| + if (watcher_dll) {
|
| + browser_watcher::WatcherMainFunction watcher_main =
|
| + reinterpret_cast<browser_watcher::WatcherMainFunction>(
|
| + ::GetProcAddress(watcher_dll,
|
| + browser_watcher::kWatcherDLLEntrypoint));
|
| +
|
| + watcher_main(chrome::kBrowserExitCodesRegistryPath);
|
| +
|
| + return content::RESULT_CODE_NORMAL_EXIT;
|
| + } else {
|
| + return chrome::RESULT_CODE_MISSING_DATA;
|
| + }
|
| + }
|
| +
|
| // Initialize the sandbox services.
|
| sandbox::SandboxInterfaceInfo sandbox_info = {0};
|
| content::InitializeSandboxInfo(&sandbox_info);
|
| @@ -199,7 +228,7 @@ int MainDllLoader::Launch(HINSTANCE instance) {
|
| scoped_ptr<base::Environment> env(base::Environment::Create());
|
| env->SetVar(chrome::kChromeVersionEnvVar, base::WideToUTF8(version));
|
|
|
| - OnBeforeLaunch(file);
|
| + OnBeforeLaunch(process_type_, file);
|
| DLL_MAIN chrome_main =
|
| reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain"));
|
| int rc = chrome_main(instance, &sandbox_info);
|
| @@ -226,11 +255,33 @@ void MainDllLoader::RelaunchChromeBrowserWithNewCommandLineIfNeeded() {
|
|
|
| class ChromeDllLoader : public MainDllLoader {
|
| protected:
|
| - virtual void OnBeforeLaunch(const base::string16& dll_path) {
|
| + virtual void OnBeforeLaunch(const std::string& process_type,
|
| + const base::string16& dll_path) override;
|
| + virtual int OnBeforeExit(int return_code,
|
| + const base::string16& dll_path) override;
|
| +};
|
| +
|
| +void ChromeDllLoader::OnBeforeLaunch(const std::string& process_type,
|
| + const base::string16& dll_path) {
|
| + if (process_type.empty()) {
|
| RecordDidRun(dll_path);
|
| +
|
| + // Launch the watcher process if stats collection consent has been granted.
|
| + if (g_chrome_crash_client.Get().GetCollectStatsConsent()) {
|
| + wchar_t exe_path[MAX_PATH];
|
| + ::GetModuleFileNameW(NULL, exe_path, MAX_PATH);
|
| +
|
| + base::CommandLine cmd_line = base::CommandLine(base::FilePath(exe_path));
|
| + cmd_line.AppendSwitchASCII(switches::kProcessType, "watcher");
|
| + browser_watcher::WatcherClient watcher_client(cmd_line);
|
| +
|
| + watcher_client.LaunchWatcher();
|
| + }
|
| + }
|
| }
|
|
|
| - virtual int OnBeforeExit(int return_code, const base::string16& dll_path) {
|
| +int ChromeDllLoader::OnBeforeExit(int return_code,
|
| + const base::string16& dll_path) {
|
| // NORMAL_EXIT_CANCEL is used for experiments when the user cancels
|
| // so we need to reset the did_run signal so omaha does not count
|
| // this run as active usage.
|
| @@ -239,13 +290,13 @@ class ChromeDllLoader : public MainDllLoader {
|
| }
|
| return return_code;
|
| }
|
| -};
|
|
|
| //=============================================================================
|
|
|
| class ChromiumDllLoader : public MainDllLoader {
|
| protected:
|
| - virtual void OnBeforeLaunch(const base::string16& dll_path) override {
|
| + virtual void OnBeforeLaunch(const std::string& process_type,
|
| + const base::string16& dll_path) override {
|
| }
|
| virtual int OnBeforeExit(int return_code,
|
| const base::string16& dll_path) override {
|
|
|