summaryrefslogtreecommitdiffstats
path: root/chrome/installer/launcher_support
diff options
context:
space:
mode:
authormpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-25 22:11:23 +0000
committermpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-25 22:11:23 +0000
commitefde268d313a402ff730906cc30719d71a7e07b0 (patch)
tree5998ac359a448c7d0541ff6d1d09a73272f938e3 /chrome/installer/launcher_support
parent3aa54ea723c1f673d9ba184465f42f3555719970 (diff)
downloadchromium_src-efde268d313a402ff730906cc30719d71a7e07b0.zip
chromium_src-efde268d313a402ff730906cc30719d71a7e07b0.tar.gz
chromium_src-efde268d313a402ff730906cc30719d71a7e07b0.tar.bz2
Revert 285661 "Remove some dead app host code."
Causes compile failures on official builders: e.g., http://build.chromium.org/p/chromium.chrome/builders/Google%20Chrome%20Win/ FAILED: ninja -t msvc -e environment.x64 -- c:\b\build\goma/gomacc "c:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64\cl.exe" /nologo /showIncludes /FC @obj\chrome\installer\util\installer_util_nacl_win64.chrome_app_host_distribution.obj.rsp /c ..\..\chrome\installer\util\chrome_app_host_distribution.cc /Foobj\chrome\installer\util\installer_util_nacl_win64.chrome_app_host_distribution.obj /Fdobj\chrome\installer_util_nacl_win64.cc.pdb c:\b\build\slave\google-chrome-rel-win\build\src\chrome\installer\util\chrome_app_host_distribution.cc(126) :error C2065: 'kChromeAppHostGuid' : undeclared identifier ninja: build stopped: subcommand failed. > Remove some dead app host code. > > app_host.exe was removed in r220555. This change removes some dead code > that was left behind. Specifically: > - chrome_launcher_support no longer exposes any methods related to the > AppHost. > - Chrome's uninstall prompt no longer has a special case to handle > suppressing the "delete your profile" checkbox. > - Chrome and its installer no longer have a dependency on > launcher_support. > - The installer no longer supports installing items from the webstore. > - GetUntrustedDataValue no longer has consumers and is gone. > > BUG=297647 > R=benwells@chromium.org,huangs@chromium.org,gab@chromium.org > > Review URL: https://codereview.chromium.org/422453004 TBR=grt@chromium.org Review URL: https://codereview.chromium.org/422593002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285706 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/launcher_support')
-rw-r--r--chrome/installer/launcher_support/chrome_launcher_support.cc146
-rw-r--r--chrome/installer/launcher_support/chrome_launcher_support.h54
2 files changed, 184 insertions, 16 deletions
diff --git a/chrome/installer/launcher_support/chrome_launcher_support.cc b/chrome/installer/launcher_support/chrome_launcher_support.cc
index 9e9ba92..8e5b6a5 100644
--- a/chrome/installer/launcher_support/chrome_launcher_support.cc
+++ b/chrome/installer/launcher_support/chrome_launcher_support.cc
@@ -5,12 +5,20 @@
#include "chrome/installer/launcher_support/chrome_launcher_support.h"
#include <windows.h>
+#include <tchar.h>
+#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "base/process/launch.h"
#include "base/strings/string16.h"
#include "base/win/registry.h"
+#ifndef OFFICIAL_BUILD
+#include "base/path_service.h"
+#endif
+
namespace chrome_launcher_support {
namespace {
@@ -18,6 +26,8 @@ namespace {
// TODO(huangs) Refactor the constants: http://crbug.com/148538
const wchar_t kGoogleRegClientStateKey[] =
L"Software\\Google\\Update\\ClientState";
+const wchar_t kGoogleRegClientsKey[] = L"Software\\Google\\Update\\Clients";
+const wchar_t kRegVersionField[] = L"pv";
// Copied from chrome_appid.cc.
const wchar_t kBinariesAppGuid[] = L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
@@ -25,8 +35,14 @@ const wchar_t kBinariesAppGuid[] = L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
// Copied from google_chrome_distribution.cc.
const wchar_t kBrowserAppGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}";
+// Copied frome google_chrome_sxs_distribution.cc.
+const wchar_t kSxSBrowserAppGuid[] = L"{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}";
+
// Copied from util_constants.cc.
+const wchar_t kChromeAppHostExe[] = L"app_host.exe";
+const char kChromeAppLauncher[] = "app-launcher";
const wchar_t kChromeExe[] = L"chrome.exe";
+const wchar_t kUninstallArgumentsField[] = L"UninstallArguments";
const wchar_t kUninstallStringField[] = L"UninstallString";
// Reads a string value from the specified product's "ClientState" registry key.
@@ -50,6 +66,33 @@ bool GetClientStateValue(InstallationLevel level,
return false;
}
+// Determines whether the specified product has a key in "Clients". This
+// indicates whether the product is installed at the given level.
+bool IsProductInstalled(InstallationLevel level, const wchar_t* app_guid) {
+ HKEY root_key = (level == USER_LEVEL_INSTALLATION) ?
+ HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
+ base::string16 subkey(kGoogleRegClientsKey);
+ subkey.append(1, L'\\').append(app_guid);
+ base::win::RegKey reg_key;
+ // Google Update always uses 32bit hive.
+ return reg_key.Open(root_key, subkey.c_str(),
+ KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS &&
+ reg_key.HasValue(kRegVersionField);
+}
+
+bool IsAppLauncherEnabledAtLevel(InstallationLevel level) {
+ base::string16 uninstall_arguments;
+ if (GetClientStateValue(level,
+ kAppLauncherGuid,
+ kUninstallArgumentsField,
+ &uninstall_arguments)) {
+ return CommandLine::FromString(L"dummy.exe " + uninstall_arguments)
+ .HasSwitch(kChromeAppLauncher) &&
+ !GetAppHostPathForInstallationLevel(level).empty();
+ }
+ return false;
+}
+
// Reads the path to setup.exe from the value "UninstallString" within the
// specified product's "ClientState" registry key. Returns an empty FilePath if
// an error occurs or the product is not installed at the specified level.
@@ -64,22 +107,9 @@ base::FilePath GetSetupExeFromRegistry(InstallationLevel level,
return base::FilePath();
}
-// Returns the path to an existing setup.exe at the specified level, if it can
-// be found via Omaha client state.
-base::FilePath GetSetupExeForInstallationLevel(InstallationLevel level) {
- // Look in the registry for Chrome Binaries first.
- base::FilePath setup_exe_path(
- GetSetupExeFromRegistry(level, kBinariesAppGuid));
- // If the above fails, look in the registry for Chrome next.
- if (setup_exe_path.empty())
- setup_exe_path = GetSetupExeFromRegistry(level, kBrowserAppGuid);
- // If we fail again, then setup_exe_path would be empty.
- return setup_exe_path;
-}
-
-// Returns the path to an installed |exe_file| (e.g. chrome.exe) at the
-// specified level, given |setup_exe_path| from Omaha client state. Returns
-// empty base::FilePath if none found, or if |setup_exe_path| is empty.
+// Returns the path to an installed |exe_file| (e.g. chrome.exe, app_host.exe)
+// at the specified level, given |setup_exe_path| from Omaha client state.
+// Returns empty base::FilePath if none found, or if |setup_exe_path| is empty.
base::FilePath FindExeRelativeToSetupExe(const base::FilePath setup_exe_path,
const wchar_t* exe_file) {
if (!setup_exe_path.empty()) {
@@ -101,11 +131,52 @@ base::FilePath FindExeRelativeToSetupExe(const base::FilePath setup_exe_path,
} // namespace
+const wchar_t kAppLauncherGuid[] = L"{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}";
+
+void UninstallLegacyAppLauncher(InstallationLevel level) {
+ base::FilePath setup_exe(GetSetupExeFromRegistry(level, kAppLauncherGuid));
+ if (setup_exe.empty())
+ return;
+ base::string16 uninstall_arguments;
+ if (GetClientStateValue(level,
+ kAppLauncherGuid,
+ kUninstallArgumentsField,
+ &uninstall_arguments)) {
+ CommandLine uninstall_cmd = CommandLine::FromString(
+ L"\"" + setup_exe.value() + L"\" " + uninstall_arguments);
+
+ VLOG(1) << "Uninstalling legacy app launcher with command line: "
+ << uninstall_cmd.GetCommandLineString();
+ base::LaunchProcess(uninstall_cmd, base::LaunchOptions(), NULL);
+ }
+}
+
+base::FilePath GetSetupExeForInstallationLevel(InstallationLevel level) {
+ // Look in the registry for Chrome Binaries first.
+ base::FilePath setup_exe_path(
+ GetSetupExeFromRegistry(level, kBinariesAppGuid));
+ // If the above fails, look in the registry for Chrome next.
+ if (setup_exe_path.empty())
+ setup_exe_path = GetSetupExeFromRegistry(level, kBrowserAppGuid);
+ // If we fail again, then setup_exe_path would be empty.
+ return setup_exe_path;
+}
+
base::FilePath GetChromePathForInstallationLevel(InstallationLevel level) {
return FindExeRelativeToSetupExe(
GetSetupExeForInstallationLevel(level), kChromeExe);
}
+base::FilePath GetAppHostPathForInstallationLevel(InstallationLevel level) {
+ return FindExeRelativeToSetupExe(
+ GetSetupExeFromRegistry(level, kAppLauncherGuid), kChromeAppHostExe);
+}
+
+base::FilePath GetChromeSxSPathForInstallationLevel(InstallationLevel level) {
+ return FindExeRelativeToSetupExe(
+ GetSetupExeFromRegistry(level, kSxSBrowserAppGuid), kChromeExe);
+}
+
base::FilePath GetAnyChromePath() {
base::FilePath chrome_path;
if (chrome_path.empty())
@@ -115,4 +186,47 @@ base::FilePath GetAnyChromePath() {
return chrome_path;
}
+base::FilePath GetAnyAppHostPath() {
+ base::FilePath app_host_path;
+ if (app_host_path.empty()) {
+ app_host_path = GetAppHostPathForInstallationLevel(
+ SYSTEM_LEVEL_INSTALLATION);
+ }
+ if (app_host_path.empty())
+ app_host_path = GetAppHostPathForInstallationLevel(USER_LEVEL_INSTALLATION);
+ return app_host_path;
+}
+
+base::FilePath GetAnyChromeSxSPath() {
+ base::FilePath path =
+ GetChromeSxSPathForInstallationLevel(USER_LEVEL_INSTALLATION);
+ if (path.empty())
+ path = GetChromeSxSPathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION);
+ return path;
+}
+
+bool IsAppHostPresent() {
+ base::FilePath app_host_exe = GetAnyAppHostPath();
+ return !app_host_exe.empty();
+}
+
+InstallationState GetAppLauncherInstallationState() {
+ if (IsAppLauncherEnabledAtLevel(SYSTEM_LEVEL_INSTALLATION))
+ return INSTALLED_AT_SYSTEM_LEVEL;
+
+ if (IsAppLauncherEnabledAtLevel(USER_LEVEL_INSTALLATION))
+ return INSTALLED_AT_USER_LEVEL;
+
+ return NOT_INSTALLED;
+}
+
+bool IsAppLauncherPresent() {
+ return GetAppLauncherInstallationState() != NOT_INSTALLED;
+}
+
+bool IsChromeBrowserPresent() {
+ return IsProductInstalled(USER_LEVEL_INSTALLATION, kBrowserAppGuid) ||
+ IsProductInstalled(SYSTEM_LEVEL_INSTALLATION, kBrowserAppGuid);
+}
+
} // namespace chrome_launcher_support
diff --git a/chrome/installer/launcher_support/chrome_launcher_support.h b/chrome/installer/launcher_support/chrome_launcher_support.h
index 9cf1479..f50ff28 100644
--- a/chrome/installer/launcher_support/chrome_launcher_support.h
+++ b/chrome/installer/launcher_support/chrome_launcher_support.h
@@ -16,18 +16,72 @@ enum InstallationLevel {
SYSTEM_LEVEL_INSTALLATION,
};
+enum InstallationState {
+ NOT_INSTALLED,
+ INSTALLED_AT_USER_LEVEL,
+ INSTALLED_AT_SYSTEM_LEVEL,
+};
+
+// The app GUID for Chrome App Launcher.
+extern const wchar_t kAppLauncherGuid[];
+
+// Returns the path to an existing setup.exe at the specified level, if it can
+// be found via Omaha client state.
+base::FilePath GetSetupExeForInstallationLevel(InstallationLevel level);
+
// Returns the path to an installed chrome.exe at the specified level, if it can
// be found via Omaha client state. Prefers the installer from a multi-install,
// but may also return that of a single-install of Chrome if no multi-install
// exists.
base::FilePath GetChromePathForInstallationLevel(InstallationLevel level);
+// Returns the path to an installed app_host.exe at the specified level, if
+// it can be found via Omaha client state.
+base::FilePath GetAppHostPathForInstallationLevel(InstallationLevel level);
+
+// Returns the path to an installed SxS chrome.exe at the specified level, if
+// it can be found via Omaha client state.
+base::FilePath GetChromeSxSPathForInstallationLevel(InstallationLevel level);
+
// Returns the path to an installed chrome.exe, or an empty path. Prefers a
// system-level installation to a user-level installation. Uses Omaha client
// state to identify a Chrome installation location.
// The file path returned (if any) is guaranteed to exist.
base::FilePath GetAnyChromePath();
+// Returns the path to an installed app_host.exe, or an empty path. Prefers a
+// system-level installation to a user-level installation. Uses Omaha client
+// state to identify a App Host installation location.
+// The file path returned (if any) is guaranteed to exist.
+base::FilePath GetAnyAppHostPath();
+
+// Returns the path to an installed SxS chrome.exe, or an empty path. Prefers a
+// user-level installation to a system-level installation. Uses Omaha client
+// state to identify a Chrome Canary installation location.
+// The file path returned (if any) is guaranteed to exist.
+base::FilePath GetAnyChromeSxSPath();
+
+// Uninstalls the legacy app launcher by launching setup.exe with the uninstall
+// arguments from the App Launcher ClientState registry key. The uninstall will
+// run asynchronously.
+void UninstallLegacyAppLauncher(InstallationLevel level);
+
+// Returns true if App Host is installed (system-level or user-level),
+// or in the same directory as the current executable.
+bool IsAppHostPresent();
+
+// Returns the app launcher installation state. If the launcher is installed
+// at both system level and user level, system level is returned.
+InstallationState GetAppLauncherInstallationState();
+
+// Returns true if App Launcher is installed (system-level or user-level).
+bool IsAppLauncherPresent();
+
+// Returns true if the Chrome browser is installed (system-level or user-level).
+// If this is running in an official build, it will check if a non-canary build
+// if installed. If it is not an official build, it will always return true.
+bool IsChromeBrowserPresent();
+
} // namespace chrome_launcher_support
#endif // CHROME_INSTALLER_LAUNCHER_SUPPORT_CHROME_LAUNCHER_SUPPORT_H_