| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 bool WillProductBePresentAfterSetup( | 316 bool WillProductBePresentAfterSetup( |
| 317 const installer::InstallerState& installer_state, | 317 const installer::InstallerState& installer_state, |
| 318 const installer::InstallationState& machine_state, | 318 const installer::InstallationState& machine_state, |
| 319 BrowserDistribution::Type type) { | 319 BrowserDistribution::Type type) { |
| 320 DCHECK(SupportsSingleInstall(type) || installer_state.is_multi_install()); | 320 DCHECK(SupportsSingleInstall(type) || installer_state.is_multi_install()); |
| 321 | 321 |
| 322 const ProductState* product_state = | 322 const ProductState* product_state = |
| 323 machine_state.GetProductState(installer_state.system_install(), type); | 323 machine_state.GetProductState(installer_state.system_install(), type); |
| 324 | 324 |
| 325 // Determine if the product is present prior to the current operation. | 325 // Determine if the product is present prior to the current operation. |
| 326 bool is_present = false; | 326 bool is_present = (product_state != NULL); |
| 327 if (product_state != NULL) { | |
| 328 if (type == BrowserDistribution::CHROME_FRAME) { | |
| 329 is_present = !product_state->uninstall_command().HasSwitch( | |
| 330 switches::kChromeFrameReadyMode); | |
| 331 } else { | |
| 332 is_present = true; | |
| 333 } | |
| 334 } | |
| 335 | |
| 336 bool is_uninstall = installer_state.operation() == InstallerState::UNINSTALL; | 327 bool is_uninstall = installer_state.operation() == InstallerState::UNINSTALL; |
| 337 | 328 |
| 338 // Determine if current operation affects the product. | 329 // Determine if current operation affects the product. |
| 339 bool is_affected = false; | |
| 340 const Product* product = installer_state.FindProduct(type); | 330 const Product* product = installer_state.FindProduct(type); |
| 341 if (product != NULL) { | 331 bool is_affected = (product != NULL); |
| 342 if (type == BrowserDistribution::CHROME_FRAME) { | |
| 343 // If Chrome Frame is being uninstalled, we don't bother to check | |
| 344 // !HasOption(kOptionReadyMode) since CF would not have been installed | |
| 345 // in the first place. If for some odd reason it weren't, we would be | |
| 346 // conservative, and cause false to be retruned since CF should not be | |
| 347 // installed then (so is_uninstall = true and is_affected = true). | |
| 348 is_affected = is_uninstall || !product->HasOption(kOptionReadyMode); | |
| 349 } else { | |
| 350 is_affected = true; | |
| 351 } | |
| 352 } | |
| 353 | 332 |
| 354 // Decide among {(1),(2),(3),(4)}. | 333 // Decide among {(1),(2),(3),(4)}. |
| 355 return is_affected ? !is_uninstall : is_present; | 334 return is_affected ? !is_uninstall : is_present; |
| 356 } | 335 } |
| 357 | 336 |
| 358 bool AdjustProcessPriority() { | 337 bool AdjustProcessPriority() { |
| 359 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 338 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 360 DWORD priority_class = ::GetPriorityClass(::GetCurrentProcess()); | 339 DWORD priority_class = ::GetPriorityClass(::GetCurrentProcess()); |
| 361 if (priority_class == 0) { | 340 if (priority_class == 0) { |
| 362 PLOG(WARNING) << "Failed to get the process's priority class."; | 341 PLOG(WARNING) << "Failed to get the process's priority class."; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 } | 463 } |
| 485 | 464 |
| 486 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 465 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
| 487 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 466 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
| 488 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, | 467 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, |
| 489 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 468 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
| 490 } | 469 } |
| 491 } | 470 } |
| 492 | 471 |
| 493 } // namespace installer | 472 } // namespace installer |
| OLD | NEW |