summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-02 21:19:01 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-02 21:19:01 +0000
commit3e76e27b7504fef3150c8074b88954b679740769 (patch)
treee85a2a8b86f952e43da4856bf0f4d0a55587d7f4
parent6fc9077537613d42871b3ce6a0eb18f3924f6c99 (diff)
downloadchromium_src-3e76e27b7504fef3150c8074b88954b679740769.zip
chromium_src-3e76e27b7504fef3150c8074b88954b679740769.tar.gz
chromium_src-3e76e27b7504fef3150c8074b88954b679740769.tar.bz2
Fix platform_util::GetChannel on Windows.
GetChannel was confused in multi-user installs. It treated them as CHANNEL_UNKNOWN instead of their correct channels. BUG=81218 TEST=none Review URL: http://codereview.chromium.org/6893158 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83790 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/breakpad_win.cc4
-rw-r--r--chrome/browser/platform_util_win.cc23
-rw-r--r--chrome/installer/util/google_update_settings.cc68
-rw-r--r--chrome/installer/util/google_update_settings.h8
-rw-r--r--chrome/installer/util/google_update_settings_unittest.cc22
-rw-r--r--chrome_frame/chrome_tab.cc4
6 files changed, 80 insertions, 49 deletions
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc
index b7aa15c..f2b29ad 100644
--- a/chrome/app/breakpad_win.cc
+++ b/chrome/app/breakpad_win.cc
@@ -558,8 +558,8 @@ static DWORD __stdcall InitCrashReporterThread(void* param) {
} else {
// Capture more detail in crash dumps for beta and dev channel builds.
string16 channel_string;
- GoogleUpdateSettings::GetChromeChannel(!is_per_user_install,
- &channel_string);
+ GoogleUpdateSettings::GetChromeChannelAndModifiers(!is_per_user_install,
+ &channel_string);
if (channel_string == L"dev" || channel_string == L"beta" ||
channel_string == GoogleChromeSxSDistribution::ChannelName())
dump_type = kLargerDumpType;
diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc
index 1949e2b..41993d6 100644
--- a/chrome/browser/platform_util_win.cc
+++ b/chrome/browser/platform_util_win.cc
@@ -204,7 +204,8 @@ std::string GetVersionStringModifier() {
bool is_system_install =
!InstallUtil::IsPerUserInstall(module.value().c_str());
- GoogleUpdateSettings::GetChromeChannel(is_system_install, &channel);
+ GoogleUpdateSettings::GetChromeChannelAndModifiers(is_system_install,
+ &channel);
}
return UTF16ToASCII(channel);
#else
@@ -214,20 +215,22 @@ std::string GetVersionStringModifier() {
Channel GetChannel() {
#if defined(GOOGLE_CHROME_BUILD)
- // Call GoogleUpdateSettings::GetChromeChannel with |false| as the first
- // argument to avoid having it append "-m" to the channel name, or returning
- // "m" for the stable channel.
- string16 channel_16;
- GoogleUpdateSettings::GetChromeChannel(false, &channel_16);
- std::string channel = UTF16ToASCII(channel_16);
+ std::wstring channel(L"unknown");
+
+ FilePath module;
+ if (PathService::Get(base::FILE_MODULE, &module)) {
+ bool is_system_install =
+ !InstallUtil::IsPerUserInstall(module.value().c_str());
+ channel = GoogleUpdateSettings::GetChromeChannel(is_system_install);
+ }
if (channel.empty()) {
return CHANNEL_STABLE;
- } else if (channel == "beta") {
+ } else if (channel == L"beta") {
return CHANNEL_BETA;
- } else if (channel == "dev") {
+ } else if (channel == L"dev") {
return CHANNEL_DEV;
- } else if (channel == "canary") {
+ } else if (channel == L"canary") {
return CHANNEL_CANARY;
}
#endif
diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc
index 49d80ec..2b6b8ea 100644
--- a/chrome/installer/util/google_update_settings.cc
+++ b/chrome/installer/util/google_update_settings.cc
@@ -88,7 +88,40 @@ EulaSearchResult HasEULASetting(HKEY root, const std::wstring& state_key,
FOUND_SAME_SETTING : FOUND_OPPOSITE_SETTING;
}
-} // namespace.
+bool GetChromeChannelInternal(bool system_install,
+ bool add_multi_modifier,
+ std::wstring* channel) {
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ if (dist->GetChromeChannel(channel)) {
+ return true;
+ }
+
+ HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+ std::wstring reg_path = dist->GetStateKey();
+ RegKey key(root_key, reg_path.c_str(), KEY_READ);
+
+ installer::ChannelInfo channel_info;
+ if (!channel_info.Initialize(key)) {
+ channel->assign(L"unknown");
+ return false;
+ }
+
+ if (!channel_info.GetChannelName(channel)) {
+ channel->assign(L"unknown");
+ }
+
+ // Tag the channel name if this is a multi-install.
+ if (add_multi_modifier && channel_info.IsMultiInstall()) {
+ if (!channel->empty()) {
+ channel->append(1, L'-');
+ }
+ channel->append(1, L'm');
+ }
+
+ return true;
+}
+
+} // namespace
bool GoogleUpdateSettings::GetCollectStatsConsent() {
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
@@ -220,32 +253,15 @@ bool GoogleUpdateSettings::ClearReferral() {
return ClearGoogleUpdateStrKey(google_update::kRegReferralField);
}
-bool GoogleUpdateSettings::GetChromeChannel(bool system_install,
- std::wstring* channel) {
- BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- if (dist->GetChromeChannel(channel))
- return true;
-
- HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
- std::wstring reg_path = dist->GetStateKey();
- RegKey key(root_key, reg_path.c_str(), KEY_READ);
- installer::ChannelInfo channel_info;
- if (!channel_info.Initialize(key)) {
- *channel = L"unknown";
- return false;
- }
-
- if (!channel_info.GetChannelName(channel))
- *channel = L"unknown";
-
- // Tag the channel name if this is a multi-install product.
- if (channel_info.IsMultiInstall()) {
- if (!channel->empty())
- channel->append(1, L'-');
- channel->append(1, L'm');
- }
+std::wstring GoogleUpdateSettings::GetChromeChannel(bool system_install) {
+ std::wstring channel;
+ GetChromeChannelInternal(system_install, false, &channel);
+ return channel;
+}
- return true;
+bool GoogleUpdateSettings::GetChromeChannelAndModifiers(bool system_install,
+ std::wstring* channel) {
+ return GetChromeChannelInternal(system_install, true, channel);
}
void GoogleUpdateSettings::UpdateInstallStatus(bool system_install,
diff --git a/chrome/installer/util/google_update_settings.h b/chrome/installer/util/google_update_settings.h
index 002a532..f5ee53d 100644
--- a/chrome/installer/util/google_update_settings.h
+++ b/chrome/installer/util/google_update_settings.h
@@ -86,12 +86,18 @@ class GoogleUpdateSettings {
// true if this operation succeeded.
static bool ClearReferral();
+ // Returns only the channel name: "" (stable), "dev", "beta", "canary", or
+ // "unknown" if unknown. This value will not be modified by "-m" for a
+ // multi-install.
+ static std::wstring GetChromeChannel(bool system_install);
+
// Return a human readable modifier for the version string, e.g.
// the channel (dev, beta, stable). Returns true if this operation succeeded,
// on success, channel contains one of "", "unknown", "dev" or "beta" (unless
// it is a multi-install product, in which case it will return "m",
// "unknown-m", "dev-m", or "beta-m").
- static bool GetChromeChannel(bool system_install, std::wstring* channel);
+ static bool GetChromeChannelAndModifiers(bool system_install,
+ std::wstring* channel);
// This method changes the Google Update "ap" value to move the installation
// on to or off of one of the recovery channels.
diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc
index afe5ab4..c70e3a4 100644
--- a/chrome/installer/util/google_update_settings_unittest.cc
+++ b/chrome/installer/util/google_update_settings_unittest.cc
@@ -128,8 +128,8 @@ class GoogleUpdateSettingsTest: public testing::Test {
SetApField(install, ap.c_str());
std::wstring ret_channel;
- EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(is_system,
- &ret_channel));
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(
+ is_system, &ret_channel));
EXPECT_STREQ(channel, ret_channel.c_str())
<< "Expecting channel \"" << channel
<< "\" for ap=\"" << ap << "\"";
@@ -186,11 +186,13 @@ class GoogleUpdateSettingsTest: public testing::Test {
TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelAbsent) {
// Per-system first.
std::wstring channel;
- EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(true, &channel));
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(true,
+ &channel));
EXPECT_STREQ(L"", channel.c_str());
// Then per-user.
- EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(false, &channel));
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false,
+ &channel));
EXPECT_STREQ(L"", channel.c_str());
}
@@ -198,11 +200,13 @@ TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelAbsent) {
TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptySystem) {
SetApField(SYSTEM_INSTALL, L"");
std::wstring channel;
- EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(true, &channel));
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(true,
+ &channel));
EXPECT_STREQ(L"", channel.c_str());
// Per-user lookups still succeed and return empty string.
- EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(false, &channel));
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false,
+ &channel));
EXPECT_STREQ(L"", channel.c_str());
}
@@ -210,11 +214,13 @@ TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptyUser) {
SetApField(USER_INSTALL, L"");
// Per-system lookups still succeed and return empty string.
std::wstring channel;
- EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(true, &channel));
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(true,
+ &channel));
EXPECT_STREQ(L"", channel.c_str());
// Per-user lookup should succeed.
- EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(false, &channel));
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false,
+ &channel));
EXPECT_STREQ(L"", channel.c_str());
}
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc
index 330fd19..b7d2898 100644
--- a/chrome_frame/chrome_tab.cc
+++ b/chrome_frame/chrome_tab.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -308,7 +308,7 @@ HRESULT SetupRunOnce() {
std::wstring channel_name;
if (base::win::GetVersion() < base::win::VERSION_VISTA &&
- GoogleUpdateSettings::GetChromeChannel(true, &channel_name)) {
+ GoogleUpdateSettings::GetChromeChannelAndModifiers(true, &channel_name)) {
std::transform(channel_name.begin(), channel_name.end(),
channel_name.begin(), tolower);
// Use this only for the dev channel and CEEE channels.