| 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 #include <stddef.h> | 10 #include <stddef.h> |
| 11 | 11 |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <iterator> | 13 #include <iterator> |
| 14 #include <set> | 14 #include <set> |
| 15 #include <string> |
| 15 | 16 |
| 16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 17 #include "base/cpu.h" | 18 #include "base/cpu.h" |
| 18 #include "base/files/file_enumerator.h" | 19 #include "base/files/file_enumerator.h" |
| 19 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
| 20 #include "base/files/file_util.h" | 21 #include "base/files/file_util.h" |
| 21 #include "base/logging.h" | 22 #include "base/logging.h" |
| 22 #include "base/macros.h" | 23 #include "base/macros.h" |
| 23 #include "base/numerics/safe_conversions.h" | 24 #include "base/numerics/safe_conversions.h" |
| 24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 26 #include "base/version.h" | 27 #include "base/version.h" |
| 27 #include "base/win/registry.h" | 28 #include "base/win/registry.h" |
| 28 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
| 29 #include "chrome/installer/setup/setup_constants.h" | 30 #include "chrome/installer/setup/setup_constants.h" |
| 30 #include "chrome/installer/util/app_registration_data.h" | 31 #include "chrome/installer/util/app_registration_data.h" |
| 31 #include "chrome/installer/util/google_update_constants.h" | 32 #include "chrome/installer/util/google_update_constants.h" |
| 32 #include "chrome/installer/util/installation_state.h" | 33 #include "chrome/installer/util/installation_state.h" |
| 33 #include "chrome/installer/util/installer_state.h" | 34 #include "chrome/installer/util/installer_state.h" |
| 35 #include "chrome/installer/util/master_preferences.h" |
| 36 #include "chrome/installer/util/master_preferences_constants.h" |
| 34 #include "chrome/installer/util/util_constants.h" | 37 #include "chrome/installer/util/util_constants.h" |
| 35 #include "courgette/courgette.h" | 38 #include "courgette/courgette.h" |
| 36 #include "courgette/third_party/bsdiff.h" | 39 #include "courgette/third_party/bsdiff.h" |
| 37 #include "third_party/bspatch/mbspatch.h" | 40 #include "third_party/bspatch/mbspatch.h" |
| 38 | 41 |
| 39 namespace installer { | 42 namespace installer { |
| 40 | 43 |
| 41 namespace { | 44 namespace { |
| 42 | 45 |
| 43 // Returns true if product |type| cam be meaningfully installed without the | 46 // Returns true if product |type| cam be meaningfully installed without the |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 std::reverse_copy(input + 21, input + 23, output); | 536 std::reverse_copy(input + 21, input + 23, output); |
| 534 std::reverse_copy(input + 24, input + 26, output); | 537 std::reverse_copy(input + 24, input + 26, output); |
| 535 std::reverse_copy(input + 26, input + 28, output); | 538 std::reverse_copy(input + 26, input + 28, output); |
| 536 std::reverse_copy(input + 28, input + 30, output); | 539 std::reverse_copy(input + 28, input + 30, output); |
| 537 std::reverse_copy(input + 30, input + 32, output); | 540 std::reverse_copy(input + 30, input + 32, output); |
| 538 std::reverse_copy(input + 32, input + 34, output); | 541 std::reverse_copy(input + 32, input + 34, output); |
| 539 std::reverse_copy(input + 34, input + 36, output); | 542 std::reverse_copy(input + 34, input + 36, output); |
| 540 return squid; | 543 return squid; |
| 541 } | 544 } |
| 542 | 545 |
| 546 bool IsDowngradeAllowed(const MasterPreferences& prefs) { |
| 547 bool allow_downgrade = false; |
| 548 return prefs.GetBool(master_preferences::kAllowDowngrade, &allow_downgrade) && |
| 549 allow_downgrade; |
| 550 } |
| 551 |
| 543 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) | 552 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) |
| 544 : is_enabled_(false) { | 553 : is_enabled_(false) { |
| 545 HANDLE temp_handle; | 554 HANDLE temp_handle; |
| 546 if (!::OpenProcessToken(::GetCurrentProcess(), | 555 if (!::OpenProcessToken(::GetCurrentProcess(), |
| 547 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, | 556 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, |
| 548 &temp_handle)) { | 557 &temp_handle)) { |
| 549 return; | 558 return; |
| 550 } | 559 } |
| 551 token_.Set(temp_handle); | 560 token_.Set(temp_handle); |
| 552 | 561 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 575 } | 584 } |
| 576 | 585 |
| 577 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 586 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
| 578 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 587 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
| 579 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, | 588 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, |
| 580 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 589 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
| 581 } | 590 } |
| 582 } | 591 } |
| 583 | 592 |
| 584 } // namespace installer | 593 } // namespace installer |
| OLD | NEW |