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

Side by Side Diff: chrome/installer/setup/setup_util.cc

Issue 90963002: Revert of Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
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 // This file declares util functions for setup project. 5 // This file declares util functions for setup project.
6 6
7 #include "chrome/installer/setup/setup_util.h" 7 #include "chrome/installer/setup/setup_util.h"
8 8
9 #include <windows.h> 9 #include <windows.h>
10 10
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 // The following status values represent failed uninstalls: 445 // The following status values represent failed uninstalls:
446 // 15: CHROME_NOT_INSTALLED 446 // 15: CHROME_NOT_INSTALLED
447 // 20: UNINSTALL_FAILED 447 // 20: UNINSTALL_FAILED
448 // 21: UNINSTALL_CANCELLED 448 // 21: UNINSTALL_CANCELLED
449 return (install_status == UNINSTALL_SUCCESSFUL || 449 return (install_status == UNINSTALL_SUCCESSFUL ||
450 install_status == UNINSTALL_REQUIRES_REBOOT); 450 install_status == UNINSTALL_REQUIRES_REBOOT);
451 } 451 }
452 452
453 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) 453 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name)
454 : is_enabled_(false) { 454 : is_enabled_(false) {
455 HANDLE temp_handle;
456 if (!::OpenProcessToken(::GetCurrentProcess(), 455 if (!::OpenProcessToken(::GetCurrentProcess(),
457 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, 456 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
458 &temp_handle)) { 457 token_.Receive())) {
459 return; 458 return;
460 } 459 }
461 token_.Set(temp_handle);
462 460
463 LUID privilege_luid; 461 LUID privilege_luid;
464 if (!::LookupPrivilegeValue(NULL, privilege_name, &privilege_luid)) { 462 if (!::LookupPrivilegeValue(NULL, privilege_name, &privilege_luid)) {
465 token_.Close(); 463 token_.Close();
466 return; 464 return;
467 } 465 }
468 466
469 // Adjust the token's privileges to enable |privilege_name|. If this privilege 467 // Adjust the token's privileges to enable |privilege_name|. If this privilege
470 // was already enabled, |previous_privileges_|.PrivilegeCount will be set to 0 468 // was already enabled, |previous_privileges_|.PrivilegeCount will be set to 0
471 // and we then know not to disable this privilege upon destruction. 469 // and we then know not to disable this privilege upon destruction.
(...skipping 12 matching lines...) Expand all
484 } 482 }
485 483
486 ScopedTokenPrivilege::~ScopedTokenPrivilege() { 484 ScopedTokenPrivilege::~ScopedTokenPrivilege() {
487 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { 485 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) {
488 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, 486 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_,
489 sizeof(TOKEN_PRIVILEGES), NULL, NULL); 487 sizeof(TOKEN_PRIVILEGES), NULL, NULL);
490 } 488 }
491 } 489 }
492 490
493 } // namespace installer 491 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/browser/first_run/upgrade_util_win.cc ('k') | chrome/installer/setup/setup_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698