OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // | 40 // |
41 // The -- is required if switches are to be passed to Chrome; any switches | 41 // The -- is required if switches are to be passed to Chrome; any switches |
42 // before the -- will be interpreted by app_shim_win, and not passed to Chrome. | 42 // before the -- will be interpreted by app_shim_win, and not passed to Chrome. |
43 // | 43 // |
44 // If --chrome-sxs is specified, looks for the SxS (Canary) build of Chrome. | 44 // If --chrome-sxs is specified, looks for the SxS (Canary) build of Chrome. |
45 // This will always fail for Chromium. | 45 // This will always fail for Chromium. |
46 int WINAPI wWinMain(HINSTANCE instance, | 46 int WINAPI wWinMain(HINSTANCE instance, |
47 HINSTANCE prev_instance, | 47 HINSTANCE prev_instance, |
48 wchar_t* /*command_line*/, | 48 wchar_t* /*command_line*/, |
49 int show_command) { | 49 int show_command) { |
50 CommandLine::Init(0, nullptr); | 50 base::CommandLine::Init(0, nullptr); |
51 | 51 |
52 // Log to stderr. Otherwise it will log to a file by default. | 52 // Log to stderr. Otherwise it will log to a file by default. |
53 logging::LoggingSettings logging_settings; | 53 logging::LoggingSettings logging_settings; |
54 logging_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 54 logging_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
55 logging::InitLogging(logging_settings); | 55 logging::InitLogging(logging_settings); |
56 | 56 |
57 // Get the command-line for the Chrome binary. | 57 // Get the command-line for the Chrome binary. |
58 // --chrome-sxs on the command line means we should run the canary binary. | 58 // --chrome-sxs on the command line means we should run the canary binary. |
59 bool is_canary = | 59 bool is_canary = |
60 base::CommandLine::ForCurrentProcess()->HasSwitch(kChromeSxS); | 60 base::CommandLine::ForCurrentProcess()->HasSwitch(kChromeSxS); |
61 base::FilePath chrome_path = GetChromeExePath(is_canary); | 61 base::FilePath chrome_path = GetChromeExePath(is_canary); |
62 if (chrome_path.empty()) { | 62 if (chrome_path.empty()) { |
63 LOG(ERROR) << "Could not find chrome.exe path in the registry."; | 63 LOG(ERROR) << "Could not find chrome.exe path in the registry."; |
64 return kNoProgram; | 64 return kNoProgram; |
65 } | 65 } |
66 CommandLine command_line(chrome_path); | 66 base::CommandLine command_line(chrome_path); |
67 | 67 |
68 // Get the command-line arguments for the subprocess, consisting of the | 68 // Get the command-line arguments for the subprocess, consisting of the |
69 // arguments (but not switches) to this binary. This gets everything after the | 69 // arguments (but not switches) to this binary. This gets everything after the |
70 // "--". | 70 // "--". |
71 for (const auto& arg : CommandLine::ForCurrentProcess()->GetArgs()) | 71 for (const auto& arg : base::CommandLine::ForCurrentProcess()->GetArgs()) |
72 command_line.AppendArgNative(arg); | 72 command_line.AppendArgNative(arg); |
73 | 73 |
74 if (!base::LaunchProcess(command_line, base::LaunchOptions()).IsValid()) { | 74 if (!base::LaunchProcess(command_line, base::LaunchOptions()).IsValid()) { |
75 LOG(ERROR) << "Could not run chrome.exe."; | 75 LOG(ERROR) << "Could not run chrome.exe."; |
76 return kLaunchFailure; | 76 return kLaunchFailure; |
77 } | 77 } |
78 | 78 |
79 return kOK; | 79 return kOK; |
80 } | 80 } |
OLD | NEW |