diff options
Diffstat (limited to 'chrome/installer/util/helper.cc')
-rw-r--r-- | chrome/installer/util/helper.cc | 107 |
1 files changed, 17 insertions, 90 deletions
diff --git a/chrome/installer/util/helper.cc b/chrome/installer/util/helper.cc index 6cddf25..82f8a36 100644 --- a/chrome/installer/util/helper.cc +++ b/chrome/installer/util/helper.cc @@ -4,17 +4,13 @@ #include "chrome/installer/util/helper.h" -#include "base/command_line.h" -#include "base/file_path.h" #include "base/logging.h" +#include "base/file_path.h" #include "base/path_service.h" -#include "base/win/registry.h" #include "chrome/installer/util/browser_distribution.h" +#include "chrome/installer/util/installation_state.h" #include "chrome/installer/util/install_util.h" -#include "chrome/installer/util/master_preferences.h" -#include "chrome/installer/util/package_properties.h" - -using base::win::RegKey; +#include "chrome/installer/util/util_constants.h" namespace { @@ -40,101 +36,32 @@ FilePath GetChromeInstallBasePath(bool system, namespace installer { -bool IsInstalledAsMulti(bool system_install, BrowserDistribution* dist) { - bool installed_as_multi = false; - CommandLine cmd(CommandLine::NO_PROGRAM); - if (GetUninstallSwitches(system_install, dist, &cmd)) - installed_as_multi = cmd.HasSwitch(installer::switches::kMultiInstall); - return installed_as_multi; -} - -bool GetUninstallSwitches(bool system_install, BrowserDistribution* dist, - CommandLine* cmd_line_switches) { - scoped_ptr<Version> installed(InstallUtil::GetChromeVersion(dist, - system_install)); - if (installed.get()) { - HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - RegKey key(root, dist->GetStateKey().c_str(), KEY_READ); - if (key.Valid()) { - std::wstring args; - key.ReadValue(installer::kUninstallArgumentsField, &args); - if (!args.empty()) { - args.insert(0, L"foo.exe "); - *cmd_line_switches = CommandLine::FromString(args); - } else { - LOG(ERROR) << "No uninstallation arguments for " - << dist->GetApplicationName(); - installed.reset(); - } - } else { - LOG(ERROR) << "Product looks to be installed but we can't access the " - "state key: " << dist->GetApplicationName(); - installed.reset(); - } - } - - return installed.get() != NULL; -} - FilePath GetChromeInstallPath(bool system_install, BrowserDistribution* dist) { - return GetChromeInstallBasePath(system_install, dist, - installer::kInstallBinaryDir); + return GetChromeInstallBasePath(system_install, dist, kInstallBinaryDir); } FilePath GetChromeUserDataPath(BrowserDistribution* dist) { return GetChromeInstallBasePath(false, dist, kInstallUserDataDir); } -FilePath GetChromeFrameInstallPath(bool multi_install, bool system_install, - BrowserDistribution* dist) { - DCHECK_EQ(BrowserDistribution::CHROME_FRAME, dist->GetType()); - - scoped_ptr<Version> installed_version( - InstallUtil::GetChromeVersion(dist, system_install)); - - if (!multi_install) { - // Check if Chrome Frame is installed as multi. If it is, return an empty - // path and log an error. - if (installed_version.get() && IsInstalledAsMulti(system_install, dist)) { - LOG(ERROR) << "Cannot install Chrome Frame in single mode as a multi mode" - " installation already exists."; - return FilePath(); - } - VLOG(1) << "Chrome Frame will be installed as 'single'"; - return GetChromeInstallPath(system_install, dist); - } - - // TODO(tommi): If Chrome Frame is installed as single and the installed - // channel is older than the one we're installing, we should migrate - // CF to Chrome's install folder and change its channel. +BrowserDistribution* GetBinariesDistribution(bool system_install) { + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + ProductState state; - // Multi install. Check if Chrome Frame is already installed. - // If CF is installed as single (i.e. not multi), we will return an empty - // path (for now). Otherwise, if CF is not installed or if it is installed - // as multi, we will return Chrome's install folder. - if (installed_version.get() && !IsInstalledAsMulti(system_install, dist)) { - LOG(ERROR) << "Cannot install Chrome Frame in multi mode as a single mode" - " installation already exists."; - return FilePath(); + // If we're part of a multi-install, we need to poll using the multi-installer + // package's app guid rather than the browser's or Chrome Frame's app guid. + // If we can't read the app's state from the registry, assume it isn't + // multi-installed. + if (state.Initialize(system_install, dist) && state.is_multi_install()) { + return BrowserDistribution::GetSpecificDistribution( + BrowserDistribution::CHROME_BINARIES); + } else { + return dist; } - - // Return Chrome's installation folder. - VLOG(1) << "Chrome Frame will be installed as 'multi'"; - const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess(); - BrowserDistribution* chrome = - BrowserDistribution::GetSpecificDistribution( - BrowserDistribution::CHROME_BROWSER, prefs); - return GetChromeInstallPath(system_install, chrome); } std::wstring GetAppGuidForUpdates(bool system_install) { - BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - - // If we're part of a multi-install, we need to poll using the multi-installer - // package's app guid rather than the browser's or Chrome Frame's app guid. - return IsInstalledAsMulti(system_install, dist) ? - ActivePackageProperties().GetAppGuid() : - dist->GetAppGuid(); + return GetBinariesDistribution(system_install)->GetAppGuid(); } } // namespace installer. |