Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: chrome/browser/extensions/app_host/app_host_main.cc

Issue 10905238: If Chrome Binaries version > App Host version, then update App Host. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Style issues; removing unneeded debug messages. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/version.h"
11 #include "chrome/browser/extensions/app_host/app_host_upgrade.h"
10 #include "chrome/browser/extensions/app_host/binaries_installer.h" 12 #include "chrome/browser/extensions/app_host/binaries_installer.h"
11 #include "chrome/installer/launcher_support/chrome_launcher_support.h" 13 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
12 14
13 int main(int /* argc */, char* /* argv[] */) { 15 int main(int /* argc */, char* /* argv[] */) {
16 using namespace app_host;
17 using namespace chrome_launcher_support;
14 base::AtExitManager exit_manager; 18 base::AtExitManager exit_manager;
15 19
16 // Initialize the commandline singleton from the environment. 20 // Initialize the commandline singleton from the environment.
17 CommandLine::Init(0, NULL); 21 CommandLine::Init(0, NULL);
18 22
19 FilePath chrome_exe(chrome_launcher_support::GetAnyChromePath()); 23 FilePath chrome_exe(GetAnyChromePath());
20 24
21 if (chrome_exe.empty()) { 25 if (chrome_exe.empty()) {
22 LOG(INFO) << "No Chrome executable could be found. Let's install it."; 26 LOG(INFO) << "No Chrome executable could be found. Let's install it.";
23 HRESULT hr = app_host::InstallBinaries(); 27 HRESULT hr = app_host::InstallBinaries();
24 if (FAILED(hr)) { 28 if (FAILED(hr)) {
25 LOG(ERROR) << "Failed to install the Chrome Binaries. Error: " << hr; 29 LOG(ERROR) << "Failed to install the Chrome Binaries. Error: " << hr;
26 return 1; 30 return 1;
27 } else { 31 } else {
28 chrome_exe = chrome_launcher_support::GetAnyChromePath(); 32 chrome_exe = GetAnyChromePath();
29 if (chrome_exe.empty()) { 33 if (chrome_exe.empty()) {
30 LOG(ERROR) << "Failed to find the Chrome Binaries despite a " 34 LOG(ERROR) << "Failed to find the Chrome Binaries despite a "
31 << "'successful' installation."; 35 << "'successful' installation.";
32 return 1; 36 return 1;
33 } 37 }
34 } 38 }
35 } 39 }
36 40
37 CommandLine chrome_exe_command_line(chrome_exe); 41 CommandLine chrome_exe_command_line(chrome_exe);
38 chrome_exe_command_line.AppendArguments( 42 chrome_exe_command_line.AppendArguments(
39 *CommandLine::ForCurrentProcess(), false); 43 *CommandLine::ForCurrentProcess(), false);
40 44
41 if (base::LaunchProcess(chrome_exe_command_line, 45 // Launch Chrome before checking for updates, for faster user experience.
42 base::LaunchOptions(), 46 bool launch_result = base::LaunchProcess(chrome_exe_command_line,
43 NULL)) { 47 base::LaunchOptions(),
48 NULL);
49 if (launch_result) {
grt (UTC plus 2) 2012/09/13 13:14:42 no braces for single-line conditionals like this
huangs 2012/09/13 18:46:00 Done.
44 LOG(INFO) << "Delegated to Chrome executable at " << chrome_exe.value(); 50 LOG(INFO) << "Delegated to Chrome executable at " << chrome_exe.value();
45 return 0;
46 } else { 51 } else {
47 LOG(INFO) << "Failed to launch Chrome executable at " << chrome_exe.value(); 52 LOG(INFO) << "Failed to launch Chrome executable at " << chrome_exe.value();
48 return 1;
49 } 53 }
54
55 // If system-level Chrome Binary is installed, and if its version is
grt (UTC plus 2) 2012/09/13 13:14:42 i think this block of code is big enough and isola
huangs 2012/09/13 18:46:00 Okay, moving into app_host_upgrade.cc. Also hidin
56 // newer than App Host's, then upgrade App Host by calling setup.exe.
grt (UTC plus 2) 2012/09/13 13:14:42 please change "upgrade" in all cases to "update" .
erikwright (departed) 2012/09/13 13:48:26 By "the latter" grt@ meant "the former".
huangs 2012/09/13 18:46:00 Makes sense. Done!
57 Version chrome_binaries_version;
58 if (GetAppVersionForInstallationLevel(kMultiInstallAppGuid,
59 true, // System-level.
60 &chrome_binaries_version)) {
61 Version app_host_version;
62 if (GetAppVersionForInstallationLevel(kChromeAppHostAppGuid,
grt (UTC plus 2) 2012/09/13 13:14:42 if this is used to get the version of the currentl
huangs 2012/09/13 18:46:00 Done.
63 false, // User-level.
64 &app_host_version)) {
65 if (app_host_version.IsOlderThan(chrome_binaries_version.GetString())) {
66 LOG(INFO) << "App Host version (" << app_host_version.GetString() <<
grt (UTC plus 2) 2012/09/13 13:14:43 wrap use of the streaming operator by putting the
erikwright (departed) 2012/09/13 13:48:26 Correct. Note this is an exception to my previous
huangs 2012/09/13 18:46:00 Done.
67 ") is older than Chrome Binaries version (" <<
68 chrome_binaries_version.GetString() <<
69 "), so running setup.exe to upgrade";
grt (UTC plus 2) 2012/09/13 13:14:43 general comment: make the log message as concise a
huangs 2012/09/13 18:46:00 Done.
70 if (!UpgradeAppHost(true)) { // Use system-level setup.exe
grt (UTC plus 2) 2012/09/13 13:14:43 no braces
huangs 2012/09/13 18:46:00 Done.
71 LOG(ERROR) << "Failed to upgrade App Host";
72 }
73 }
74 } else {
75 LOG(INFO) << "Failed to get App Host version";
grt (UTC plus 2) 2012/09/13 13:14:43 why isn't this an ERROR?
huangs 2012/09/13 18:46:00 Done.
76 }
77 } // Else there is no system-level Chrome, so do nothing.
78
79 return launch_result ? 0 : 1;
grt (UTC plus 2) 2012/09/13 13:14:43 optional: return !launch_result; is equivalent and
huangs 2012/09/13 18:46:00 Done.
50 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698