| 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/installer/launcher_support/chrome_launcher_support.h" | 11 #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
| 11 | 12 |
| 12 namespace { | |
| 13 | |
| 14 const wchar_t kChromeExe[] = L"chrome.exe"; | |
| 15 | |
| 16 } // namespace | |
| 17 | |
| 18 int main(int /* argc */, char* /* argv[] */) { | 13 int main(int /* argc */, char* /* argv[] */) { |
| 19 base::AtExitManager exit_manager; | 14 base::AtExitManager exit_manager; |
| 20 | 15 |
| 21 // Initialize the commandline singleton from the environment. | 16 // Initialize the commandline singleton from the environment. |
| 22 CommandLine::Init(0, NULL); | 17 CommandLine::Init(0, NULL); |
| 23 | 18 |
| 24 FilePath chrome_exe(chrome_launcher_support::GetAnyChromePath()); | 19 FilePath chrome_exe(chrome_launcher_support::GetAnyChromePath()); |
| 25 | 20 |
| 26 if (chrome_exe.empty()) { | 21 if (chrome_exe.empty()) { |
| 27 LOG(ERROR) << "No Chrome executable could be found."; | 22 LOG(INFO) << "No Chrome executable could be found. Let's install it."; |
| 28 // TODO(erikwright): install Chrome. | 23 HRESULT hr = app_host::InstallBinaries(); |
| 29 return 1; | 24 if (FAILED(hr)) { |
| 25 LOG(ERROR) << "Failed to install the Chrome Binaries. Error: " << hr; |
| 26 return 1; |
| 27 } else { |
| 28 chrome_exe = chrome_launcher_support::GetAnyChromePath(); |
| 29 if (chrome_exe.empty()) { |
| 30 LOG(ERROR) << "Failed to find the Chrome Binaries despite a " |
| 31 << "'successful' installation."; |
| 32 return 1; |
| 33 } |
| 34 } |
| 30 } | 35 } |
| 31 | 36 |
| 32 CommandLine chrome_exe_command_line(chrome_exe); | 37 CommandLine chrome_exe_command_line(chrome_exe); |
| 33 chrome_exe_command_line.AppendArguments( | 38 chrome_exe_command_line.AppendArguments( |
| 34 *CommandLine::ForCurrentProcess(), false); | 39 *CommandLine::ForCurrentProcess(), false); |
| 35 | 40 |
| 36 if (base::LaunchProcess(chrome_exe_command_line, | 41 if (base::LaunchProcess(chrome_exe_command_line, |
| 37 base::LaunchOptions(), | 42 base::LaunchOptions(), |
| 38 NULL)) { | 43 NULL)) { |
| 39 LOG(INFO) << "Delegated to Chrome executable at " << chrome_exe.value(); | 44 LOG(INFO) << "Delegated to Chrome executable at " << chrome_exe.value(); |
| 40 return 0; | 45 return 0; |
| 41 } else { | 46 } else { |
| 42 LOG(INFO) << "Failed to launch Chrome executable at " << chrome_exe.value(); | 47 LOG(INFO) << "Failed to launch Chrome executable at " << chrome_exe.value(); |
| 43 return 1; | 48 return 1; |
| 44 } | 49 } |
| 45 } | 50 } |
| OLD | NEW |