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

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

Issue 2110021: Use FilePath::DirName instead of the deprecated file_util::GetDirectoryFromPath. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: fix win Created 10 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
« no previous file with comments | « chrome/browser/web_applications/web_app.cc ('k') | webkit/default_plugin/plugin_impl_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/registry.h" 11 #include "base/registry.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ret = ScheduleFileSystemEntityForDeletion(grandparent_dir.value().c_str()); 132 ret = ScheduleFileSystemEntityForDeletion(grandparent_dir.value().c_str());
133 if (!ret) { 133 if (!ret) {
134 LOG(ERROR) << "Failed to schedule grandparent dir for deletion: " 134 LOG(ERROR) << "Failed to schedule grandparent dir for deletion: "
135 << grandparent_dir.value(); 135 << grandparent_dir.value();
136 } 136 }
137 } 137 }
138 return ret; 138 return ret;
139 } 139 }
140 140
141 // Deletes empty parent & empty grandparent dir of given path. 141 // Deletes empty parent & empty grandparent dir of given path.
142 bool DeleteEmptyParentDir(const std::wstring& path) { 142 bool DeleteEmptyParentDir(const FilePath& path) {
143 bool ret = true; 143 bool ret = true;
144 std::wstring parent_dir = file_util::GetDirectoryFromPath(path); 144 FilePath parent_dir = path.DirName();
145 if (!parent_dir.empty() && file_util::IsDirectoryEmpty(parent_dir)) { 145 if (!parent_dir.empty() && file_util::IsDirectoryEmpty(parent_dir.value())) {
146 if (!file_util::Delete(parent_dir, true)) { 146 if (!file_util::Delete(parent_dir, true)) {
147 ret = false; 147 ret = false;
148 LOG(ERROR) << "Failed to delete folder: " << parent_dir; 148 LOG(ERROR) << "Failed to delete folder: " << parent_dir.value();
149 } 149 }
150 150
151 parent_dir = file_util::GetDirectoryFromPath(parent_dir); 151 parent_dir = parent_dir.DirName();
152 if (!parent_dir.empty() && file_util::IsDirectoryEmpty(parent_dir)) { 152 if (!parent_dir.empty() &&
153 file_util::IsDirectoryEmpty(parent_dir.value())) {
tony 2010/05/24 03:32:29 Nit: It would be good to make a FilePath version o
153 if (!file_util::Delete(parent_dir, true)) { 154 if (!file_util::Delete(parent_dir, true)) {
154 ret = false; 155 ret = false;
155 LOG(ERROR) << "Failed to delete folder: " << parent_dir; 156 LOG(ERROR) << "Failed to delete folder: " << parent_dir.value();
156 } 157 }
157 } 158 }
158 } 159 }
159 return ret; 160 return ret;
160 } 161 }
161 162
162 enum DeleteResult { 163 enum DeleteResult {
163 DELETE_SUCCEEDED, 164 DELETE_SUCCEEDED,
164 DELETE_FAILED, 165 DELETE_FAILED,
165 DELETE_REQUIRES_REBOOT 166 DELETE_REQUIRES_REBOOT
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if (InstallUtil::IsChromeFrameProcess()) { 251 if (InstallUtil::IsChromeFrameProcess()) {
251 ScheduleDirectoryForDeletion(user_local_state.value().c_str()); 252 ScheduleDirectoryForDeletion(user_local_state.value().c_str());
252 result = DELETE_REQUIRES_REBOOT; 253 result = DELETE_REQUIRES_REBOOT;
253 } else { 254 } else {
254 result = DELETE_FAILED; 255 result = DELETE_FAILED;
255 } 256 }
256 } 257 }
257 if (result == DELETE_REQUIRES_REBOOT) { 258 if (result == DELETE_REQUIRES_REBOOT) {
258 ScheduleParentAndGrandparentForDeletion(user_local_state); 259 ScheduleParentAndGrandparentForDeletion(user_local_state);
259 } else { 260 } else {
260 DeleteEmptyParentDir(user_local_state.value()); 261 DeleteEmptyParentDir(user_local_state);
261 } 262 }
262 } 263 }
263 264
264 if (result == DELETE_REQUIRES_REBOOT) { 265 if (result == DELETE_REQUIRES_REBOOT) {
265 // If we need a reboot to continue, schedule the parent directories for 266 // If we need a reboot to continue, schedule the parent directories for
266 // deletion unconditionally. If they are not empty, the session manager 267 // deletion unconditionally. If they are not empty, the session manager
267 // will not delete them on reboot. 268 // will not delete them on reboot.
268 ScheduleParentAndGrandparentForDeletion(FilePath(install_path)); 269 ScheduleParentAndGrandparentForDeletion(FilePath(install_path));
269 } else { 270 } else {
270 // Now check and delete if the parent directories are empty 271 // Now check and delete if the parent directories are empty
271 // For example Google\Chrome or Chromium 272 // For example Google\Chrome or Chromium
272 DeleteEmptyParentDir(install_path); 273 DeleteEmptyParentDir(FilePath(install_path));
273 } 274 }
274 return result; 275 return result;
275 } 276 }
276 277
277 // This method tries to delete a registry key and logs an error message 278 // This method tries to delete a registry key and logs an error message
278 // in case of failure. It returns true if deletion is successful, 279 // in case of failure. It returns true if deletion is successful,
279 // otherwise false. 280 // otherwise false.
280 bool DeleteRegistryKey(RegKey& key, const std::wstring& key_path) { 281 bool DeleteRegistryKey(RegKey& key, const std::wstring& key_path) {
281 LOG(INFO) << "Deleting registry key " << key_path; 282 LOG(INFO) << "Deleting registry key " << key_path;
282 if (!key.DeleteKey(key_path.c_str()) && 283 if (!key.DeleteKey(key_path.c_str()) &&
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 distribution_data); 590 distribution_data);
590 } 591 }
591 592
592 // Try and delete the preserved local state once the post-install 593 // Try and delete the preserved local state once the post-install
593 // operations are complete. 594 // operations are complete.
594 if (!local_state_path.empty()) 595 if (!local_state_path.empty())
595 file_util::Delete(local_state_path, false); 596 file_util::Delete(local_state_path, false);
596 597
597 return ret; 598 return ret;
598 } 599 }
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app.cc ('k') | webkit/default_plugin/plugin_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698