Commit 8b090304 authored by grt's avatar grt Committed by Commit bot

Remove multi-install from install_static.

BUG=577816

Review-Url: https://codereview.chromium.org/2601443002
Cr-Commit-Position: refs/heads/master@{#442874}
parent cdf61249
...@@ -31,7 +31,7 @@ const InstallConstants kInstallModes[] = { ...@@ -31,7 +31,7 @@ const InstallConstants kInstallModes[] = {
L"", // Empty default channel name as above. L"", // Empty default channel name as above.
ChannelStrategy::UNSUPPORTED, ChannelStrategy::UNSUPPORTED,
true, // Supports system-level installs. true, // Supports system-level installs.
true, // Supports multi-install. true, // Supported multi-install.
}, },
}; };
......
...@@ -31,7 +31,7 @@ const InstallConstants kInstallModes[] = { ...@@ -31,7 +31,7 @@ const InstallConstants kInstallModes[] = {
L"", // The empty string means "stable". L"", // The empty string means "stable".
ChannelStrategy::ADDITIONAL_PARAMETERS, ChannelStrategy::ADDITIONAL_PARAMETERS,
true, // Supports system-level installs. true, // Supports system-level installs.
true, // Supports multi-install. true, // Supported multi-install.
}, },
{ {
sizeof(kInstallModes[0]), sizeof(kInstallModes[0]),
...@@ -41,7 +41,7 @@ const InstallConstants kInstallModes[] = { ...@@ -41,7 +41,7 @@ const InstallConstants kInstallModes[] = {
L"canary", L"canary",
ChannelStrategy::FIXED, ChannelStrategy::FIXED,
false, // Does not support system-level installs. false, // Does not support system-level installs.
false, // Does not support multi-install. false, // Did not support multi-install.
}, },
}; };
......
...@@ -58,8 +58,8 @@ struct InstallConstants { ...@@ -58,8 +58,8 @@ struct InstallConstants {
// True if this mode supports system-level installs. // True if this mode supports system-level installs.
bool supports_system_level; bool supports_system_level;
// True if this mode supports multi-install. // True if this mode supported the now-deprecated multi-install.
bool supports_multi_install; bool supported_multi_install;
}; };
} // namespace install_static } // namespace install_static
......
...@@ -26,16 +26,12 @@ InstallDetails* g_module_details = nullptr; ...@@ -26,16 +26,12 @@ InstallDetails* g_module_details = nullptr;
} // namespace } // namespace
std::wstring InstallDetails::GetClientStateKeyPath(bool binaries) const { std::wstring InstallDetails::GetClientStateKeyPath() const {
return binaries && multi_install() return install_static::GetClientStateKeyPath(app_guid());
? GetBinariesClientStateKeyPath()
: install_static::GetClientStateKeyPath(app_guid());
} }
std::wstring InstallDetails::GetClientStateMediumKeyPath(bool binaries) const { std::wstring InstallDetails::GetClientStateMediumKeyPath() const {
return binaries && multi_install() return install_static::GetClientStateMediumKeyPath(app_guid());
? GetBinariesClientStateMediumKeyPath()
: install_static::GetClientStateMediumKeyPath(app_guid());
} }
bool InstallDetails::VersionMismatch() const { bool InstallDetails::VersionMismatch() const {
......
...@@ -50,9 +50,6 @@ class InstallDetails { ...@@ -50,9 +50,6 @@ class InstallDetails {
// True if installed in C:\Program Files{, {x86)}; otherwise, false. // True if installed in C:\Program Files{, {x86)}; otherwise, false.
bool system_level; bool system_level;
// True if multi-install.
bool multi_install;
}; };
InstallDetails(const InstallDetails&) = delete; InstallDetails(const InstallDetails&) = delete;
...@@ -91,9 +88,9 @@ class InstallDetails { ...@@ -91,9 +88,9 @@ class InstallDetails {
return payload_->mode->supports_system_level; return payload_->mode->supports_system_level;
} }
// True if the mode supports multi-install. // True if the mode once supported multi-install.
bool supports_multi_install() const { bool supported_multi_install() const {
return payload_->mode->supports_multi_install; return payload_->mode->supported_multi_install;
} }
// The install's update channel, or an empty string if the brand does not // The install's update channel, or an empty string if the brand does not
...@@ -102,21 +99,16 @@ class InstallDetails { ...@@ -102,21 +99,16 @@ class InstallDetails {
return std::wstring(payload_->channel, payload_->channel_length); return std::wstring(payload_->channel, payload_->channel_length);
} }
bool system_level() const { return payload_->system_level; } bool system_level() const { return payload_->system_level; }
bool multi_install() const { return payload_->multi_install; }
// Returns the path to the installation's ClientState registry key. This
// Returns the path to the installation's ClientState registry key. Returns // registry key is used to hold various installation-related values, including
// the path for the binaries if |binaries| and Chrome is // an indication of consent for usage stats.
// multi-install. Otherwise, returns the path for Chrome itself. This registry std::wstring GetClientStateKeyPath() const;
// key is used to hold various installation-related values, including an
// indication of consent for usage stats. // Returns the path to the installation's ClientStateMedium registry key. This
std::wstring GetClientStateKeyPath(bool binaries) const;
// Returns the path to the installation's ClientStateMedium registry key.
// Returns the path for the binaries if |binaries| and Chrome is
// multi-install. Otherwise, returns the path for Chrome itself. This
// registry key is used to hold various installation-related values, including // registry key is used to hold various installation-related values, including
// an indication of consent for usage stats for a system-level install. // an indication of consent for usage stats for a system-level install.
std::wstring GetClientStateMediumKeyPath(bool binaries) const; std::wstring GetClientStateMediumKeyPath() const;
// Returns true if there is an indication of a mismatch between the primary // Returns true if there is an indication of a mismatch between the primary
// module and this module. // module and this module.
...@@ -168,9 +160,6 @@ class PrimaryInstallDetails : public InstallDetails { ...@@ -168,9 +160,6 @@ class PrimaryInstallDetails : public InstallDetails {
void set_system_level(bool system_level) { void set_system_level(bool system_level) {
payload_.system_level = system_level; payload_.system_level = system_level;
} }
void set_multi_install(bool multi_install) {
payload_.multi_install = multi_install;
}
private: private:
std::wstring channel_; std::wstring channel_;
......
...@@ -22,7 +22,7 @@ class FakeInstallDetails : public InstallDetails { ...@@ -22,7 +22,7 @@ class FakeInstallDetails : public InstallDetails {
constants.size = sizeof(constants); constants.size = sizeof(constants);
constants.install_suffix = L""; constants.install_suffix = L"";
constants.default_channel_name = L""; constants.default_channel_name = L"";
constants.supports_multi_install = true; constants.supported_multi_install = true;
if (kUseGoogleUpdateIntegration) { if (kUseGoogleUpdateIntegration) {
constants.app_guid = L"testguid"; constants.app_guid = L"testguid";
constants.channel_strategy = ChannelStrategy::FIXED; constants.channel_strategy = ChannelStrategy::FIXED;
...@@ -57,68 +57,23 @@ class FakeInstallDetails : public InstallDetails { ...@@ -57,68 +57,23 @@ class FakeInstallDetails : public InstallDetails {
TEST(InstallDetailsTest, GetClientStateKeyPath) { TEST(InstallDetailsTest, GetClientStateKeyPath) {
FakeInstallDetails details; FakeInstallDetails details;
if (kUseGoogleUpdateIntegration) { if (kUseGoogleUpdateIntegration) {
// Single-install. EXPECT_THAT(details.GetClientStateKeyPath(),
EXPECT_THAT(details.GetClientStateKeyPath(false),
StrEq(L"Software\\Google\\Update\\ClientState\\testguid")); StrEq(L"Software\\Google\\Update\\ClientState\\testguid"));
EXPECT_THAT(details.GetClientStateKeyPath(true),
StrEq(L"Software\\Google\\Update\\ClientState\\testguid"));
// Multi-install.
details.payload.multi_install = true;
EXPECT_THAT(details.GetClientStateKeyPath(false),
StrEq(L"Software\\Google\\Update\\ClientState\\testguid"));
EXPECT_THAT(details.GetClientStateKeyPath(true),
StrEq(std::wstring(L"Software\\Google\\Update\\ClientState\\")
.append(kBinariesAppGuid)));
} else { } else {
// Single-install. EXPECT_THAT(details.GetClientStateKeyPath(),
EXPECT_THAT(details.GetClientStateKeyPath(false),
StrEq(std::wstring(L"Software\\").append(kProductPathName)));
EXPECT_THAT(details.GetClientStateKeyPath(true),
StrEq(std::wstring(L"Software\\").append(kProductPathName))); StrEq(std::wstring(L"Software\\").append(kProductPathName)));
// Multi-install.
details.payload.multi_install = true;
EXPECT_THAT(details.GetClientStateKeyPath(false),
StrEq(std::wstring(L"Software\\").append(kProductPathName)));
EXPECT_THAT(details.GetClientStateKeyPath(true),
StrEq(std::wstring(L"Software\\").append(kBinariesPathName)));
} }
} }
TEST(InstallDetailsTest, GetClientStateMediumKeyPath) { TEST(InstallDetailsTest, GetClientStateMediumKeyPath) {
FakeInstallDetails details; FakeInstallDetails details;
if (kUseGoogleUpdateIntegration) { if (kUseGoogleUpdateIntegration) {
// Single-install.
EXPECT_THAT(
details.GetClientStateMediumKeyPath(false),
StrEq(L"Software\\Google\\Update\\ClientStateMedium\\testguid"));
EXPECT_THAT( EXPECT_THAT(
details.GetClientStateMediumKeyPath(true), details.GetClientStateMediumKeyPath(),
StrEq(L"Software\\Google\\Update\\ClientStateMedium\\testguid")); StrEq(L"Software\\Google\\Update\\ClientStateMedium\\testguid"));
// Multi-install.
details.payload.multi_install = true;
EXPECT_THAT(
details.GetClientStateMediumKeyPath(false),
StrEq(L"Software\\Google\\Update\\ClientStateMedium\\testguid"));
EXPECT_THAT(
details.GetClientStateMediumKeyPath(true),
StrEq(std::wstring(L"Software\\Google\\Update\\ClientStateMedium\\")
.append(kBinariesAppGuid)));
} else { } else {
// Single-install. EXPECT_THAT(details.GetClientStateKeyPath(),
EXPECT_THAT(details.GetClientStateKeyPath(false),
StrEq(std::wstring(L"Software\\").append(kProductPathName)));
EXPECT_THAT(details.GetClientStateKeyPath(true),
StrEq(std::wstring(L"Software\\").append(kProductPathName)));
// Multi-install.
details.payload.multi_install = true;
EXPECT_THAT(details.GetClientStateKeyPath(false),
StrEq(std::wstring(L"Software\\").append(kProductPathName))); StrEq(std::wstring(L"Software\\").append(kProductPathName)));
EXPECT_THAT(details.GetClientStateKeyPath(true),
StrEq(std::wstring(L"Software\\").append(kBinariesPathName)));
} }
} }
......
...@@ -52,14 +52,14 @@ extern const wchar_t kProductPathName[]; ...@@ -52,14 +52,14 @@ extern const wchar_t kProductPathName[];
// The length, in characters, of kProductPathName not including the terminator. // The length, in characters, of kProductPathName not including the terminator.
extern const size_t kProductPathNameLength; extern const size_t kProductPathNameLength;
// The GUID with which the brand's multi-install binaries are registered with // The GUID with which the brand's multi-install binaries were registered with
// Google Update. Must be empty if the brand does not integrate with Google // Google Update for modes that once supported the now-deprecated multi-install.
// Update. // Must be empty if the brand does not integrate with Google Update.
extern const wchar_t kBinariesAppGuid[]; extern const wchar_t kBinariesAppGuid[];
// The name of the registry key in which data for the brand's multi-install // The name of the registry key in which data for the brand's multi-install
// binaries are stored. Must be empty if the brand integrates with Google // binaries were stored for modes that once supported the now-deprecated
// Update. // multi-install. Must be empty if the brand integrates with Google Update.
extern const wchar_t kBinariesPathName[]; extern const wchar_t kBinariesPathName[];
// A brand's collection of install modes. // A brand's collection of install modes.
......
...@@ -45,11 +45,11 @@ TEST(InstallModes, VerifyModes) { ...@@ -45,11 +45,11 @@ TEST(InstallModes, VerifyModes) {
TEST(InstallModes, VerifyBrand) { TEST(InstallModes, VerifyBrand) {
if (kUseGoogleUpdateIntegration) { if (kUseGoogleUpdateIntegration) {
// Binaries are registered under an app guid with Google Update integration. // Binaries were registered via an app guid with Google Update integration.
ASSERT_THAT(kBinariesAppGuid, StrNe(L"")); ASSERT_THAT(kBinariesAppGuid, StrNe(L""));
ASSERT_THAT(kBinariesPathName, StrEq(L"")); ASSERT_THAT(kBinariesPathName, StrEq(L""));
} else { } else {
// Binaries are registered under a different path name without. // Binaries were registered via a different path name without.
ASSERT_THAT(kBinariesAppGuid, StrEq(L"")); ASSERT_THAT(kBinariesAppGuid, StrEq(L""));
ASSERT_THAT(kBinariesPathName, StrNe(L"")); ASSERT_THAT(kBinariesPathName, StrNe(L""));
} }
......
...@@ -257,21 +257,17 @@ std::vector<StringType> TokenizeStringT( ...@@ -257,21 +257,17 @@ std::vector<StringType> TokenizeStringT(
} }
std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode, std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode,
bool system_level, bool system_level) {
bool binaries) {
assert(kUseGoogleUpdateIntegration); assert(kUseGoogleUpdateIntegration);
// InitChannelInfo in google_update_settings.cc only reports a failure in the // InitChannelInfo in google_update_settings.cc only reports a failure when
// case of multi-install Chrome where the binaries' ClientState key exists, // Chrome's ClientState key exists but that the "ap" value therein cannot be
// but that the "ap" value therein cannot be read due to some reason *other* // read due to some reason *other* than it not being present. This should be
// than it not being present. This should be exceedingly rare. For // exceedingly rare. For simplicity's sake, use an empty |value| in case of
// simplicity's sake, use an empty |value| in case of any error whatsoever // any error whatsoever here.
// here.
std::wstring value; std::wstring value;
nt::QueryRegValueSZ(system_level ? nt::HKLM : nt::HKCU, nt::WOW6432, nt::QueryRegValueSZ(system_level ? nt::HKLM : nt::HKCU, nt::WOW6432,
(binaries ? GetBinariesClientStateKeyPath() GetClientStateKeyPath(mode.app_guid).c_str(), kRegValueAp,
: GetClientStateKeyPath(mode.app_guid)) &value);
.c_str(),
kRegValueAp, &value);
static constexpr wchar_t kChromeChannelBetaPattern[] = L"1?1-*"; static constexpr wchar_t kChromeChannelBetaPattern[] = L"1?1-*";
static constexpr wchar_t kChromeChannelBetaX64Pattern[] = L"*x64-beta*"; static constexpr wchar_t kChromeChannelBetaX64Pattern[] = L"*x64-beta*";
...@@ -294,7 +290,7 @@ std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode, ...@@ -294,7 +290,7 @@ std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode,
} }
// Else report values with garbage as stable since they will match the stable // Else report values with garbage as stable since they will match the stable
// rules in the update configs. ChannelInfo::GetChannelName painstakingly // rules in the update configs. ChannelInfo::GetChannelName painstakingly
// strips off known modifiers (e.g., "-multi-full") to see if the empty string // strips off known modifiers (e.g., "-full") to see if the empty string
// remains, returning channel "unknown" if not. This differs here in that some // remains, returning channel "unknown" if not. This differs here in that some
// clients will tag crashes as "stable" rather than "unknown" via this // clients will tag crashes as "stable" rather than "unknown" via this
// codepath, but it is an accurate reflection of which update channel the // codepath, but it is an accurate reflection of which update channel the
...@@ -309,10 +305,6 @@ bool IsSystemInstall() { ...@@ -309,10 +305,6 @@ bool IsSystemInstall() {
return InstallDetails::Get().system_level(); return InstallDetails::Get().system_level();
} }
bool IsMultiInstall() {
return InstallDetails::Get().multi_install();
}
bool GetCollectStatsConsent() { bool GetCollectStatsConsent() {
bool enabled = true; bool enabled = true;
...@@ -327,7 +319,7 @@ bool GetCollectStatsConsent() { ...@@ -327,7 +319,7 @@ bool GetCollectStatsConsent() {
if (system_install && if (system_install &&
nt::QueryRegValueDWORD( nt::QueryRegValueDWORD(
nt::HKLM, nt::WOW6432, nt::HKLM, nt::WOW6432,
InstallDetails::Get().GetClientStateMediumKeyPath(true).c_str(), InstallDetails::Get().GetClientStateMediumKeyPath().c_str(),
kRegValueUsageStats, &out_value)) { kRegValueUsageStats, &out_value)) {
return (out_value == 1); return (out_value == 1);
} }
...@@ -335,7 +327,7 @@ bool GetCollectStatsConsent() { ...@@ -335,7 +327,7 @@ bool GetCollectStatsConsent() {
// Second, try ClientState. // Second, try ClientState.
return (nt::QueryRegValueDWORD( return (nt::QueryRegValueDWORD(
system_install ? nt::HKLM : nt::HKCU, nt::WOW6432, system_install ? nt::HKLM : nt::HKCU, nt::WOW6432,
InstallDetails::Get().GetClientStateKeyPath(true).c_str(), InstallDetails::Get().GetClientStateKeyPath().c_str(),
kRegValueUsageStats, &out_value) && kRegValueUsageStats, &out_value) &&
out_value == 1); out_value == 1);
} }
...@@ -513,16 +505,11 @@ void GetExecutableVersionDetails(const std::wstring& exe_path, ...@@ -513,16 +505,11 @@ void GetExecutableVersionDetails(const std::wstring& exe_path,
GetValueFromVersionResource(data.get(), L"SpecialBuild", special_build); GetValueFromVersionResource(data.get(), L"SpecialBuild", special_build);
} }
} }
*channel_name = GetChromeChannelName(true /* add_modifier */); *channel_name = GetChromeChannelName();
} }
std::wstring GetChromeChannelName(bool add_modifier) { std::wstring GetChromeChannelName() {
const std::wstring& channel = InstallDetails::Get().channel(); return InstallDetails::Get().channel();
if (!add_modifier || !IsMultiInstall())
return channel;
if (channel.empty())
return L"m";
return channel + L"-m";
} }
std::wstring GetBrowserCrashDumpAttemptsRegistryPath() { std::wstring GetBrowserCrashDumpAttemptsRegistryPath() {
...@@ -748,9 +735,7 @@ bool RecursiveDirectoryCreate(const std::wstring& full_path) { ...@@ -748,9 +735,7 @@ bool RecursiveDirectoryCreate(const std::wstring& full_path) {
// This function takes these inputs rather than accessing the module's // This function takes these inputs rather than accessing the module's
// InstallDetails instance since it is used to bootstrap InstallDetails. // InstallDetails instance since it is used to bootstrap InstallDetails.
std::wstring DetermineChannel(const InstallConstants& mode, std::wstring DetermineChannel(const InstallConstants& mode, bool system_level) {
bool system_level,
bool multi_install) {
if (!kUseGoogleUpdateIntegration) if (!kUseGoogleUpdateIntegration)
return std::wstring(); return std::wstring();
...@@ -759,7 +744,7 @@ std::wstring DetermineChannel(const InstallConstants& mode, ...@@ -759,7 +744,7 @@ std::wstring DetermineChannel(const InstallConstants& mode,
assert(false); assert(false);
break; break;
case ChannelStrategy::ADDITIONAL_PARAMETERS: case ChannelStrategy::ADDITIONAL_PARAMETERS:
return ChannelFromAdditionalParameters(mode, system_level, multi_install); return ChannelFromAdditionalParameters(mode, system_level);
case ChannelStrategy::FIXED: case ChannelStrategy::FIXED:
return mode.default_channel_name; return mode.default_channel_name;
} }
......
...@@ -53,9 +53,6 @@ template <typename T> inline void IgnoreUnused(T) {} ...@@ -53,9 +53,6 @@ template <typename T> inline void IgnoreUnused(T) {}
// Returns true if Chrome is running at system level. // Returns true if Chrome is running at system level.
bool IsSystemInstall(); bool IsSystemInstall();
// Returns true if current installation of Chrome is a multi-install.
bool IsMultiInstall();
// Returns true if usage stats collecting is enabled for this user for the // Returns true if usage stats collecting is enabled for this user for the
// current executable. // current executable.
bool GetCollectStatsConsent(); bool GetCollectStatsConsent();
...@@ -125,13 +122,10 @@ void GetExecutableVersionDetails(const std::wstring& exe_path, ...@@ -125,13 +122,10 @@ void GetExecutableVersionDetails(const std::wstring& exe_path,
std::wstring* channel_name); std::wstring* channel_name);
// Gets the channel name for the current Chrome process. // Gets the channel name for the current Chrome process.
// If |add_modifier| is true the channel name is returned with the modifier
// prepended to it. Currently this is only done for multi installs, i.e (-m)
// is the only modifier supported.
// TODO(ananta) // TODO(ananta)
// http://crbug.com/604923 // http://crbug.com/604923
// Unify this with the Browser Distribution code. // Unify this with the Browser Distribution code.
std::wstring GetChromeChannelName(bool add_modifier); std::wstring GetChromeChannelName();
// Returns the registry path where the browser crash dumps metrics need to be // Returns the registry path where the browser crash dumps metrics need to be
// written to. // written to.
...@@ -184,9 +178,7 @@ bool RecursiveDirectoryCreate(const std::wstring& full_path); ...@@ -184,9 +178,7 @@ bool RecursiveDirectoryCreate(const std::wstring& full_path);
// Returns the unadorned channel name based on the channel strategy for the // Returns the unadorned channel name based on the channel strategy for the
// install mode. // install mode.
std::wstring DetermineChannel(const InstallConstants& mode, std::wstring DetermineChannel(const InstallConstants& mode, bool system_level);
bool system_level,
bool multi_install);
// Caches the |ProcessType| of the current process. // Caches the |ProcessType| of the current process.
extern ProcessType g_process_type; extern ProcessType g_process_type;
......
...@@ -267,20 +267,17 @@ TEST(InstallStaticTest, BrowserProcessTest) { ...@@ -267,20 +267,17 @@ TEST(InstallStaticTest, BrowserProcessTest) {
class InstallStaticUtilTest class InstallStaticUtilTest
: public ::testing::TestWithParam< : public ::testing::TestWithParam<
std::tuple<InstallConstantIndex, const char*, const char*>> { std::tuple<InstallConstantIndex, const char*>> {
protected: protected:
InstallStaticUtilTest() { InstallStaticUtilTest() {
InstallConstantIndex mode_index; InstallConstantIndex mode_index;
const char* level; const char* level;
const char* mode;
std::tie(mode_index, level, mode) = GetParam(); std::tie(mode_index, level) = GetParam();
mode_ = &kInstallModes[mode_index]; mode_ = &kInstallModes[mode_index];
system_level_ = std::string(level) != "user"; system_level_ = std::string(level) != "user";
EXPECT_TRUE(!system_level_ || mode_->supports_system_level); EXPECT_TRUE(!system_level_ || mode_->supports_system_level);
multi_install_ = std::string(mode) != "single";
EXPECT_TRUE(!multi_install_ || mode_->supports_multi_install);
root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
nt_root_key_ = system_level_ ? nt::HKLM : nt::HKCU; nt_root_key_ = system_level_ ? nt::HKLM : nt::HKCU;
...@@ -289,7 +286,6 @@ class InstallStaticUtilTest ...@@ -289,7 +286,6 @@ class InstallStaticUtilTest
details->set_mode(mode_); details->set_mode(mode_);
details->set_channel(mode_->default_channel_name); details->set_channel(mode_->default_channel_name);
details->set_system_level(system_level_); details->set_system_level(system_level_);
details->set_multi_install(multi_install_);
InstallDetails::SetForProcess(std::move(details)); InstallDetails::SetForProcess(std::move(details));
base::string16 path; base::string16 path;
...@@ -304,8 +300,6 @@ class InstallStaticUtilTest ...@@ -304,8 +300,6 @@ class InstallStaticUtilTest
bool system_level() const { return system_level_; } bool system_level() const { return system_level_; }
bool multi_install() const { return multi_install_; }
const wchar_t* default_channel() const { return mode_->default_channel_name; } const wchar_t* default_channel() const { return mode_->default_channel_name; }
void SetUsageStat(DWORD value, bool medium) { void SetUsageStat(DWORD value, bool medium) {
...@@ -341,12 +335,7 @@ class InstallStaticUtilTest ...@@ -341,12 +335,7 @@ class InstallStaticUtilTest
if (medium) if (medium)
result.append(L"Medium"); result.append(L"Medium");
result.push_back(L'\\'); result.push_back(L'\\');
if (multi_install_) result.append(mode_->app_guid);
result.append(kBinariesAppGuid);
else
result.append(mode_->app_guid);
} else if (multi_install_) {
result.append(kBinariesPathName);
} else { } else {
result.append(kProductPathName); result.append(kProductPathName);
} }
...@@ -358,7 +347,6 @@ class InstallStaticUtilTest ...@@ -358,7 +347,6 @@ class InstallStaticUtilTest
nt::ROOT_KEY nt_root_key_ = nt::AUTO; nt::ROOT_KEY nt_root_key_ = nt::AUTO;
const InstallConstants* mode_ = nullptr; const InstallConstants* mode_ = nullptr;
bool system_level_ = false; bool system_level_ = false;
bool multi_install_ = false;
DISALLOW_COPY_AND_ASSIGN(InstallStaticUtilTest); DISALLOW_COPY_AND_ASSIGN(InstallStaticUtilTest);
}; };
...@@ -423,37 +411,26 @@ TEST_P(InstallStaticUtilTest, UsageStatsPolicy) { ...@@ -423,37 +411,26 @@ TEST_P(InstallStaticUtilTest, UsageStatsPolicy) {
} }
TEST_P(InstallStaticUtilTest, GetChromeChannelName) { TEST_P(InstallStaticUtilTest, GetChromeChannelName) {
EXPECT_EQ(default_channel(), GetChromeChannelName(false)); EXPECT_EQ(default_channel(), GetChromeChannelName());
std::wstring expected = default_channel();
if (multi_install()) {
if (expected.empty())
expected = L"m";
else
expected += L"-m";
}
EXPECT_EQ(expected, GetChromeChannelName(true));
} }
#if defined(GOOGLE_CHROME_BUILD) #if defined(GOOGLE_CHROME_BUILD)
// Stable supports multi-install at user and system levels. // Stable supports user and system levels.
INSTANTIATE_TEST_CASE_P(Stable, INSTANTIATE_TEST_CASE_P(Stable,
InstallStaticUtilTest, InstallStaticUtilTest,
testing::Combine(testing::Values(STABLE_INDEX), testing::Combine(testing::Values(STABLE_INDEX),
testing::Values("user", "system"), testing::Values("user", "system")));
testing::Values("single", "multi"))); // Canary is only at user level.
// Canary is single-only at user level.
INSTANTIATE_TEST_CASE_P(Canary, INSTANTIATE_TEST_CASE_P(Canary,
InstallStaticUtilTest, InstallStaticUtilTest,
testing::Combine(testing::Values(CANARY_INDEX), testing::Combine(testing::Values(CANARY_INDEX),
testing::Values("user"), testing::Values("user")));
testing::Values("single")));
#else // GOOGLE_CHROME_BUILD #else // GOOGLE_CHROME_BUILD
// Chromium supports multi-install at user and system levels. // Chromium supports user and system levels.
INSTANTIATE_TEST_CASE_P(Chromium, INSTANTIATE_TEST_CASE_P(Chromium,
InstallStaticUtilTest, InstallStaticUtilTest,
testing::Combine(testing::Values(CHROMIUM_INDEX), testing::Combine(testing::Values(CHROMIUM_INDEX),
testing::Values("user", "system"), testing::Values("user", "system")));
testing::Values("single", "multi")));
#endif // !GOOGLE_CHROME_BUILD #endif // !GOOGLE_CHROME_BUILD
} // namespace install_static } // namespace install_static
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/install_static/product_install_details.h" #include "chrome/install_static/product_install_details.h"
#include <windows.h> #include <windows.h>
#include <assert.h>
#include <algorithm> #include <algorithm>
...@@ -119,15 +118,6 @@ std::wstring GetInstallSuffix(const std::wstring& exe_path) { ...@@ -119,15 +118,6 @@ std::wstring GetInstallSuffix(const std::wstring& exe_path) {
(name - scan) - kProductPathNameLength); (name - scan) - kProductPathNameLength);
} }
bool IsMultiInstall(const InstallConstants& mode, bool system_level) {
assert(mode.supports_multi_install);
std::wstring args;
return nt::QueryRegValueSZ(system_level ? nt::HKLM : nt::HKCU, nt::WOW6432,
GetClientStateKeyPath(mode.app_guid).c_str(),
L"UninstallArguments", &args) &&
args.find(L"--multi-install") != std::wstring::npos;
}
std::unique_ptr<PrimaryInstallDetails> MakeProductDetails( std::unique_ptr<PrimaryInstallDetails> MakeProductDetails(
const std::wstring& exe_path) { const std::wstring& exe_path) {
std::unique_ptr<PrimaryInstallDetails> details(new PrimaryInstallDetails()); std::unique_ptr<PrimaryInstallDetails> details(new PrimaryInstallDetails());
...@@ -135,13 +125,10 @@ std::unique_ptr<PrimaryInstallDetails> MakeProductDetails( ...@@ -135,13 +125,10 @@ std::unique_ptr<PrimaryInstallDetails> MakeProductDetails(
const InstallConstants* mode = FindInstallMode(GetInstallSuffix(exe_path)); const InstallConstants* mode = FindInstallMode(GetInstallSuffix(exe_path));
const bool system_level = const bool system_level =
mode->supports_system_level && PathIsInProgramFiles(exe_path); mode->supports_system_level && PathIsInProgramFiles(exe_path);
const bool multi_install =
mode->supports_multi_install && IsMultiInstall(*mode, system_level);
details->set_mode(mode); details->set_mode(mode);
details->set_system_level(system_level); details->set_system_level(system_level);
details->set_multi_install(multi_install); details->set_channel(DetermineChannel(*mode, system_level));
details->set_channel(DetermineChannel(*mode, system_level, multi_install));
return details; return details;
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
namespace install_static { namespace install_static {
struct InstallConstants;
class PrimaryInstallDetails; class PrimaryInstallDetails;
// Creates product details for the current process and sets them as the global // Creates product details for the current process and sets them as the global
...@@ -36,10 +35,6 @@ bool PathIsInProgramFiles(const std::wstring& path); ...@@ -36,10 +35,6 @@ bool PathIsInProgramFiles(const std::wstring& path);
// "...\[kProductName][suffix]\Application". // "...\[kProductName][suffix]\Application".
std::wstring GetInstallSuffix(const std::wstring& exe_path); std::wstring GetInstallSuffix(const std::wstring& exe_path);
// Returns true if the browser of |mode| at |system_level| is registered as
// being multi-install.
bool IsMultiInstall(const InstallConstants& mode, bool system_level);
// Creates product details for the process at |exe_path|. // Creates product details for the process at |exe_path|.
std::unique_ptr<PrimaryInstallDetails> MakeProductDetails( std::unique_ptr<PrimaryInstallDetails> MakeProductDetails(
const std::wstring& exe_path); const std::wstring& exe_path);
......
...@@ -184,38 +184,20 @@ class MakeProductDetailsTest : public testing::TestWithParam<TestData> { ...@@ -184,38 +184,20 @@ class MakeProductDetailsTest : public testing::TestWithParam<TestData> {
const TestData& test_data() const { return test_data_; } const TestData& test_data() const { return test_data_; }
void SetUninstallArguments(const wchar_t* value) { void SetAp(const wchar_t* value) {
ASSERT_THAT( ASSERT_THAT(base::win::RegKey(root_key_, GetClientStateKeyPath().c_str(),
base::win::RegKey(root_key_, GetClientStateKeyPath(false).c_str(), KEY_WOW64_32KEY | KEY_SET_VALUE)
KEY_WOW64_32KEY | KEY_SET_VALUE) .WriteValue(L"ap", value),
.WriteValue(L"UninstallArguments", value), Eq(ERROR_SUCCESS));
Eq(ERROR_SUCCESS));
}
void SetAp(const wchar_t* value, bool binaries) {
ASSERT_TRUE(!binaries ||
kInstallModes[test_data().index].supports_multi_install);
ASSERT_THAT(
base::win::RegKey(root_key_, GetClientStateKeyPath(binaries).c_str(),
KEY_WOW64_32KEY | KEY_SET_VALUE)
.WriteValue(L"ap", value),
Eq(ERROR_SUCCESS));
} }
private: private:
// Returns the registry path for the product's ClientState key. // Returns the registry path for the product's ClientState key.
std::wstring GetClientStateKeyPath(bool binaries) { std::wstring GetClientStateKeyPath() {
EXPECT_TRUE(!binaries ||
kInstallModes[test_data().index].supports_multi_install);
std::wstring result(L"Software\\"); std::wstring result(L"Software\\");
if (kUseGoogleUpdateIntegration) { if (kUseGoogleUpdateIntegration) {
result.append(L"Google\\Update\\ClientState\\"); result.append(L"Google\\Update\\ClientState\\");
if (binaries) result.append(kInstallModes[test_data().index].app_guid);
result.append(kBinariesAppGuid);
else
result.append(kInstallModes[test_data().index].app_guid);
} else if (binaries) {
result.append(kBinariesPathName);
} else { } else {
result.append(kProductPathName); result.append(kProductPathName);
} }
...@@ -251,32 +233,6 @@ TEST_P(MakeProductDetailsTest, DefaultChannel) { ...@@ -251,32 +233,6 @@ TEST_P(MakeProductDetailsTest, DefaultChannel) {
EXPECT_THAT(details->channel(), StrEq(test_data().channel)); EXPECT_THAT(details->channel(), StrEq(test_data().channel));
} }
// Test that multi-install is properly parsed out of the registry.
TEST_P(MakeProductDetailsTest, MultiInstall) {
{
std::unique_ptr<PrimaryInstallDetails> details(
MakeProductDetails(test_data().path));
EXPECT_FALSE(details->multi_install());
}
{
SetUninstallArguments(L"--uninstall");
std::unique_ptr<PrimaryInstallDetails> details(
MakeProductDetails(test_data().path));
EXPECT_FALSE(details->multi_install());
}
if (!kInstallModes[test_data().index].supports_multi_install)
return;
{
SetUninstallArguments(L"--uninstall --multi-install --chrome");
std::unique_ptr<PrimaryInstallDetails> details(
MakeProductDetails(test_data().path));
EXPECT_TRUE(details->multi_install());
}
}
// Test that the channel name is properly parsed out of additional parameters. // Test that the channel name is properly parsed out of additional parameters.
TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) { TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) {
const std::pair<const wchar_t*, const wchar_t*> kApChannels[] = { const std::pair<const wchar_t*, const wchar_t*> kApChannels[] = {
...@@ -292,10 +248,10 @@ TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) { ...@@ -292,10 +248,10 @@ TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) {
{L"1.0-dev", L""}, {L"1.0-dev", L""},
{L"fuzzy", L""}, {L"fuzzy", L""},
{L"foo", L""}, {L"foo", L""},
{L"-multi-chrome", L""}, {L"-multi-chrome", L""}, // Legacy.
{L"x64-stable-multi-chrome", L""}, {L"x64-stable-multi-chrome", L""}, // Legacy.
{L"-stage:ensemble_patching-multi-chrome-full", L""}, {L"-stage:ensemble_patching-multi-chrome-full", L""}, // Legacy.
{L"-multi-chrome-full", L""}, {L"-multi-chrome-full", L""}, // Legacy.
// beta // beta
{L"1.1-beta", L"beta"}, {L"1.1-beta", L"beta"},
{L"1.1-beta-full", L"beta"}, {L"1.1-beta-full", L"beta"},
...@@ -317,25 +273,7 @@ TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) { ...@@ -317,25 +273,7 @@ TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) {
}; };
for (const auto& ap_and_channel : kApChannels) { for (const auto& ap_and_channel : kApChannels) {
SetAp(ap_and_channel.first, false); SetAp(ap_and_channel.first);
std::unique_ptr<PrimaryInstallDetails> details(
MakeProductDetails(test_data().path));
if (kInstallModes[test_data().index].channel_strategy ==
ChannelStrategy::ADDITIONAL_PARAMETERS) {
EXPECT_THAT(details->channel(), StrEq(ap_and_channel.second));
} else {
// "ap" is ignored for this mode.
EXPECT_THAT(details->channel(), StrEq(test_data().channel));
}
}
if (!kInstallModes[test_data().index].supports_multi_install)
return;
// For multi-install modes, "ap" is pulled from the binaries' key.
for (const auto& ap_and_channel : kApChannels) {
SetAp(ap_and_channel.first, true);
SetUninstallArguments(L"--uninstall --multi-install --chrome");
std::unique_ptr<PrimaryInstallDetails> details( std::unique_ptr<PrimaryInstallDetails> details(
MakeProductDetails(test_data().path)); MakeProductDetails(test_data().path));
if (kInstallModes[test_data().index].channel_strategy == if (kInstallModes[test_data().index].channel_strategy ==
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment