Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1339)

Side by Side Diff: chrome/installer/setup/uninstall.cc

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 base::FilePath setup_exe_base_name(installer::kSetupExe); 263 base::FilePath setup_exe_base_name(installer::kSetupExe);
264 264
265 while (true) { 265 while (true) {
266 base::FilePath to_delete(file_enumerator.Next()); 266 base::FilePath to_delete(file_enumerator.Next());
267 if (to_delete.empty()) 267 if (to_delete.empty())
268 break; 268 break;
269 if (!remove_setup && to_delete.BaseName() == setup_exe_base_name) 269 if (!remove_setup && to_delete.BaseName() == setup_exe_base_name)
270 continue; 270 continue;
271 271
272 VLOG(1) << "Deleting installer path " << to_delete.value(); 272 VLOG(1) << "Deleting installer path " << to_delete.value();
273 if (!file_util::Delete(to_delete, true)) { 273 if (!base::Delete(to_delete, true)) {
274 LOG(ERROR) << "Failed to delete path: " << to_delete.value(); 274 LOG(ERROR) << "Failed to delete path: " << to_delete.value();
275 success = false; 275 success = false;
276 } 276 }
277 } 277 }
278 278
279 return success; 279 return success;
280 } 280 }
281 281
282 } // namespace 282 } // namespace
283 283
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 DELETE_REQUIRES_REBOOT, 395 DELETE_REQUIRES_REBOOT,
396 }; 396 };
397 397
398 // Deletes the given directory if it is empty. Returns DELETE_SUCCEEDED if the 398 // Deletes the given directory if it is empty. Returns DELETE_SUCCEEDED if the
399 // directory is deleted, DELETE_NOT_EMPTY if it is not empty, and DELETE_FAILED 399 // directory is deleted, DELETE_NOT_EMPTY if it is not empty, and DELETE_FAILED
400 // otherwise. 400 // otherwise.
401 DeleteResult DeleteEmptyDir(const base::FilePath& path) { 401 DeleteResult DeleteEmptyDir(const base::FilePath& path) {
402 if (!file_util::IsDirectoryEmpty(path)) 402 if (!file_util::IsDirectoryEmpty(path))
403 return DELETE_NOT_EMPTY; 403 return DELETE_NOT_EMPTY;
404 404
405 if (file_util::Delete(path, true)) 405 if (base::Delete(path, true))
406 return DELETE_SUCCEEDED; 406 return DELETE_SUCCEEDED;
407 407
408 LOG(ERROR) << "Failed to delete folder: " << path.value(); 408 LOG(ERROR) << "Failed to delete folder: " << path.value();
409 return DELETE_FAILED; 409 return DELETE_FAILED;
410 } 410 }
411 411
412 void GetLocalStateFolders(const Product& product, 412 void GetLocalStateFolders(const Product& product,
413 std::vector<base::FilePath>* paths) { 413 std::vector<base::FilePath>* paths) {
414 // Obtain the location of the user profile data. 414 // Obtain the location of the user profile data.
415 product.GetUserDataPaths(paths); 415 product.GetUserDataPaths(paths);
(...skipping 26 matching lines...) Expand all
442 DeleteResult DeleteLocalState( 442 DeleteResult DeleteLocalState(
443 const std::vector<base::FilePath>& local_state_folders, 443 const std::vector<base::FilePath>& local_state_folders,
444 bool schedule_on_failure) { 444 bool schedule_on_failure) {
445 if (local_state_folders.empty()) 445 if (local_state_folders.empty())
446 return DELETE_SUCCEEDED; 446 return DELETE_SUCCEEDED;
447 447
448 DeleteResult result = DELETE_SUCCEEDED; 448 DeleteResult result = DELETE_SUCCEEDED;
449 for (size_t i = 0; i < local_state_folders.size(); ++i) { 449 for (size_t i = 0; i < local_state_folders.size(); ++i) {
450 const base::FilePath& user_local_state = local_state_folders[i]; 450 const base::FilePath& user_local_state = local_state_folders[i];
451 VLOG(1) << "Deleting user profile " << user_local_state.value(); 451 VLOG(1) << "Deleting user profile " << user_local_state.value();
452 if (!file_util::Delete(user_local_state, true)) { 452 if (!base::Delete(user_local_state, true)) {
453 LOG(ERROR) << "Failed to delete user profile dir: " 453 LOG(ERROR) << "Failed to delete user profile dir: "
454 << user_local_state.value(); 454 << user_local_state.value();
455 if (schedule_on_failure) { 455 if (schedule_on_failure) {
456 ScheduleDirectoryForDeletion(user_local_state.value().c_str()); 456 ScheduleDirectoryForDeletion(user_local_state.value().c_str());
457 result = DELETE_REQUIRES_REBOOT; 457 result = DELETE_REQUIRES_REBOOT;
458 } else { 458 } else {
459 result = DELETE_FAILED; 459 result = DELETE_FAILED;
460 } 460 }
461 } 461 }
462 } 462 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 LOG(ERROR) << "DeleteAppHostFilesAndFolders: no installation destination " 536 LOG(ERROR) << "DeleteAppHostFilesAndFolders: no installation destination "
537 << "path."; 537 << "path.";
538 return DELETE_FAILED; // Nothing else we can do to uninstall, so we return. 538 return DELETE_FAILED; // Nothing else we can do to uninstall, so we return.
539 } 539 }
540 540
541 DeleteInstallTempDir(target_path); 541 DeleteInstallTempDir(target_path);
542 542
543 DeleteResult result = DELETE_SUCCEEDED; 543 DeleteResult result = DELETE_SUCCEEDED;
544 544
545 base::FilePath app_host_exe(target_path.Append(installer::kChromeAppHostExe)); 545 base::FilePath app_host_exe(target_path.Append(installer::kChromeAppHostExe));
546 if (!file_util::Delete(app_host_exe, false)) { 546 if (!base::Delete(app_host_exe, false)) {
547 result = DELETE_FAILED; 547 result = DELETE_FAILED;
548 LOG(ERROR) << "Failed to delete path: " << app_host_exe.value(); 548 LOG(ERROR) << "Failed to delete path: " << app_host_exe.value();
549 } 549 }
550 550
551 return result; 551 return result;
552 } 552 }
553 553
554 DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, 554 DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state,
555 const base::FilePath& setup_exe) { 555 const base::FilePath& setup_exe) {
556 const base::FilePath& target_path = installer_state.target_path(); 556 const base::FilePath& target_path = installer_state.target_path();
(...skipping 25 matching lines...) Expand all
582 if (to_delete.BaseName().value() == installer::kChromeAppHostExe) 582 if (to_delete.BaseName().value() == installer::kChromeAppHostExe)
583 continue; 583 continue;
584 if (!installer_directory.empty() && 584 if (!installer_directory.empty() &&
585 (to_delete == installer_directory || 585 (to_delete == installer_directory ||
586 installer_directory.IsParent(to_delete) || 586 installer_directory.IsParent(to_delete) ||
587 to_delete.IsParent(installer_directory))) { 587 to_delete.IsParent(installer_directory))) {
588 continue; 588 continue;
589 } 589 }
590 590
591 VLOG(1) << "Deleting install path " << to_delete.value(); 591 VLOG(1) << "Deleting install path " << to_delete.value();
592 if (!file_util::Delete(to_delete, true)) { 592 if (!base::Delete(to_delete, true)) {
593 LOG(ERROR) << "Failed to delete path (1st try): " << to_delete.value(); 593 LOG(ERROR) << "Failed to delete path (1st try): " << to_delete.value();
594 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { 594 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) {
595 // We don't try killing Chrome processes for Chrome Frame builds since 595 // We don't try killing Chrome processes for Chrome Frame builds since
596 // that is unlikely to help. Instead, schedule files for deletion and 596 // that is unlikely to help. Instead, schedule files for deletion and
597 // return a value that will trigger a reboot prompt. 597 // return a value that will trigger a reboot prompt.
598 base::FileEnumerator::FileInfo find_info = file_enumerator.GetInfo(); 598 base::FileEnumerator::FileInfo find_info = file_enumerator.GetInfo();
599 if (find_info.IsDirectory()) 599 if (find_info.IsDirectory())
600 ScheduleDirectoryForDeletion(to_delete.value().c_str()); 600 ScheduleDirectoryForDeletion(to_delete.value().c_str());
601 else 601 else
602 ScheduleFileSystemEntityForDeletion(to_delete.value().c_str()); 602 ScheduleFileSystemEntityForDeletion(to_delete.value().c_str());
603 result = DELETE_REQUIRES_REBOOT; 603 result = DELETE_REQUIRES_REBOOT;
604 } else { 604 } else {
605 // Try closing any running Chrome processes and deleting files once 605 // Try closing any running Chrome processes and deleting files once
606 // again. 606 // again.
607 CloseAllChromeProcesses(); 607 CloseAllChromeProcesses();
608 if (!file_util::Delete(to_delete, true)) { 608 if (!base::Delete(to_delete, true)) {
609 LOG(ERROR) << "Failed to delete path (2nd try): " 609 LOG(ERROR) << "Failed to delete path (2nd try): "
610 << to_delete.value(); 610 << to_delete.value();
611 result = DELETE_FAILED; 611 result = DELETE_FAILED;
612 break; 612 break;
613 } 613 }
614 } 614 }
615 } 615 }
616 } 616 }
617 617
618 return result; 618 return result;
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 1344
1345 if (!force_uninstall) { 1345 if (!force_uninstall) {
1346 VLOG(1) << "Uninstallation complete. Launching post-uninstall operations."; 1346 VLOG(1) << "Uninstallation complete. Launching post-uninstall operations.";
1347 browser_dist->DoPostUninstallOperations(product_state->version(), 1347 browser_dist->DoPostUninstallOperations(product_state->version(),
1348 backup_state_file, distribution_data); 1348 backup_state_file, distribution_data);
1349 } 1349 }
1350 1350
1351 // Try and delete the preserved local state once the post-install 1351 // Try and delete the preserved local state once the post-install
1352 // operations are complete. 1352 // operations are complete.
1353 if (!backup_state_file.empty()) 1353 if (!backup_state_file.empty())
1354 file_util::Delete(backup_state_file, false); 1354 base::Delete(backup_state_file, false);
1355 1355
1356 return ret; 1356 return ret;
1357 } 1357 }
1358 1358
1359 void CleanUpInstallationDirectoryAfterUninstall( 1359 void CleanUpInstallationDirectoryAfterUninstall(
1360 const InstallationState& original_state, 1360 const InstallationState& original_state,
1361 const InstallerState& installer_state, 1361 const InstallerState& installer_state,
1362 const CommandLine& cmd_line, 1362 const CommandLine& cmd_line,
1363 installer::InstallStatus* uninstall_status) { 1363 installer::InstallStatus* uninstall_status) {
1364 if (*uninstall_status != installer::UNINSTALL_SUCCESSFUL && 1364 if (*uninstall_status != installer::UNINSTALL_SUCCESSFUL &&
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 // deletion unconditionally. If they are not empty, the session manager 1426 // deletion unconditionally. If they are not empty, the session manager
1427 // will not delete them on reboot. 1427 // will not delete them on reboot.
1428 ScheduleParentAndGrandparentForDeletion(target_path); 1428 ScheduleParentAndGrandparentForDeletion(target_path);
1429 } else if (DeleteApplicationProductAndVendorDirectories(target_path) == 1429 } else if (DeleteApplicationProductAndVendorDirectories(target_path) ==
1430 installer::DELETE_FAILED) { 1430 installer::DELETE_FAILED) {
1431 *uninstall_status = installer::UNINSTALL_FAILED; 1431 *uninstall_status = installer::UNINSTALL_FAILED;
1432 } 1432 }
1433 } 1433 }
1434 1434
1435 } // namespace installer 1435 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/setup/setup_util_unittest.cc ('k') | chrome/installer/test/alternate_version_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698