Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "apps/app_host/binaries_installer.h" | 7 #include "apps/app_host/binaries_installer.h" |
| 8 #include "apps/app_host/operation_launcher.h" | |
| 8 #include "apps/app_host/update.h" | 9 #include "apps/app_host/update.h" |
| 9 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/process_util.h" | |
| 14 #include "chrome/installer/launcher_support/chrome_launcher_support.h" | 14 #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
| 15 | 15 |
| 16 | |
|
gab
2013/03/28 03:06:06
nit: Remove extra empty line.
| |
| 16 int APIENTRY wWinMain(HINSTANCE, HINSTANCE, wchar_t*, int) { | 17 int APIENTRY wWinMain(HINSTANCE, HINSTANCE, wchar_t*, int) { |
| 17 base::AtExitManager exit_manager; | 18 base::AtExitManager exit_manager; |
| 18 | 19 |
| 19 // Initialize the commandline singleton from the environment. | 20 // Initialize the commandline singleton from the environment. |
| 20 CommandLine::Init(0, NULL); | 21 CommandLine::Init(0, NULL); |
| 21 | 22 |
| 22 base::FilePath chrome_exe(chrome_launcher_support::GetAnyChromePath()); | 23 base::FilePath chrome_exe(chrome_launcher_support::GetAnyChromePath()); |
| 23 if (chrome_exe.empty()) { | 24 if (chrome_exe.empty()) { |
| 24 LOG(INFO) << "No Chrome executable could be found. Let's install it."; | 25 LOG(INFO) << "No Chrome executable could be found. Let's install it."; |
| 25 HRESULT hr = app_host::InstallBinaries(); | 26 HRESULT hr = app_host::InstallBinaries(); |
| 26 if (FAILED(hr)) { | 27 if (FAILED(hr)) { |
| 27 LOG(ERROR) << "Failed to install the Chrome Binaries. Error: " << hr; | 28 LOG(ERROR) << "Failed to install the Chrome Binaries. Error: " << hr; |
| 28 return 1; | 29 return 1; |
| 29 } else { | 30 } else { |
| 30 chrome_exe = chrome_launcher_support::GetAnyChromePath(); | 31 chrome_exe = chrome_launcher_support::GetAnyChromePath(); |
| 31 if (chrome_exe.empty()) { | 32 if (chrome_exe.empty()) { |
| 32 LOG(ERROR) << "Failed to find the Chrome Binaries despite a " | 33 LOG(ERROR) << "Failed to find the Chrome Binaries despite a " |
| 33 << "'successful' installation."; | 34 << "'successful' installation."; |
| 34 return 1; | 35 return 1; |
| 35 } | 36 } |
| 36 } | 37 } |
| 37 } | 38 } |
| 38 | 39 |
| 39 CommandLine chrome_exe_command_line(chrome_exe); | 40 CommandLine chrome_exe_command_line(chrome_exe); |
| 40 chrome_exe_command_line.AppendArguments( | 41 chrome_exe_command_line.AppendArguments( |
| 41 *CommandLine::ForCurrentProcess(), false); | 42 *CommandLine::ForCurrentProcess(), false); |
| 43 | |
| 42 // Launch Chrome before checking for update, for faster user experience. | 44 // Launch Chrome before checking for update, for faster user experience. |
|
robertshield
2013/03/28 02:38:03
grammar nit: for -> for a
| |
| 43 bool launch_result = base::LaunchProcess(chrome_exe_command_line, | 45 DWORD exit_code = 0; |
| 44 base::LaunchOptions(), NULL); | 46 if (!app_host::LaunchOperation(chrome_exe_command_line, |
| 45 if (launch_result) | 47 ::GetStdHandle(STD_OUTPUT_HANDLE), |
| 46 LOG(INFO) << "Delegated to Chrome executable at " << chrome_exe.value(); | 48 &exit_code)) { |
| 47 else | 49 LOG(ERROR) << "Failed to delegate to Chrome."; |
|
gab
2013/03/28 03:06:06
Does this need to make it in Release builds or is
erikwright (departed)
2013/04/18 17:43:04
This is not a NOTREACHED scenario. Things out of o
| |
| 48 LOG(INFO) << "Failed to launch Chrome executable at " << chrome_exe.value(); | 50 return 1; |
|
gab
2013/03/28 03:06:06
This should be a constant return code, no?
| |
| 51 } | |
| 49 | 52 |
| 50 app_host::EnsureAppHostUpToDate(); | 53 app_host::EnsureAppHostUpToDate(); |
| 51 | 54 |
| 52 return !launch_result; | 55 return exit_code; |
| 53 } | 56 } |
| OLD | NEW |