Chromium Code Reviews| 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 defines the methods useful for uninstalling Chrome. | 5 // This file defines the methods useful for uninstalling Chrome. |
| 6 | 6 |
| 7 #include "chrome/installer/setup/uninstall.h" | 7 #include "chrome/installer/setup/uninstall.h" |
| 8 | 8 |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 | 10 |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 } | 438 } |
| 439 | 439 |
| 440 DeleteInstallTempDir(target_path); | 440 DeleteInstallTempDir(target_path); |
| 441 | 441 |
| 442 DeleteResult result = DELETE_SUCCEEDED; | 442 DeleteResult result = DELETE_SUCCEEDED; |
| 443 | 443 |
| 444 FilePath app_host_exe(target_path.Append(installer::kChromeAppHostExe)); | 444 FilePath app_host_exe(target_path.Append(installer::kChromeAppHostExe)); |
| 445 if (!file_util::Delete(app_host_exe, false)) { | 445 if (!file_util::Delete(app_host_exe, false)) { |
| 446 result = DELETE_FAILED; | 446 result = DELETE_FAILED; |
| 447 LOG(ERROR) << "Failed to delete path: " << app_host_exe.value(); | 447 LOG(ERROR) << "Failed to delete path: " << app_host_exe.value(); |
| 448 } else { | 448 } else if (!target_path.empty() && file_util::IsDirectoryEmpty(target_path)) { |
|
gab
2012/08/08 20:32:59
I don't think target_path.empty() is possible at t
erikwright (departed)
2012/08/09 14:52:51
It may be empty if both Chrome and App Host were i
| |
| 449 DeleteEmptyParentDir(target_path); | 449 if (!file_util::Delete(target_path, true)) { |
| 450 result = DELETE_FAILED; | |
| 451 LOG(ERROR) << "Failed to delete folder: " << target_path.value(); | |
| 452 } else { | |
| 453 DeleteEmptyParentDir(target_path); | |
| 454 } | |
| 450 } | 455 } |
| 451 | 456 |
| 452 return result; | 457 return result; |
| 453 } | 458 } |
| 454 | 459 |
| 455 DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, | 460 DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, |
| 456 const Version& installed_version) { | 461 const Version& installed_version) { |
| 457 const FilePath& target_path = installer_state.target_path(); | 462 const FilePath& target_path = installer_state.target_path(); |
| 458 if (target_path.empty()) { | 463 if (target_path.empty()) { |
| 459 LOG(ERROR) << "DeleteChromeFilesAndFolders: no installation destination " | 464 LOG(ERROR) << "DeleteChromeFilesAndFolders: no installation destination " |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 471 false, | 476 false, |
| 472 static_cast<FileEnumerator::FileType>(FileEnumerator::FILES | | 477 static_cast<FileEnumerator::FileType>(FileEnumerator::FILES | |
| 473 FileEnumerator::DIRECTORIES)); | 478 FileEnumerator::DIRECTORIES)); |
| 474 while (true) { | 479 while (true) { |
| 475 FilePath to_delete(file_enumerator.Next()); | 480 FilePath to_delete(file_enumerator.Next()); |
| 476 if (to_delete.empty()) | 481 if (to_delete.empty()) |
| 477 break; | 482 break; |
| 478 if (to_delete.BaseName().value() == installer::kChromeAppHostExe) | 483 if (to_delete.BaseName().value() == installer::kChromeAppHostExe) |
| 479 continue; | 484 continue; |
| 480 | 485 |
| 481 VLOG(1) << "Deleting install path " << target_path.value(); | 486 VLOG(1) << "Deleting install path " << to_delete.value(); |
| 482 if (!file_util::Delete(to_delete, true)) { | 487 if (!file_util::Delete(to_delete, true)) { |
| 483 LOG(ERROR) << "Failed to delete path (1st try): " << to_delete.value(); | 488 LOG(ERROR) << "Failed to delete path (1st try): " << to_delete.value(); |
| 484 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { | 489 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { |
| 485 // We don't try killing Chrome processes for Chrome Frame builds since | 490 // We don't try killing Chrome processes for Chrome Frame builds since |
| 486 // that is unlikely to help. Instead, schedule files for deletion and | 491 // that is unlikely to help. Instead, schedule files for deletion and |
| 487 // return a value that will trigger a reboot prompt. | 492 // return a value that will trigger a reboot prompt. |
| 488 FileEnumerator::FindInfo find_info; | 493 FileEnumerator::FindInfo find_info; |
| 489 file_enumerator.GetFindInfo(&find_info); | 494 file_enumerator.GetFindInfo(&find_info); |
| 490 if (FileEnumerator::IsDirectory(find_info)) | 495 if (FileEnumerator::IsDirectory(find_info)) |
| 491 ScheduleDirectoryForDeletion(to_delete.value().c_str()); | 496 ScheduleDirectoryForDeletion(to_delete.value().c_str()); |
| 492 else | 497 else |
| 493 ScheduleFileSystemEntityForDeletion(to_delete.value().c_str()); | 498 ScheduleFileSystemEntityForDeletion(to_delete.value().c_str()); |
| 494 result = DELETE_REQUIRES_REBOOT; | 499 result = DELETE_REQUIRES_REBOOT; |
| 495 } else { | 500 } else { |
| 496 // Try closing any running Chrome processes and deleting files once | 501 // Try closing any running Chrome processes and deleting files once |
| 497 // again. | 502 // again. |
| 498 CloseAllChromeProcesses(); | 503 CloseAllChromeProcesses(); |
| 499 if (!file_util::Delete(to_delete, true)) { | 504 if (!file_util::Delete(to_delete, true)) { |
| 500 LOG(ERROR) << "Failed to delete path (2nd try): " | 505 LOG(ERROR) << "Failed to delete path (2nd try): " |
| 501 << to_delete.value(); | 506 << to_delete.value(); |
| 502 result = DELETE_FAILED; | 507 result = DELETE_FAILED; |
| 503 break; | 508 break; |
| 504 } | 509 } |
| 505 } | 510 } |
| 506 } | 511 } |
| 507 } | 512 } |
| 508 | 513 |
| 509 if (result == DELETE_REQUIRES_REBOOT) { | 514 if (result == DELETE_REQUIRES_REBOOT) { |
| 515 // Delete the Application directory at reboot if empty. | |
|
gab
2012/08/08 20:32:59
This function does not seem to wait for reboot for
erikwright (departed)
2012/08/09 14:52:51
This is the implementation of ScheduleFileSystemEn
gab
2012/08/09 16:07:22
Indeed :), guess I missed that line when reading t
| |
| 516 ScheduleFileSystemEntityForDeletion(target_path.value().c_str()); | |
| 510 // If we need a reboot to continue, schedule the parent directories for | 517 // If we need a reboot to continue, schedule the parent directories for |
|
gab
2012/08/08 20:32:59
nit: add empty line between code and comment
erikwright (departed)
2012/08/09 14:52:51
Done.
| |
| 511 // deletion unconditionally. If they are not empty, the session manager | 518 // deletion unconditionally. If they are not empty, the session manager |
| 512 // will not delete them on reboot. | 519 // will not delete them on reboot. |
| 513 ScheduleParentAndGrandparentForDeletion(target_path); | 520 ScheduleParentAndGrandparentForDeletion(target_path); |
| 514 } else { | 521 } else if (file_util::IsDirectoryEmpty(target_path)) { |
| 515 // Now check and delete if the parent directories are empty | 522 if (!file_util::Delete(target_path, true)) { |
| 516 // For example Google\Chrome or Chromium | 523 result = DELETE_FAILED; |
| 517 DeleteEmptyParentDir(target_path); | 524 LOG(ERROR) << "Failed to delete folder: " << target_path.value(); |
|
gab
2012/08/08 20:32:59
Seems this log message is duplicated all over this
erikwright (departed)
2012/08/09 14:52:51
I thought about it, but it's also used in DeleteLo
| |
| 525 } else { | |
| 526 // Now check and delete if the parent directories are empty | |
| 527 // For example Google\Chrome or Chromium | |
| 528 DeleteEmptyParentDir(target_path); | |
| 529 } | |
| 518 } | 530 } |
| 519 return result; | 531 return result; |
| 520 } | 532 } |
| 521 | 533 |
| 522 // This method checks if Chrome is currently running or if the user has | 534 // This method checks if Chrome is currently running or if the user has |
| 523 // cancelled the uninstall operation by clicking Cancel on the confirmation | 535 // cancelled the uninstall operation by clicking Cancel on the confirmation |
| 524 // box that Chrome pops up. | 536 // box that Chrome pops up. |
| 525 InstallStatus IsChromeActiveOrUserCancelled( | 537 InstallStatus IsChromeActiveOrUserCancelled( |
| 526 const InstallerState& installer_state, | 538 const InstallerState& installer_state, |
| 527 const Product& product) { | 539 const Product& product) { |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1161 | 1173 |
| 1162 // Try and delete the preserved local state once the post-install | 1174 // Try and delete the preserved local state once the post-install |
| 1163 // operations are complete. | 1175 // operations are complete. |
| 1164 if (!backup_state_file.empty()) | 1176 if (!backup_state_file.empty()) |
| 1165 file_util::Delete(backup_state_file, false); | 1177 file_util::Delete(backup_state_file, false); |
| 1166 | 1178 |
| 1167 return ret; | 1179 return ret; |
| 1168 } | 1180 } |
| 1169 | 1181 |
| 1170 } // namespace installer | 1182 } // namespace installer |
| OLD | NEW |