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

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: Renamed app_host_upgrade.* to update.*; changed how App Host version is obtained; moved code to upd… 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..5cb0cb37c27d1024359e058a17e8c44da32a9cc3 100644
--- a/chrome/installer/launcher_support/chrome_launcher_support.cc
+++ b/chrome/installer/launcher_support/chrome_launcher_support.cc
@@ -8,6 +8,7 @@
#include <tchar.h>
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/logging.h"
#ifndef OFFICIAL_BUILD
#include "base/path_service.h"
#endif
@@ -16,14 +17,15 @@
namespace {
-// TODO(erikwright): These constants are duplicated all over the place.
-// Consolidate them somehow.
-const wchar_t kChromeRegClientStateKey[] =
+// TODO(huangs) Refactor the constants:
+// http://code.google.com/p/chromium/issues/detail?id=148538
grt (UTC plus 2) 2012/09/13 20:04:12 same comment about shrinking this
huangs 2012/09/13 22:25:37 Done.
grt (UTC plus 2) 2012/09/14 14:26:52 Same comment about putting bug number on same line
+const wchar_t kChromeBinariesRegClientStateKey[] =
L"Software\\Google\\Update\\ClientState\\"
- L"{8A69D345-D564-463c-AFF1-A69D9E530F96}";
+ L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
const wchar_t kUninstallStringField[] = L"UninstallString";
+// Copied from util_constants.cc.
const wchar_t kChromeExe[] = L"chrome.exe";
#ifndef OFFICIAL_BUILD
@@ -56,38 +58,41 @@ 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);
-
- FilePath chrome_exe_path;
-
- 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.
+ RegKey reg_key;
+ if (reg_key.Open(root_key, kChromeBinariesRegClientStateKey,
erikwright (departed) 2012/09/13 19:27:49 If we can't find the ChromeBinaries, next try Chro
huangs 2012/09/13 22:25:37 Sorry for the no-op; misread comments! Done. Extr
+ KEY_QUERY_VALUE) == ERROR_SUCCESS) {
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);
- 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);
- }
+ FilePath setup_exe_path(uninstall);
+ if (file_util::PathExists(setup_exe_path))
+ return setup_exe_path;
}
}
+ return FilePath();
+}
- if (file_util::PathExists(chrome_exe_path))
- return chrome_exe_path;
-
+FilePath GetChromePathForInstallationLevel(InstallationLevel level) {
+ FilePath setup_exe_path(GetSetupExeForInstallationLevel(level));
+ if (!setup_exe_path.empty()) {
+ FilePath chrome_exe_path;
+ // 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 = chrome_exe_path.DirName().DirName().Append(kChromeExe);
+ }
+ if (file_util::PathExists(chrome_exe_path))
+ return chrome_exe_path;
+ }
return FilePath();
}

Powered by Google App Engine
This is Rietveld 408576698