summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/win/registry.cc1
-rw-r--r--chrome/installer/setup/uninstall.cc12
-rw-r--r--chrome/installer/util/install_util.cc5
-rw-r--r--chrome/installer/util/install_util.h8
-rw-r--r--chrome/installer/util/install_util_unittest.cc38
5 files changed, 49 insertions, 15 deletions
diff --git a/base/win/registry.cc b/base/win/registry.cc
index 72e0f6e..9a34f1f 100644
--- a/base/win/registry.cc
+++ b/base/win/registry.cc
@@ -125,7 +125,6 @@ LONG RegKey::DeleteKey(const wchar_t* name) {
LONG RegKey::DeleteValue(const wchar_t* value_name) {
DCHECK(key_);
- DCHECK(value_name);
LONG result = RegDeleteValue(key_, value_name);
return result;
}
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 7b10923..4171ea8 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -642,7 +642,7 @@ void RemoveFiletypeRegistration(const InstallerState& installer_state,
for (const wchar_t* const* filetype = &ShellUtil::kFileAssociations[0];
*filetype != NULL; ++filetype) {
if (InstallUtil::DeleteRegistryValueIf(
- root, (classes_path + *filetype).c_str(), L"",
+ root, (classes_path + *filetype).c_str(), NULL,
prog_id_pred) == InstallUtil::DELETED) {
cleared_assocs.push_back(*filetype);
}
@@ -730,12 +730,12 @@ bool DeleteChromeRegistrationKeys(const InstallerState& installer_state,
.append(1, L'\\')
.append(client_name);
open_key.assign(client_key).append(ShellUtil::kRegShellOpen);
- if (InstallUtil::DeleteRegistryKeyIf(root, client_key, open_key, L"",
+ if (InstallUtil::DeleteRegistryKeyIf(root, client_key, open_key, NULL,
open_command_pred) != InstallUtil::NOT_FOUND) {
// Delete the default value of SOFTWARE\Clients\StartMenuInternet if it
// references this Chrome (i.e., if it was made the default browser).
InstallUtil::DeleteRegistryValueIf(
- root, ShellUtil::kRegStartMenuInternet, L"",
+ root, ShellUtil::kRegStartMenuInternet, NULL,
InstallUtil::ValueEquals(client_name));
// Also delete the value for the default user if we're operating in
// HKLM.
@@ -744,7 +744,7 @@ bool DeleteChromeRegistrationKeys(const InstallerState& installer_state,
HKEY_USERS,
string16(L".DEFAULT\\").append(
ShellUtil::kRegStartMenuInternet).c_str(),
- L"", InstallUtil::ValueEquals(client_name));
+ NULL, InstallUtil::ValueEquals(client_name));
}
}
}
@@ -798,7 +798,7 @@ bool DeleteChromeRegistrationKeys(const InstallerState& installer_state,
// being processed; the iteration above will have no hits since registration
// lives in HKLM.
InstallUtil::DeleteRegistryValueIf(
- root, ShellUtil::kRegStartMenuInternet, L"",
+ root, ShellUtil::kRegStartMenuInternet, NULL,
InstallUtil::ValueEquals(dist->GetBaseAppName() + browser_entry_suffix));
// Delete each protocol association if it references this Chrome.
@@ -814,7 +814,7 @@ bool DeleteChromeRegistrationKeys(const InstallerState& installer_state,
parent_key.resize(base_length);
parent_key.append(*proto);
child_key.assign(parent_key).append(ShellUtil::kRegShellOpen);
- InstallUtil::DeleteRegistryKeyIf(root, parent_key, child_key, L"",
+ InstallUtil::DeleteRegistryKeyIf(root, parent_key, child_key, NULL,
open_command_pred);
}
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index 0c1dd99..e05edbf 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -423,7 +423,6 @@ InstallUtil::ConditionalDeleteResult InstallUtil::DeleteRegistryKeyIf(
const wchar_t* value_name,
const RegistryValuePredicate& predicate) {
DCHECK(root_key);
- DCHECK(value_name);
ConditionalDeleteResult delete_result = NOT_FOUND;
RegKey key;
string16 actual_value;
@@ -446,7 +445,6 @@ InstallUtil::ConditionalDeleteResult InstallUtil::DeleteRegistryValueIf(
const RegistryValuePredicate& predicate) {
DCHECK(root_key);
DCHECK(key_path);
- DCHECK(value_name);
ConditionalDeleteResult delete_result = NOT_FOUND;
RegKey key;
string16 actual_value;
@@ -456,7 +454,8 @@ InstallUtil::ConditionalDeleteResult InstallUtil::DeleteRegistryValueIf(
predicate.Evaluate(actual_value)) {
LONG result = key.DeleteValue(value_name);
if (result != ERROR_SUCCESS) {
- LOG(ERROR) << "Failed to delete registry value: " << value_name
+ LOG(ERROR) << "Failed to delete registry value: "
+ << (value_name ? value_name : L"(Default)")
<< " error: " << result;
delete_result = DELETE_FAILED;
}
diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h
index e10025c..5120cce 100644
--- a/chrome/installer/util/install_util.h
+++ b/chrome/installer/util/install_util.h
@@ -130,8 +130,8 @@ class InstallUtil {
// Deletes the key |key_to_delete_path| under |root_key| iff the value
// |value_name| in the key |key_to_test_path| under |root_key| satisfies
- // |predicate|. |value_name| must be an empty string to test the key's
- // default value.
+ // |predicate|. |value_name| may be either NULL or an empty string to test
+ // the key's default value.
static ConditionalDeleteResult DeleteRegistryKeyIf(
HKEY root_key,
const string16& key_to_delete_path,
@@ -140,8 +140,8 @@ class InstallUtil {
const RegistryValuePredicate& predicate);
// Deletes the value |value_name| in the key |key_path| under |root_key| iff
- // its current value satisfies |predicate|. |value_name| must be an empty
- // string to test the key's default value.
+ // its current value satisfies |predicate|. |value_name| may be either NULL
+ // or an empty string to test/delete the key's default value.
static ConditionalDeleteResult DeleteRegistryValueIf(
HKEY root_key,
const wchar_t* key_path,
diff --git a/chrome/installer/util/install_util_unittest.cc b/chrome/installer/util/install_util_unittest.cc
index 89c870d..5d86b2b 100644
--- a/chrome/installer/util/install_util_unittest.cc
+++ b/chrome/installer/util/install_util_unittest.cc
@@ -258,6 +258,22 @@ TEST_F(InstallUtilTest, DeleteRegistryKeyIf) {
EXPECT_FALSE(RegKey(root, parent_key_path.c_str(),
KEY_QUERY_VALUE).Valid());
}
+
+ // Default value exists and matches: delete.
+ {
+ MockRegistryValuePredicate pred;
+
+ EXPECT_CALL(pred, Evaluate(StrEq(value))).WillOnce(Return(true));
+ ASSERT_EQ(ERROR_SUCCESS,
+ RegKey(root, child_key_path.c_str(),
+ KEY_SET_VALUE).WriteValue(NULL, value));
+ EXPECT_EQ(InstallUtil::DELETED,
+ InstallUtil::DeleteRegistryKeyIf(root, parent_key_path,
+ child_key_path, NULL,
+ pred));
+ EXPECT_FALSE(RegKey(root, parent_key_path.c_str(),
+ KEY_QUERY_VALUE).Valid());
+ }
}
}
@@ -330,7 +346,7 @@ TEST_F(InstallUtilTest, DeleteRegistryValueIf) {
{
RegistryOverrideManager override_manager;
override_manager.OverrideRegistry(root, L"root_key");
- // Default value matches: delete.
+ // Default value matches: delete using empty string.
{
MockRegistryValuePredicate pred;
@@ -346,6 +362,26 @@ TEST_F(InstallUtilTest, DeleteRegistryValueIf) {
KEY_QUERY_VALUE).HasValue(L""));
}
}
+
+ {
+ RegistryOverrideManager override_manager;
+ override_manager.OverrideRegistry(root, L"root_key");
+ // Default value matches: delete using NULL.
+ {
+ MockRegistryValuePredicate pred;
+
+ EXPECT_CALL(pred, Evaluate(StrEq(value))).WillOnce(Return(true));
+ ASSERT_EQ(ERROR_SUCCESS,
+ RegKey(root, key_path.c_str(),
+ KEY_SET_VALUE).WriteValue(L"", value));
+ EXPECT_EQ(InstallUtil::DELETED,
+ InstallUtil::DeleteRegistryValueIf(root, key_path.c_str(),
+ NULL, pred));
+ EXPECT_TRUE(RegKey(root, key_path.c_str(), KEY_QUERY_VALUE).Valid());
+ EXPECT_FALSE(RegKey(root, key_path.c_str(),
+ KEY_QUERY_VALUE).HasValue(L""));
+ }
+ }
}
TEST_F(InstallUtilTest, ValueEquals) {