| OLD | NEW |
| 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 LOG(ERROR) << "Failed to delete value " << name << " in key " << path; | 622 LOG(ERROR) << "Failed to delete value " << name << " in key " << path; |
| 623 // Skip over this value on subsequent iterations. | 623 // Skip over this value on subsequent iterations. |
| 624 to_skip.insert(name); | 624 to_skip.insert(name); |
| 625 ++index; | 625 ++index; |
| 626 continue; | 626 continue; |
| 627 } | 627 } |
| 628 did_delete = true; | 628 did_delete = true; |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 | 631 |
| 632 base::string16 GuidToSquid(const base::string16& guid) { | |
| 633 base::string16 squid; | |
| 634 squid.reserve(32); | |
| 635 auto input = guid.begin(); | |
| 636 auto output = std::back_inserter(squid); | |
| 637 | |
| 638 // Reverse-copy relevant characters, skipping separators. | |
| 639 std::reverse_copy(input + 0, input + 8, output); | |
| 640 std::reverse_copy(input + 9, input + 13, output); | |
| 641 std::reverse_copy(input + 14, input + 18, output); | |
| 642 std::reverse_copy(input + 19, input + 21, output); | |
| 643 std::reverse_copy(input + 21, input + 23, output); | |
| 644 std::reverse_copy(input + 24, input + 26, output); | |
| 645 std::reverse_copy(input + 26, input + 28, output); | |
| 646 std::reverse_copy(input + 28, input + 30, output); | |
| 647 std::reverse_copy(input + 30, input + 32, output); | |
| 648 std::reverse_copy(input + 32, input + 34, output); | |
| 649 std::reverse_copy(input + 34, input + 36, output); | |
| 650 return squid; | |
| 651 } | |
| 652 | |
| 653 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) | 632 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) |
| 654 : is_enabled_(false) { | 633 : is_enabled_(false) { |
| 655 HANDLE temp_handle; | 634 HANDLE temp_handle; |
| 656 if (!::OpenProcessToken(::GetCurrentProcess(), | 635 if (!::OpenProcessToken(::GetCurrentProcess(), |
| 657 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, | 636 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, |
| 658 &temp_handle)) { | 637 &temp_handle)) { |
| 659 return; | 638 return; |
| 660 } | 639 } |
| 661 token_.Set(temp_handle); | 640 token_.Set(temp_handle); |
| 662 | 641 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 685 } | 664 } |
| 686 | 665 |
| 687 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 666 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
| 688 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 667 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
| 689 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, | 668 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, |
| 690 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 669 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
| 691 } | 670 } |
| 692 } | 671 } |
| 693 | 672 |
| 694 } // namespace installer | 673 } // namespace installer |
| OLD | NEW |