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 std::string GuidToSquid(const std::string& guid) { | |
grt (UTC plus 2)
2015/09/11 18:14:26
can you get rid of the extra copy by using an outp
bcwhite
2015/09/11 19:24:45
Done.
| |
633 std::string squid = guid.substr(0, 8) + guid.substr(9, 4) + | |
634 guid.substr(14, 4) + guid.substr(19, 4) + guid.substr(24, 12); | |
635 std::string::iterator iter = squid.begin(); | |
636 std::reverse(iter + 0, iter + 8); | |
637 std::reverse(iter + 8, iter + 12); | |
638 std::reverse(iter + 12, iter + 16); | |
639 std::reverse(iter + 16, iter + 18); | |
640 std::reverse(iter + 18, iter + 20); | |
641 std::reverse(iter + 20, iter + 22); | |
642 std::reverse(iter + 22, iter + 24); | |
643 std::reverse(iter + 24, iter + 26); | |
644 std::reverse(iter + 26, iter + 28); | |
645 std::reverse(iter + 28, iter + 30); | |
646 std::reverse(iter + 30, iter + 32); | |
647 return squid; | |
648 } | |
649 | |
632 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) | 650 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) |
633 : is_enabled_(false) { | 651 : is_enabled_(false) { |
634 HANDLE temp_handle; | 652 HANDLE temp_handle; |
635 if (!::OpenProcessToken(::GetCurrentProcess(), | 653 if (!::OpenProcessToken(::GetCurrentProcess(), |
636 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, | 654 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, |
637 &temp_handle)) { | 655 &temp_handle)) { |
638 return; | 656 return; |
639 } | 657 } |
640 token_.Set(temp_handle); | 658 token_.Set(temp_handle); |
641 | 659 |
(...skipping 22 matching lines...) Expand all Loading... | |
664 } | 682 } |
665 | 683 |
666 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 684 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
667 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 685 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
668 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, | 686 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, |
669 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 687 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
670 } | 688 } |
671 } | 689 } |
672 | 690 |
673 } // namespace installer | 691 } // namespace installer |
OLD | NEW |