| 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 int APIENTRY wWinMain(HINSTANCE, HINSTANCE, wchar_t*, int) { | 16 int APIENTRY wWinMain(HINSTANCE, HINSTANCE, wchar_t*, int) { |
| 17 base::AtExitManager exit_manager; | 17 base::AtExitManager exit_manager; |
| 18 | 18 |
| 19 // Initialize the commandline singleton from the environment. | 19 // Initialize the commandline singleton from the environment. |
| 20 CommandLine::Init(0, NULL); | 20 CommandLine::Init(0, NULL); |
| 21 | 21 |
| 22 base::FilePath chrome_exe(chrome_launcher_support::GetAnyChromePath()); | 22 base::FilePath chrome_exe(chrome_launcher_support::GetAnyChromePath()); |
| 23 if (chrome_exe.empty()) { | 23 if (chrome_exe.empty()) { |
| 24 LOG(INFO) << "No Chrome executable could be found. Let's install it."; | 24 LOG(INFO) << "No Chrome executable could be found. Let's install it."; |
| 25 HRESULT hr = app_host::InstallBinaries(); | 25 HRESULT hr = app_host::InstallBinaries(); |
| 26 if (FAILED(hr)) { | 26 if (FAILED(hr)) { |
| 27 LOG(ERROR) << "Failed to install the Chrome Binaries. Error: " << hr; | 27 LOG(ERROR) << "Failed to install the Chrome Binaries. Error: " << hr; |
| 28 return 1; | 28 return 1; |
| 29 } else { | 29 } else { |
| 30 chrome_exe = chrome_launcher_support::GetAnyChromePath(); | 30 chrome_exe = chrome_launcher_support::GetAnyChromePath(); |
| 31 if (chrome_exe.empty()) { | 31 if (chrome_exe.empty()) { |
| 32 LOG(ERROR) << "Failed to find the Chrome Binaries despite a " | 32 LOG(ERROR) << "Failed to find the Chrome Binaries despite a " |
| 33 << "'successful' installation."; | 33 << "'successful' installation."; |
| 34 return 1; | 34 return 1; |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 CommandLine chrome_exe_command_line(chrome_exe); | 39 CommandLine chrome_exe_command_line(chrome_exe); |
| 40 chrome_exe_command_line.AppendArguments( | 40 chrome_exe_command_line.AppendArguments( |
| 41 *CommandLine::ForCurrentProcess(), false); | 41 *CommandLine::ForCurrentProcess(), false); |
| 42 // Launch Chrome before checking for update, for faster user experience. | 42 |
| 43 bool launch_result = base::LaunchProcess(chrome_exe_command_line, | 43 // Launch Chrome before checking for an update, for a faster user experience. |
| 44 base::LaunchOptions(), NULL); | 44 DWORD exit_code = 0; |
| 45 if (launch_result) | 45 if (!app_host::LaunchOperation(chrome_exe_command_line, |
| 46 LOG(INFO) << "Delegated to Chrome executable at " << chrome_exe.value(); | 46 ::GetStdHandle(STD_OUTPUT_HANDLE), |
| 47 else | 47 &exit_code)) { |
| 48 LOG(INFO) << "Failed to launch Chrome executable at " << chrome_exe.value(); | 48 LOG(ERROR) << "Failed to delegate to Chrome."; |
| 49 return 1; |
| 50 } |
| 49 | 51 |
| 50 app_host::EnsureAppHostUpToDate(); | 52 app_host::EnsureAppHostUpToDate(); |
| 51 | 53 |
| 52 return !launch_result; | 54 return exit_code; |
| 53 } | 55 } |
| OLD | NEW |