Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3952)

Unified Diff: chrome/installer/util/install_util.cc

Issue 10451074: Always suffix ChromeHTML entries on Windows for user-level installs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstallUtil::DeleteRegistryValue Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/browser_distribution.h ('k') | chrome/installer/util/shell_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/install_util.cc
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index 5f4e2386282c85d44c43f4c0940a950a4e99d4b7..63bba526b72f35532185190f3279bac0594969ac 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -360,8 +360,8 @@ bool InstallUtil::HasDelegateExecuteHandler(BrowserDistribution* dist,
}
// This method tries to delete a registry key and logs an error message
-// in case of failure. It returns true if deletion is successful,
-// otherwise false.
+// in case of failure. It returns true if deletion is successful (or the key did
+// not exist), otherwise false.
bool InstallUtil::DeleteRegistryKey(HKEY root_key,
const std::wstring& key_path) {
VLOG(1) << "Deleting registry key " << key_path;
@@ -375,11 +375,18 @@ bool InstallUtil::DeleteRegistryKey(HKEY root_key,
}
// This method tries to delete a registry value and logs an error message
-// in case of failure. It returns true if deletion is successful,
-// otherwise false.
+// in case of failure. It returns true if deletion is successful (or the key did
+// not exist), otherwise false.
bool InstallUtil::DeleteRegistryValue(HKEY reg_root,
const std::wstring& key_path,
const std::wstring& value_name) {
+ // Return true immediately if the key doesn't exist (otherwise, creating a key
+ // with KEY_ALL_ACCESS in the next step creates the key and all its parents if
+ // they don't exist, in which case new parents are left behind post-deletion).
+ RegKey key_read_only(reg_root, key_path.c_str(), KEY_QUERY_VALUE);
+ if (!key_read_only.Valid())
+ return true;
+
RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS);
gab 2012/05/30 20:08:39 This step was causing RemoveBadWindows8Registratio
grt (UTC plus 2) 2012/05/30 20:37:40 Please use something along the lines of: RegKey k
gab 2012/06/01 00:16:01 Done.
VLOG(1) << "Deleting registry value " << value_name;
if (key.HasValue(value_name.c_str())) {
« no previous file with comments | « chrome/installer/util/browser_distribution.h ('k') | chrome/installer/util/shell_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698