summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-04 21:31:36 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-04 21:31:36 +0000
commitf982b0174be9e46fa61df53f0055c769cc0f1227 (patch)
tree7ee68da863143f006b5325bb4639925398fd1fb0
parentf81265343c9c80182cfb81dc119c2e457530d3bf (diff)
downloadchromium_src-f982b0174be9e46fa61df53f0055c769cc0f1227.zip
chromium_src-f982b0174be9e46fa61df53f0055c769cc0f1227.tar.gz
chromium_src-f982b0174be9e46fa61df53f0055c769cc0f1227.tar.bz2
Merge 274909 "Read multi-install chrome's channel from the binar..."
> Read multi-install chrome's channel from the binaries. > > BUG=380828 > R=robertshield@chromium.org > > Review URL: https://codereview.chromium.org/316103002 TBR=grt@chromium.org Review URL: https://codereview.chromium.org/315903003 git-svn-id: svn://svn.chromium.org/chrome/branches/1916/src@274913 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/installer/util/google_update_settings.cc39
-rw-r--r--chrome/installer/util/google_update_settings_unittest.cc54
2 files changed, 79 insertions, 14 deletions
diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc
index c6cba00..4059e9a 100644
--- a/chrome/installer/util/google_update_settings.cc
+++ b/chrome/installer/util/google_update_settings.cc
@@ -146,29 +146,40 @@ bool GetChromeChannelInternal(bool system_install,
bool add_multi_modifier,
base::string16* channel) {
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- if (dist->GetChromeChannel(channel)) {
- return true;
- }
- HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
- base::string16 reg_path = dist->GetStateKey();
- RegKey key(root_key, reg_path.c_str(), KEY_READ);
+ // Shortcut in case this distribution knows what channel it is (canary).
+ if (dist->GetChromeChannel(channel))
+ return true;
+ // Determine whether or not chrome is multi-install. If so, updates are
+ // delivered under the binaries' app guid, so that's where the relevant
+ // channel is found.
+ installer::ProductState state;
installer::ChannelInfo channel_info;
- if (!channel_info.Initialize(key)) {
- channel->assign(installer::kChromeChannelUnknown);
- return false;
+ ignore_result(state.Initialize(system_install, dist));
+ if (!state.is_multi_install()) {
+ // Use the channel info that was just read for this single-install chrome.
+ channel_info = state.channel();
+ } else {
+ // Read the channel info from the binaries' state key.
+ HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+ dist = BrowserDistribution::GetSpecificDistribution(
+ BrowserDistribution::CHROME_BINARIES);
+ RegKey key(root_key, dist->GetStateKey().c_str(), KEY_READ);
+
+ if (!channel_info.Initialize(key)) {
+ channel->assign(installer::kChromeChannelUnknown);
+ return false;
+ }
}
- if (!channel_info.GetChannelName(channel)) {
+ if (!channel_info.GetChannelName(channel))
channel->assign(installer::kChromeChannelUnknown);
- }
// Tag the channel name if this is a multi-install.
- if (add_multi_modifier && channel_info.IsMultiInstall()) {
- if (!channel->empty()) {
+ if (add_multi_modifier && state.is_multi_install()) {
+ if (!channel->empty())
channel->append(1, L'-');
- }
channel->append(1, L'm');
}
diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc
index 9eef4e5..0b08ef7 100644
--- a/chrome/installer/util/google_update_settings_unittest.cc
+++ b/chrome/installer/util/google_update_settings_unittest.cc
@@ -54,6 +54,37 @@ class GoogleUpdateSettingsTest : public testing::Test {
ASSERT_EQ(ERROR_SUCCESS, update_key.WriteValue(L"ap", value));
}
+ // Sets the "ap" field for a multi-install product (both the product and
+ // the binaries).
+ void SetMultiApField(SystemUserInstall is_system, const wchar_t* value) {
+ // Caller must specify a multi-install ap value.
+ ASSERT_NE(std::wstring::npos, std::wstring(value).find(L"-multi"));
+ HKEY root = is_system == SYSTEM_INSTALL ?
+ HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+ RegKey update_key;
+
+ // Write the ap value for both the product and the binaries.
+ BrowserDistribution* const kDists[] = {
+ BrowserDistribution::GetDistribution(),
+ BrowserDistribution::GetSpecificDistribution(
+ BrowserDistribution::CHROME_BINARIES)
+ };
+ for (size_t i = 0; i < arraysize(kDists); ++i) {
+ std::wstring path = kDists[i]->GetStateKey();
+ ASSERT_EQ(ERROR_SUCCESS, update_key.Create(root, path.c_str(),
+ KEY_WRITE));
+ ASSERT_EQ(ERROR_SUCCESS, update_key.WriteValue(L"ap", value));
+ }
+
+ // Make the product technically multi-install.
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ ASSERT_EQ(ERROR_SUCCESS,
+ update_key.Create(root, dist->GetStateKey().c_str(), KEY_WRITE));
+ ASSERT_EQ(ERROR_SUCCESS,
+ update_key.WriteValue(installer::kUninstallArgumentsField,
+ L"--multi-install"));
+ }
+
// Tests setting the ap= value to various combinations of values with
// prefixes and suffixes, while asserting on the correct channel value.
// Note that any non-empty ap= value that doesn't match ".*-{dev|beta}.*"
@@ -305,6 +336,29 @@ TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptyUser) {
EXPECT_STREQ(L"", channel.c_str());
}
+// Test that the channel is pulled from the binaries for multi-install products.
+TEST_F(GoogleUpdateSettingsTest, MultiInstallChannelFromBinaries) {
+ SetMultiApField(USER_INSTALL, L"2.0-dev-multi-chrome");
+ base::string16 channel;
+
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false,
+ &channel));
+ EXPECT_STREQ(L"dev-m", channel.c_str());
+
+ // See if the same happens if the product's ap is cleared.
+ SetApField(USER_INSTALL, L"");
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false,
+ &channel));
+ EXPECT_STREQ(L"dev-m", channel.c_str());
+
+ // Test the converse (binaries are stable, Chrome is other).
+ SetMultiApField(USER_INSTALL, L"-multi-chrome");
+ SetApField(USER_INSTALL, L"2.0-dev-multi-chrome");
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false,
+ &channel));
+ EXPECT_STREQ(L"m", channel.c_str());
+}
+
TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelVariousApValuesSystem) {
TestCurrentChromeChannelWithVariousApValues(SYSTEM_INSTALL);
}