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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/installer/util/browser_distribution.h ('k') | chrome/installer/util/shell_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // See the corresponding header file for description of the functions in this 5 // See the corresponding header file for description of the functions in this
6 // file. 6 // file.
7 7
8 #include "chrome/installer/util/install_util.h" 8 #include "chrome/installer/util/install_util.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 FilePath handler( 353 FilePath handler(
354 FilePath(chrome_exe).DirName() 354 FilePath(chrome_exe).DirName()
355 .AppendASCII(version->GetString()) 355 .AppendASCII(version->GetString())
356 .Append(installer::kDelegateExecuteExe)); 356 .Append(installer::kDelegateExecuteExe));
357 found = file_util::PathExists(handler); 357 found = file_util::PathExists(handler);
358 } 358 }
359 return found; 359 return found;
360 } 360 }
361 361
362 // This method tries to delete a registry key and logs an error message 362 // This method tries to delete a registry key and logs an error message
363 // in case of failure. It returns true if deletion is successful, 363 // in case of failure. It returns true if deletion is successful (or the key did
364 // otherwise false. 364 // not exist), otherwise false.
365 bool InstallUtil::DeleteRegistryKey(HKEY root_key, 365 bool InstallUtil::DeleteRegistryKey(HKEY root_key,
366 const std::wstring& key_path) { 366 const std::wstring& key_path) {
367 VLOG(1) << "Deleting registry key " << key_path; 367 VLOG(1) << "Deleting registry key " << key_path;
368 LONG result = ::SHDeleteKey(root_key, key_path.c_str()); 368 LONG result = ::SHDeleteKey(root_key, key_path.c_str());
369 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { 369 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) {
370 LOG(ERROR) << "Failed to delete registry key: " << key_path 370 LOG(ERROR) << "Failed to delete registry key: " << key_path
371 << " error: " << result; 371 << " error: " << result;
372 return false; 372 return false;
373 } 373 }
374 return true; 374 return true;
375 } 375 }
376 376
377 // This method tries to delete a registry value and logs an error message 377 // This method tries to delete a registry value and logs an error message
378 // in case of failure. It returns true if deletion is successful, 378 // in case of failure. It returns true if deletion is successful (or the key did
379 // otherwise false. 379 // not exist), otherwise false.
380 bool InstallUtil::DeleteRegistryValue(HKEY reg_root, 380 bool InstallUtil::DeleteRegistryValue(HKEY reg_root,
381 const std::wstring& key_path, 381 const std::wstring& key_path,
382 const std::wstring& value_name) { 382 const std::wstring& value_name) {
383 // Return true immediately if the key doesn't exist (otherwise, creating a key
384 // with KEY_ALL_ACCESS in the next step creates the key and all its parents if
385 // they don't exist, in which case new parents are left behind post-deletion).
386 RegKey key_read_only(reg_root, key_path.c_str(), KEY_QUERY_VALUE);
387 if (!key_read_only.Valid())
388 return true;
389
383 RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS); 390 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.
384 VLOG(1) << "Deleting registry value " << value_name; 391 VLOG(1) << "Deleting registry value " << value_name;
385 if (key.HasValue(value_name.c_str())) { 392 if (key.HasValue(value_name.c_str())) {
386 LONG result = key.DeleteValue(value_name.c_str()); 393 LONG result = key.DeleteValue(value_name.c_str());
387 if (result != ERROR_SUCCESS) { 394 if (result != ERROR_SUCCESS) {
388 LOG(ERROR) << "Failed to delete registry value: " << value_name 395 LOG(ERROR) << "Failed to delete registry value: " << value_name
389 << " error: " << result; 396 << " error: " << result;
390 return false; 397 return false;
391 } 398 }
392 } 399 }
393 return true; 400 return true;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat, 480 int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat,
474 date_str, arraysize(date_str)); 481 date_str, arraysize(date_str));
475 if (len) { 482 if (len) {
476 --len; // Subtract terminating \0. 483 --len; // Subtract terminating \0.
477 } else { 484 } else {
478 PLOG(DFATAL) << "GetDateFormat"; 485 PLOG(DFATAL) << "GetDateFormat";
479 } 486 }
480 487
481 return std::wstring(date_str, len); 488 return std::wstring(date_str, len);
482 } 489 }
OLDNEW
« 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