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

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

Issue 71013004: Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix delegate_execute for google_chrome_build 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;
455 if (!::OpenProcessToken(::GetCurrentProcess(), 456 if (!::OpenProcessToken(::GetCurrentProcess(),
456 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, 457 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
457 token_.Receive())) { 458 &temp_handle)) {
458 return; 459 return;
459 } 460 }
461 token_.Set(temp_handle);
460 462
461 LUID privilege_luid; 463 LUID privilege_luid;
462 if (!::LookupPrivilegeValue(NULL, privilege_name, &privilege_luid)) { 464 if (!::LookupPrivilegeValue(NULL, privilege_name, &privilege_luid)) {
463 token_.Close(); 465 token_.Close();
464 return; 466 return;
465 } 467 }
466 468
467 // Adjust the token's privileges to enable |privilege_name|. If this privilege 469 // Adjust the token's privileges to enable |privilege_name|. If this privilege
468 // was already enabled, |previous_privileges_|.PrivilegeCount will be set to 0 470 // was already enabled, |previous_privileges_|.PrivilegeCount will be set to 0
469 // and we then know not to disable this privilege upon destruction. 471 // and we then know not to disable this privilege upon destruction.
(...skipping 12 matching lines...) Expand all
482 } 484 }
483 485
484 ScopedTokenPrivilege::~ScopedTokenPrivilege() { 486 ScopedTokenPrivilege::~ScopedTokenPrivilege() {
485 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { 487 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) {
486 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, 488 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_,
487 sizeof(TOKEN_PRIVILEGES), NULL, NULL); 489 sizeof(TOKEN_PRIVILEGES), NULL, NULL);
488 } 490 }
489 } 491 }
490 492
491 } // namespace installer 493 } // 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