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 // This binary is a workaround for Windows 10 start menu pinning icon bug:
24 // https://crbug.com/732357.
26 // When a shortcut is pinned in the Windows 10 start menu Windows will follow
27 // the shortcut, find the target executable, look for a <target>.manifest file
28 // in the same directory and use the icon specified in there for the start menu
29 // pin. Because bookmark app shortcuts are shortcuts to Chrome (plus a few
30 // command line parameters) Windows ends up using the Chrome icon specified in
31 // chrome.VisualElementsManifest.xml instead of the site's icon stored inside
34 // The chrome_proxy.exe binary workaround "fixes" this by having bookmark app
35 // shortcuts target chrome_proxy.exe instead of chrome.exe such that Windows
36 // won't find a manifest and falls back to using the shortcut's icons as
37 // originally intended.
38 int WINAPI wWinMain(HINSTANCE instance,
39 HINSTANCE prev_instance,
40 wchar_t* /*command_line*/,
42 base::CommandLine::Init(0, nullptr);
44 logging::LoggingSettings logging_settings;
45 logging_settings.logging_dest =
46 logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR;
47 logging::InitLogging(logging_settings);
49 base::FilePath chrome_dir;
50 CHECK(base::PathService::Get(base::DIR_EXE, &chrome_dir));
51 base::CommandLine chrome_command_line(chrome_dir.Append(kChromeExecutable));
53 // Forward all command line arguments.
54 const std::vector<base::string16>& argv =
55 base::CommandLine::ForCurrentProcess()->argv();
56 // The first one is always the current executable path.
57 CHECK(argv.size() > 0);
58 CHECK_EQ(base::FilePath(argv[0]).BaseName().value(), kChromeProxyExecutable);
59 for (size_t i = 1; i < argv.size(); ++i)
60 chrome_command_line.AppendArgNative(argv[i]);
62 base::LaunchOptions launch_options;
63 launch_options.current_directory = chrome_dir;
64 launch_options.grant_foreground_privilege = true;
65 CHECK(base::LaunchProcess(chrome_command_line, launch_options).IsValid());