Upload upstream chromium 73.0.3683.0
[platform/framework/web/chromium-efl.git] / chrome / chrome_proxy / chrome_proxy_main_win.cc
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.
4
5 #include <windows.h>
6
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"
12
13 namespace {
14
15 constexpr base::FilePath::CharType kChromeExecutable[] =
16     FILE_PATH_LITERAL("chrome.exe");
17
18 constexpr base::FilePath::CharType kChromeProxyExecutable[] =
19     FILE_PATH_LITERAL("chrome_proxy.exe");
20
21 }  // namespace
22
23 int WINAPI wWinMain(HINSTANCE instance,
24                     HINSTANCE prev_instance,
25                     wchar_t* /*command_line*/,
26                     int show_command) {
27   base::CommandLine::Init(0, nullptr);
28
29   logging::LoggingSettings logging_settings;
30   logging_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
31   logging::InitLogging(logging_settings);
32
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));
36
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]);
45
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());
50
51   return 0;
52 }