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

Unified Diff: chrome/installer/launcher_support/chrome_launcher_support.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: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/launcher_support/chrome_launcher_support.cc
diff --git a/chrome/installer/launcher_support/chrome_launcher_support.cc b/chrome/installer/launcher_support/chrome_launcher_support.cc
index c92f771a4735c3a0a141056e05840e2c98d9633a..949fbff321078f5c74b6202efd5e4669dc457e9c 100644
--- a/chrome/installer/launcher_support/chrome_launcher_support.cc
+++ b/chrome/installer/launcher_support/chrome_launcher_support.cc
@@ -6,8 +6,11 @@
#include <windows.h>
#include <tchar.h>
+#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/logging.h"
+#include "base/process_util.h"
#ifndef OFFICIAL_BUILD
#include "base/path_service.h"
#endif
@@ -18,13 +21,29 @@ namespace {
// TODO(erikwright): These constants are duplicated all over the place.
// Consolidate them somehow.
-const wchar_t kChromeRegClientStateKey[] =
+const wchar_t kChromeBinariesRegClientStateKey[] =
L"Software\\Google\\Update\\ClientState\\"
- L"{8A69D345-D564-463c-AFF1-A69D9E530F96}";
+ L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
+const wchar_t kChromeBinariesRegClientsKey[] =
+ L"Software\\Google\\Update\\Clients\\"
+ L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
+const wchar_t kChromeAppHostRegClientsKey[] =
+ L"Software\\Google\\Update\\Clients\\"
+ L"{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}";
const wchar_t kUninstallStringField[] = L"UninstallString";
+// Copied from util_constants.cc
+const wchar_t kSetupExe[] = L"setup.exe";
const wchar_t kChromeExe[] = L"chrome.exe";
+namespace local_switches {
erikwright (departed) 2012/09/12 15:53:50 It's in an anonymous namespace already. I don't th
huangs 2012/09/12 19:24:27 Done.
+ const char kMultiInstall[] = "multi-install";
+ const char kChromeAppHost[] = "app-host";
+ const char kVerboseLogging[] = "verbose-logging";
+}
+
+// Copied from google_update_constants.cc
+const wchar_t kRegVersionField[] = L"pv";
#ifndef OFFICIAL_BUILD
FilePath GetDevelopmentChrome() {
@@ -56,32 +75,47 @@ FilePath GetAnyChromePath() {
return chrome_path;
}
-FilePath GetChromePathForInstallationLevel(InstallationLevel level) {
+FilePath GetSetupExeForInstallationLevel(InstallationLevel level) {
using base::win::RegKey;
HKEY root_key = (level == USER_LEVEL_INSTALLATION ?
HKEY_CURRENT_USER :
HKEY_LOCAL_MACHINE);
- RegKey reg_key(root_key, kChromeRegClientStateKey, KEY_QUERY_VALUE);
+ RegKey reg_key;
- FilePath chrome_exe_path;
+ LOG(INFO) << "Seeking reg: " << kChromeBinariesRegClientStateKey;
- if (reg_key.Valid()) {
- // Now grab the uninstall string from the appropriate ClientState key
- // and use that as the base for a path to chrome.exe.
+ if (reg_key.Open(root_key, kChromeBinariesRegClientStateKey,
+ KEY_QUERY_VALUE) == ERROR_SUCCESS) {
+ // Grab the uninstall string from the appropriate ClientState key
+ // and use that as the base for a path to setup.exe.
string16 uninstall;
if (reg_key.ReadValue(kUninstallStringField, &uninstall) == ERROR_SUCCESS) {
- // The uninstall path contains the path to setup.exe which is two levels
- // down from chrome.exe. Move up two levels (plus one to drop the file
- // name) and look for chrome.exe from there.
- FilePath uninstall_path(uninstall);
+ // Trim the command line parameters.
+ FilePath setup_exe_path(CommandLine::FromString(uninstall).GetProgram());
+ LOG(INFO) << "Seeking file: " << setup_exe_path.value();
+ if (file_util::PathExists(setup_exe_path))
+ return setup_exe_path;
+ }
+ }
+
+ return FilePath();
+}
+
+FilePath GetChromePathForInstallationLevel(InstallationLevel level) {
+ using base::win::RegKey;
erikwright (departed) 2012/09/12 15:53:50 this 'using' can go away.
huangs 2012/09/12 19:24:27 Done.
+ FilePath chrome_exe_path;
erikwright (departed) 2012/09/12 15:53:50 declaration of chrome_exe_path can go inside "if (
huangs 2012/09/12 19:24:27 Done.
+ FilePath setup_exe_path(GetSetupExeForInstallationLevel(level));
+ if (!setup_exe_path.empty()) {
+ // The uninstall path contains the path to setup.exe which is two levels
+ // down from chrome.exe. Move up two levels (plus one to drop the file
+ // name) and look for chrome.exe from there.
+ chrome_exe_path =
+ setup_exe_path.DirName().DirName().DirName().Append(kChromeExe);
+ if (!file_util::PathExists(chrome_exe_path)) {
+ // By way of mild future proofing, look up one to see if there's a
+ // chrome.exe in the version directory
chrome_exe_path =
- uninstall_path.DirName().DirName().DirName().Append(kChromeExe);
- if (!file_util::PathExists(chrome_exe_path)) {
- // By way of mild future proofing, look up one to see if there's a
- // chrome.exe in the version directory
- chrome_exe_path =
- uninstall_path.DirName().DirName().Append(kChromeExe);
- }
+ chrome_exe_path.DirName().DirName().Append(kChromeExe);
}
}
@@ -91,4 +125,56 @@ FilePath GetChromePathForInstallationLevel(InstallationLevel level) {
return FilePath();
}
+bool GetAppHostVersionString(string16* version_str) {
erikwright (departed) 2012/09/12 15:53:50 This should all be de-duped as: GetAppVersionStri
huangs 2012/09/12 19:24:27 Done, but updating Version* instead of string16*;
+ using base::win::RegKey;
+ HKEY root_key = HKEY_CURRENT_USER; // App Host is always user-level.
+ RegKey reg_key;
+ LOG(INFO) << "Trying to get " << kChromeAppHostRegClientsKey;
+ return (reg_key.Open(root_key, kChromeAppHostRegClientsKey, KEY_QUERY_VALUE)
+ == ERROR_SUCCESS) &&
+ (reg_key.ReadValue(kRegVersionField, version_str) == ERROR_SUCCESS);
+}
+
+bool GetChromeBinariesVersionStringForInstallationLevel(InstallationLevel level,
+ string16* version_str) {
+ using base::win::RegKey;
+ HKEY root_key = (level == USER_LEVEL_INSTALLATION ?
+ HKEY_CURRENT_USER :
+ HKEY_LOCAL_MACHINE);
+ RegKey reg_key;
+ LOG(INFO) << "Trying to get " << kChromeBinariesRegClientsKey;
+ return (reg_key.Open(root_key, kChromeBinariesRegClientsKey, KEY_QUERY_VALUE)
+ == ERROR_SUCCESS) &&
+ (reg_key.ReadValue(kRegVersionField, version_str) == ERROR_SUCCESS);
+}
+
+bool GetAnyChromeBinariesVersionString(string16* version_str) {
+ return GetChromeBinariesVersionStringForInstallationLevel(
+ SYSTEM_LEVEL_INSTALLATION, version_str) ||
+ GetChromeBinariesVersionStringForInstallationLevel(
+ USER_LEVEL_INSTALLATION, version_str);
+}
+
+bool UpgradeAppHost() {
+ // Get the path to setup.exe, trying the system-level first.
+ FilePath setup_exe(
+ GetSetupExeForInstallationLevel(SYSTEM_LEVEL_INSTALLATION));
+ if (setup_exe.empty()) {
+ setup_exe = GetSetupExeForInstallationLevel(USER_LEVEL_INSTALLATION);
+ }
+ if (setup_exe.empty()) {
+ LOG(INFO) << "Failed to find setup.exe";
+ return false;
+ }
+ CommandLine cmd_line(setup_exe);
+ cmd_line.AppendSwitch(local_switches::kMultiInstall);
+ cmd_line.AppendSwitch(local_switches::kChromeAppHost);
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ local_switches::kVerboseLogging)) {
+ cmd_line.AppendSwitch(local_switches::kVerboseLogging);
+ }
+ LOG(INFO) << "Command line: " << cmd_line.GetCommandLineString();
+ return base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL);
+}
+
} // namespace chrome_launcher_support

Powered by Google App Engine
This is Rietveld 408576698