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

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

Issue 14824006: Revert 198820 "Move FileEnumerator to its own file, do some refa..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/files/file_enumerator.h"
15 #include "base/path_service.h" 14 #include "base/path_service.h"
16 #include "base/process_util.h" 15 #include "base/process_util.h"
17 #include "base/string16.h" 16 #include "base/string16.h"
18 #include "base/string_util.h" 17 #include "base/string_util.h"
19 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
20 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
21 #include "base/win/registry.h" 20 #include "base/win/registry.h"
22 #include "base/win/scoped_handle.h" 21 #include "base/win/scoped_handle.h"
23 #include "base/win/shortcut.h" 22 #include "base/win/shortcut.h"
24 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (remove_setup) 245 if (remove_setup)
247 VLOG(1) << "Removing setup.exe."; 246 VLOG(1) << "Removing setup.exe.";
248 } 247 }
249 } 248 }
250 249
251 // Removes all files from the installer directory, leaving setup.exe iff 250 // Removes all files from the installer directory, leaving setup.exe iff
252 // |remove_setup| is false. 251 // |remove_setup| is false.
253 // Returns false in case of an error. 252 // Returns false in case of an error.
254 bool RemoveInstallerFiles(const base::FilePath& installer_directory, 253 bool RemoveInstallerFiles(const base::FilePath& installer_directory,
255 bool remove_setup) { 254 bool remove_setup) {
256 base::FileEnumerator file_enumerator( 255 using file_util::FileEnumerator;
256 FileEnumerator file_enumerator(
257 installer_directory, 257 installer_directory,
258 false, 258 false,
259 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); 259 FileEnumerator::FILES | FileEnumerator::DIRECTORIES);
260 bool success = true; 260 bool success = true;
261 261
262 base::FilePath setup_exe_base_name(installer::kSetupExe); 262 base::FilePath setup_exe_base_name(installer::kSetupExe);
263 263
264 while (true) { 264 while (true) {
265 base::FilePath to_delete(file_enumerator.Next()); 265 base::FilePath to_delete(file_enumerator.Next());
266 if (to_delete.empty()) 266 if (to_delete.empty())
267 break; 267 break;
268 if (!remove_setup && to_delete.BaseName() == setup_exe_base_name) 268 if (!remove_setup && to_delete.BaseName() == setup_exe_base_name)
269 continue; 269 continue;
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 565
566 base::FilePath installer_directory; 566 base::FilePath installer_directory;
567 if (target_path.IsParent(setup_exe)) 567 if (target_path.IsParent(setup_exe))
568 installer_directory = setup_exe.DirName(); 568 installer_directory = setup_exe.DirName();
569 569
570 // Enumerate all the files in target_path recursively (breadth-first). 570 // Enumerate all the files in target_path recursively (breadth-first).
571 // We delete a file or folder unless it is a parent/child of the installer 571 // We delete a file or folder unless it is a parent/child of the installer
572 // directory. For parents of the installer directory, we will later recurse 572 // directory. For parents of the installer directory, we will later recurse
573 // and delete all the children (that are not also parents/children of the 573 // and delete all the children (that are not also parents/children of the
574 // installer directory). 574 // installer directory).
575 base::FileEnumerator file_enumerator(target_path, true, 575 using file_util::FileEnumerator;
576 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); 576 FileEnumerator file_enumerator(
577 target_path, true, FileEnumerator::FILES | FileEnumerator::DIRECTORIES);
577 while (true) { 578 while (true) {
578 base::FilePath to_delete(file_enumerator.Next()); 579 base::FilePath to_delete(file_enumerator.Next());
579 if (to_delete.empty()) 580 if (to_delete.empty())
580 break; 581 break;
581 if (to_delete.BaseName().value() == installer::kChromeAppHostExe) 582 if (to_delete.BaseName().value() == installer::kChromeAppHostExe)
582 continue; 583 continue;
583 if (!installer_directory.empty() && 584 if (!installer_directory.empty() &&
584 (to_delete == installer_directory || 585 (to_delete == installer_directory ||
585 installer_directory.IsParent(to_delete) || 586 installer_directory.IsParent(to_delete) ||
586 to_delete.IsParent(installer_directory))) { 587 to_delete.IsParent(installer_directory))) {
587 continue; 588 continue;
588 } 589 }
589 590
590 VLOG(1) << "Deleting install path " << to_delete.value(); 591 VLOG(1) << "Deleting install path " << to_delete.value();
591 if (!file_util::Delete(to_delete, true)) { 592 if (!file_util::Delete(to_delete, true)) {
592 LOG(ERROR) << "Failed to delete path (1st try): " << to_delete.value(); 593 LOG(ERROR) << "Failed to delete path (1st try): " << to_delete.value();
593 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { 594 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) {
594 // 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
595 // that is unlikely to help. Instead, schedule files for deletion and 596 // that is unlikely to help. Instead, schedule files for deletion and
596 // return a value that will trigger a reboot prompt. 597 // return a value that will trigger a reboot prompt.
597 base::FileEnumerator::FileInfo find_info = file_enumerator.GetInfo(); 598 FileEnumerator::FindInfo find_info;
598 if (find_info.IsDirectory()) 599 file_enumerator.GetFindInfo(&find_info);
600 if (FileEnumerator::IsDirectory(find_info))
599 ScheduleDirectoryForDeletion(to_delete.value().c_str()); 601 ScheduleDirectoryForDeletion(to_delete.value().c_str());
600 else 602 else
601 ScheduleFileSystemEntityForDeletion(to_delete.value().c_str()); 603 ScheduleFileSystemEntityForDeletion(to_delete.value().c_str());
602 result = DELETE_REQUIRES_REBOOT; 604 result = DELETE_REQUIRES_REBOOT;
603 } else { 605 } else {
604 // Try closing any running Chrome processes and deleting files once 606 // Try closing any running Chrome processes and deleting files once
605 // again. 607 // again.
606 CloseAllChromeProcesses(); 608 CloseAllChromeProcesses();
607 if (!file_util::Delete(to_delete, true)) { 609 if (!file_util::Delete(to_delete, true)) {
608 LOG(ERROR) << "Failed to delete path (2nd try): " 610 LOG(ERROR) << "Failed to delete path (2nd try): "
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 // deletion unconditionally. If they are not empty, the session manager 1409 // deletion unconditionally. If they are not empty, the session manager
1408 // will not delete them on reboot. 1410 // will not delete them on reboot.
1409 ScheduleParentAndGrandparentForDeletion(target_path); 1411 ScheduleParentAndGrandparentForDeletion(target_path);
1410 } else if (DeleteApplicationProductAndVendorDirectories(target_path) == 1412 } else if (DeleteApplicationProductAndVendorDirectories(target_path) ==
1411 installer::DELETE_FAILED) { 1413 installer::DELETE_FAILED) {
1412 *uninstall_status = installer::UNINSTALL_FAILED; 1414 *uninstall_status = installer::UNINSTALL_FAILED;
1413 } 1415 }
1414 } 1416 }
1415 1417
1416 } // namespace installer 1418 } // namespace installer
OLDNEW
« no previous file with comments | « trunk/src/chrome/installer/setup/setup_util.cc ('k') | trunk/src/chrome/installer/test/alternate_version_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698