summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/installer/util')
-rw-r--r--chrome/installer/util/channel_info.cc4
-rw-r--r--chrome/installer/util/channel_info.h5
-rw-r--r--chrome/installer/util/google_update_settings_unittest.cc20
3 files changed, 18 insertions, 11 deletions
diff --git a/chrome/installer/util/channel_info.cc b/chrome/installer/util/channel_info.cc
index f2bb28d..8e6665e 100644
--- a/chrome/installer/util/channel_info.cc
+++ b/chrome/installer/util/channel_info.cc
@@ -134,7 +134,9 @@ bool SetModifier(ModifierIndex index, bool set, std::wstring* ap_value) {
namespace installer {
bool ChannelInfo::Initialize(const RegKey& key) {
- return (key.ReadValue(google_update::kRegApField, &value_) == ERROR_SUCCESS);
+ LONG result = key.ReadValue(google_update::kRegApField, &value_);
+ return result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND ||
+ result == ERROR_INVALID_HANDLE;
}
bool ChannelInfo::Write(RegKey* key) const {
diff --git a/chrome/installer/util/channel_info.h b/chrome/installer/util/channel_info.h
index e9c46e1..c032abd 100644
--- a/chrome/installer/util/channel_info.h
+++ b/chrome/installer/util/channel_info.h
@@ -22,7 +22,10 @@ class ChannelInfo {
public:
// Initialize an instance from the "ap" value in a given registry key.
- // Returns false if the value could not be read from the registry.
+ // Returns false if the value is present but could not be read from the
+ // registry. Returns true if the value was not present or could be read.
+ // Also returns true if the key is not valid.
+ // An absent "ap" value is treated identically to an empty "ap" value.
bool Initialize(const base::win::RegKey& key);
// Writes the info to the "ap" value in a given registry key.
diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc
index 848d900..afe5ab4 100644
--- a/chrome/installer/util/google_update_settings_unittest.cc
+++ b/chrome/installer/util/google_update_settings_unittest.cc
@@ -181,17 +181,17 @@ class GoogleUpdateSettingsTest: public testing::Test {
} // namespace
-// Verify that we return failure on no registration,
+// Verify that we return success on no registration (which means stable),
// whether per-system or per-user install.
TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelAbsent) {
// Per-system first.
std::wstring channel;
- EXPECT_FALSE(GoogleUpdateSettings::GetChromeChannel(true, &channel));
- EXPECT_STREQ(L"unknown", channel.c_str());
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(true, &channel));
+ EXPECT_STREQ(L"", channel.c_str());
// Then per-user.
- EXPECT_FALSE(GoogleUpdateSettings::GetChromeChannel(false, &channel));
- EXPECT_STREQ(L"unknown", channel.c_str());
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(false, &channel));
+ EXPECT_STREQ(L"", channel.c_str());
}
// Test an empty Ap key for system and user.
@@ -201,15 +201,17 @@ TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptySystem) {
EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(true, &channel));
EXPECT_STREQ(L"", channel.c_str());
- // Per-user lookups should fail.
- EXPECT_FALSE(GoogleUpdateSettings::GetChromeChannel(false, &channel));
+ // Per-user lookups still succeed and return empty string.
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(false, &channel));
+ EXPECT_STREQ(L"", channel.c_str());
}
TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptyUser) {
SetApField(USER_INSTALL, L"");
- // Per-system lookup should fail.
+ // Per-system lookups still succeed and return empty string.
std::wstring channel;
- EXPECT_FALSE(GoogleUpdateSettings::GetChromeChannel(true, &channel));
+ EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(true, &channel));
+ EXPECT_STREQ(L"", channel.c_str());
// Per-user lookup should succeed.
EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(false, &channel));