Chromium Code Reviews| Index: chrome/browser/extensions/app_host/app_host_main.cc |
| diff --git a/chrome/browser/extensions/app_host/app_host_main.cc b/chrome/browser/extensions/app_host/app_host_main.cc |
| index 10d044a57cbf93c2e524ceead7b669a8763e726d..30089a7c32ba7d51d19d46ed1cd2fb6d5dc5327a 100644 |
| --- a/chrome/browser/extensions/app_host/app_host_main.cc |
| +++ b/chrome/browser/extensions/app_host/app_host_main.cc |
| @@ -7,16 +7,21 @@ |
| #include "base/file_path.h" |
| #include "base/logging.h" |
| #include "base/process_util.h" |
| +#include "base/string16.h" |
|
erikwright (departed)
2012/09/13 01:13:44
do you still need this?
huangs
2012/09/13 04:40:47
Nope. Deleted.
|
| +#include "base/version.h" |
| +#include "chrome/browser/extensions/app_host/app_host_upgrade.h" |
| #include "chrome/browser/extensions/app_host/binaries_installer.h" |
| #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
| int main(int /* argc */, char* /* argv[] */) { |
| + using namespace app_host; |
| + using namespace chrome_launcher_support; |
| base::AtExitManager exit_manager; |
| // Initialize the commandline singleton from the environment. |
| CommandLine::Init(0, NULL); |
| - FilePath chrome_exe(chrome_launcher_support::GetAnyChromePath()); |
| + FilePath chrome_exe(GetAnyChromePath()); |
| if (chrome_exe.empty()) { |
| LOG(INFO) << "No Chrome executable could be found. Let's install it."; |
| @@ -25,7 +30,7 @@ int main(int /* argc */, char* /* argv[] */) { |
| LOG(ERROR) << "Failed to install the Chrome Binaries. Error: " << hr; |
| return 1; |
| } else { |
| - chrome_exe = chrome_launcher_support::GetAnyChromePath(); |
| + chrome_exe = GetAnyChromePath(); |
| if (chrome_exe.empty()) { |
| LOG(ERROR) << "Failed to find the Chrome Binaries despite a " |
| << "'successful' installation."; |
| @@ -38,13 +43,39 @@ int main(int /* argc */, char* /* argv[] */) { |
| chrome_exe_command_line.AppendArguments( |
| *CommandLine::ForCurrentProcess(), false); |
| - if (base::LaunchProcess(chrome_exe_command_line, |
| - base::LaunchOptions(), |
| - NULL)) { |
| + // Launch Chrome before checking for updates, for faster user experience. |
| + bool launch_result = base::LaunchProcess(chrome_exe_command_line, |
| + base::LaunchOptions(), |
| + NULL); |
| + if (launch_result) { |
| LOG(INFO) << "Delegated to Chrome executable at " << chrome_exe.value(); |
| - return 0; |
| } else { |
| LOG(INFO) << "Failed to launch Chrome executable at " << chrome_exe.value(); |
| - return 1; |
| } |
| + |
| + // If system-level Chrome Binary is installed, and if its version is |
| + // newer than App Host's, then upgrade App Host by calling setup.exe. |
| + Version chrome_binaries_version; |
| + if (GetAppVersionForInstallationLevel(kMultiInstallAppGuid, |
| + true, // System-level. |
| + &chrome_binaries_version)) { |
| + Version app_host_version; |
| + if (GetAppVersionForInstallationLevel(kChromeAppHostAppGuid, |
| + false, // User-level. |
| + &app_host_version)) { |
| + LOG(INFO) << "App Host version: " << app_host_version.GetString(); |
|
erikwright (departed)
2012/09/13 01:13:44
Remove these two log statements, though it would b
huangs
2012/09/13 04:40:47
Done.
|
| + LOG(INFO) << "Chrome binaries version: " << |
| + chrome_binaries_version.GetString(); |
| + if (app_host_version.IsOlderThan(chrome_binaries_version.GetString())) { |
| + LOG(INFO) << "App Host out of date -- running setup.exe to upgrade"; |
| + if (!UpgradeAppHost(true)) { // Use system-level setup.exe |
|
erikwright (departed)
2012/09/13 01:13:44
No need for UpgradeAppHost to take a parameter. It
huangs
2012/09/13 04:40:47
I did this to make the routine generic and dumb, s
|
| + LOG(ERROR) << "Failed to upgrade App Host"; |
| + } |
| + } |
| + } else { |
| + LOG(INFO) << "Failed to get App Host version"; |
| + } |
| + } // Else there is no system-level Chrome, so do nothing. |
| + |
| + return launch_result ? 0 : 1; |
| } |