1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/logging.h"
10 #include "base/path_service.h"
11 #include "base/process/launch.h"
15 constexpr base::FilePath::CharType kChromeExecutable[] =
16 FILE_PATH_LITERAL("chrome.exe");
18 constexpr base::FilePath::CharType kChromeProxyExecutable[] =
19 FILE_PATH_LITERAL("chrome_proxy.exe");
23 int WINAPI wWinMain(HINSTANCE instance,
24 HINSTANCE prev_instance,
25 wchar_t* /*command_line*/,
27 base::CommandLine::Init(0, nullptr);
29 logging::LoggingSettings logging_settings;
30 logging_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
31 logging::InitLogging(logging_settings);
33 base::FilePath chrome_dir;
34 CHECK(base::PathService::Get(base::DIR_EXE, &chrome_dir));
35 base::CommandLine chrome_command_line(chrome_dir.Append(kChromeExecutable));
37 // Forward all command line arguments.
38 const std::vector<base::string16>& argv =
39 base::CommandLine::ForCurrentProcess()->argv();
40 // The first one is always the current executable path.
41 CHECK(argv.size() > 0);
42 CHECK_EQ(base::FilePath(argv[0]).BaseName().value(), kChromeProxyExecutable);
43 for (size_t i = 1; i < argv.size(); ++i)
44 chrome_command_line.AppendArgNative(argv[i]);
46 base::LaunchOptions launch_options;
47 launch_options.current_directory = chrome_dir;
48 launch_options.grant_foreground_privilege = true;
49 CHECK(base::LaunchProcess(chrome_command_line, launch_options).IsValid());