| 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "chrome/browser/extensions/app_host/binaries_installer.h" | 10 #include "chrome/browser/extensions/app_host/binaries_installer.h" |
| 11 #include "chrome/browser/extensions/app_host/update.h" |
| 11 #include "chrome/installer/launcher_support/chrome_launcher_support.h" | 12 #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
| 12 | 13 |
| 13 int main(int /* argc */, char* /* argv[] */) { | 14 int main(int /* argc */, char* /* argv[] */) { |
| 14 base::AtExitManager exit_manager; | 15 base::AtExitManager exit_manager; |
| 15 | 16 |
| 16 // Initialize the commandline singleton from the environment. | 17 // Initialize the commandline singleton from the environment. |
| 17 CommandLine::Init(0, NULL); | 18 CommandLine::Init(0, NULL); |
| 18 | 19 |
| 19 FilePath chrome_exe(chrome_launcher_support::GetAnyChromePath()); | 20 FilePath chrome_exe(chrome_launcher_support::GetAnyChromePath()); |
| 20 | |
| 21 if (chrome_exe.empty()) { | 21 if (chrome_exe.empty()) { |
| 22 LOG(INFO) << "No Chrome executable could be found. Let's install it."; | 22 LOG(INFO) << "No Chrome executable could be found. Let's install it."; |
| 23 HRESULT hr = app_host::InstallBinaries(); | 23 HRESULT hr = app_host::InstallBinaries(); |
| 24 if (FAILED(hr)) { | 24 if (FAILED(hr)) { |
| 25 LOG(ERROR) << "Failed to install the Chrome Binaries. Error: " << hr; | 25 LOG(ERROR) << "Failed to install the Chrome Binaries. Error: " << hr; |
| 26 return 1; | 26 return 1; |
| 27 } else { | 27 } else { |
| 28 chrome_exe = chrome_launcher_support::GetAnyChromePath(); | 28 chrome_exe = chrome_launcher_support::GetAnyChromePath(); |
| 29 if (chrome_exe.empty()) { | 29 if (chrome_exe.empty()) { |
| 30 LOG(ERROR) << "Failed to find the Chrome Binaries despite a " | 30 LOG(ERROR) << "Failed to find the Chrome Binaries despite a " |
| 31 << "'successful' installation."; | 31 << "'successful' installation."; |
| 32 return 1; | 32 return 1; |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 CommandLine chrome_exe_command_line(chrome_exe); | 37 CommandLine chrome_exe_command_line(chrome_exe); |
| 38 chrome_exe_command_line.AppendArguments( | 38 chrome_exe_command_line.AppendArguments( |
| 39 *CommandLine::ForCurrentProcess(), false); | 39 *CommandLine::ForCurrentProcess(), false); |
| 40 // Launch Chrome before checking for update, for faster user experience. |
| 41 bool launch_result = base::LaunchProcess(chrome_exe_command_line, |
| 42 base::LaunchOptions(), |
| 43 NULL); |
| 44 if (launch_result) |
| 45 LOG(INFO) << "Delegated to Chrome executable at " << chrome_exe.value(); |
| 46 else |
| 47 LOG(INFO) << "Failed to launch Chrome executable at " << chrome_exe.value(); |
| 40 | 48 |
| 41 if (base::LaunchProcess(chrome_exe_command_line, | 49 app_host::EnsureAppHostUpToDate(); |
| 42 base::LaunchOptions(), | 50 |
| 43 NULL)) { | 51 return !launch_result; |
| 44 LOG(INFO) << "Delegated to Chrome executable at " << chrome_exe.value(); | |
| 45 return 0; | |
| 46 } else { | |
| 47 LOG(INFO) << "Failed to launch Chrome executable at " << chrome_exe.value(); | |
| 48 return 1; | |
| 49 } | |
| 50 } | 52 } |
| OLD | NEW |