OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 if (!file_util::CreateTemporaryFile(&temp_file)) { | 172 if (!file_util::CreateTemporaryFile(&temp_file)) { |
173 LOG(ERROR) << "Failed to create temporary file for setup.exe."; | 173 LOG(ERROR) << "Failed to create temporary file for setup.exe."; |
174 } else { | 174 } else { |
175 FilePath setup_exe_path = FilePath::FromWStringHack(setup_exe); | 175 FilePath setup_exe_path = FilePath::FromWStringHack(setup_exe); |
176 file_util::Move(setup_exe_path, temp_file); | 176 file_util::Move(setup_exe_path, temp_file); |
177 } | 177 } |
178 | 178 |
179 // Obtain the location of the user profile data. Chrome Frame needs to | 179 // Obtain the location of the user profile data. Chrome Frame needs to |
180 // build this path manually since it doesn't use the Chrome default dir. | 180 // build this path manually since it doesn't use the Chrome default dir. |
181 FilePath user_local_state; | 181 FilePath user_local_state; |
182 #if defined(CHROME_FRAME_BUILD) | 182 bool got_local_state = false; |
183 bool got_local_state = | 183 if (InstallUtil::IsChromeFrameProcess()) { |
184 chrome::GetChromeFrameUserDataDirectory(&user_local_state); | 184 got_local_state = |
185 #else // if !defined(CHROME_FRAME_BUILD) | 185 chrome::GetChromeFrameUserDataDirectory(&user_local_state); |
186 bool got_local_state = chrome::GetDefaultUserDataDirectory(&user_local_state); | 186 } else { |
187 #endif | 187 got_local_state = chrome::GetDefaultUserDataDirectory(&user_local_state); |
| 188 } |
188 | 189 |
189 // Move the browser's persisted local state | 190 // Move the browser's persisted local state |
190 if (got_local_state) { | 191 if (got_local_state) { |
191 FilePath user_local_file( | 192 FilePath user_local_file( |
192 user_local_state.Append(chrome::kLocalStateFilename)); | 193 user_local_state.Append(chrome::kLocalStateFilename)); |
193 FilePath path = FilePath::FromWStringHack(*local_state_path); | 194 FilePath path = FilePath::FromWStringHack(*local_state_path); |
194 if (!file_util::CreateTemporaryFile(&path)) | 195 if (!file_util::CreateTemporaryFile(&path)) |
195 LOG(ERROR) << "Failed to create temporary file for Local State."; | 196 LOG(ERROR) << "Failed to create temporary file for Local State."; |
196 else | 197 else |
197 file_util::CopyFile(user_local_file, path); | 198 file_util::CopyFile(user_local_file, path); |
198 } else { | 199 } else { |
199 LOG(ERROR) << "Could not retrieve user's profile directory."; | 200 LOG(ERROR) << "Could not retrieve user's profile directory."; |
200 } | 201 } |
201 | 202 |
202 DeleteResult result = DELETE_SUCCEEDED; | 203 DeleteResult result = DELETE_SUCCEEDED; |
203 | 204 |
204 LOG(INFO) << "Deleting install path " << install_path; | 205 LOG(INFO) << "Deleting install path " << install_path; |
205 if (!file_util::Delete(install_path, true)) { | 206 if (!file_util::Delete(install_path, true)) { |
206 LOG(ERROR) << "Failed to delete folder (1st try): " << install_path; | 207 LOG(ERROR) << "Failed to delete folder (1st try): " << install_path; |
207 #if defined(CHROME_FRAME_BUILD) | 208 if (InstallUtil::IsChromeFrameProcess()) { |
208 // We don't try killing Chrome processes for Chrome Frame builds since | 209 // We don't try killing Chrome processes for Chrome Frame builds since |
209 // that is unlikely to help. Instead, schedule files for deletion and | 210 // that is unlikely to help. Instead, schedule files for deletion and |
210 // return a value that will trigger a reboot prompt. | 211 // return a value that will trigger a reboot prompt. |
211 ScheduleDirectoryForDeletion(install_path.c_str()); | 212 ScheduleDirectoryForDeletion(install_path.c_str()); |
212 result = DELETE_REQUIRES_REBOOT; | 213 result = DELETE_REQUIRES_REBOOT; |
213 #else | 214 } else { |
214 // Try closing any running chrome processes and deleting files once again. | 215 // Try closing any running chrome processes and deleting files once again. |
215 CloseAllChromeProcesses(); | 216 CloseAllChromeProcesses(); |
216 if (!file_util::Delete(install_path, true)) { | 217 if (!file_util::Delete(install_path, true)) { |
217 LOG(ERROR) << "Failed to delete folder (2nd try): " << install_path; | 218 LOG(ERROR) << "Failed to delete folder (2nd try): " << install_path; |
218 result = DELETE_FAILED; | 219 result = DELETE_FAILED; |
| 220 } |
219 } | 221 } |
220 #endif | |
221 } | 222 } |
222 | 223 |
223 if (delete_profile && got_local_state) { | 224 if (delete_profile && got_local_state) { |
224 LOG(INFO) << "Deleting user profile" << user_local_state.value(); | 225 LOG(INFO) << "Deleting user profile" << user_local_state.value(); |
225 if (!file_util::Delete(user_local_state, true)) { | 226 if (!file_util::Delete(user_local_state, true)) { |
226 LOG(ERROR) << "Failed to delete user profile dir: " | 227 LOG(ERROR) << "Failed to delete user profile dir: " |
227 << user_local_state.value(); | 228 << user_local_state.value(); |
228 #if defined(CHROME_FRAME_BUILD) | 229 if (InstallUtil::IsChromeFrameProcess()) { |
229 ScheduleDirectoryForDeletion(user_local_state.value().c_str()); | 230 ScheduleDirectoryForDeletion(user_local_state.value().c_str()); |
230 result = DELETE_REQUIRES_REBOOT; | 231 result = DELETE_REQUIRES_REBOOT; |
231 #else | 232 } else { |
232 result = DELETE_FAILED; | 233 result = DELETE_FAILED; |
233 #endif | 234 } |
234 } | 235 } |
235 DeleteEmptyParentDir(user_local_state.value()); | 236 DeleteEmptyParentDir(user_local_state.value()); |
236 } | 237 } |
237 | 238 |
238 // Now check and delete if the parent directories are empty | 239 // Now check and delete if the parent directories are empty |
239 // For example Google\Chrome or Chromium | 240 // For example Google\Chrome or Chromium |
240 DeleteEmptyParentDir(install_path); | 241 DeleteEmptyParentDir(install_path); |
241 return result; | 242 return result; |
242 } | 243 } |
243 | 244 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 bool remove_all, bool force_uninstall, | 401 bool remove_all, bool force_uninstall, |
401 const CommandLine& cmd_line, const wchar_t* cmd_params) { | 402 const CommandLine& cmd_line, const wchar_t* cmd_params) { |
402 installer_util::InstallStatus status = installer_util::UNINSTALL_CONFIRMED; | 403 installer_util::InstallStatus status = installer_util::UNINSTALL_CONFIRMED; |
403 std::wstring suffix; | 404 std::wstring suffix; |
404 if (!ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix)) | 405 if (!ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix)) |
405 suffix = L""; | 406 suffix = L""; |
406 | 407 |
407 if (force_uninstall) { | 408 if (force_uninstall) { |
408 // Since --force-uninstall command line option is used, we are going to | 409 // Since --force-uninstall command line option is used, we are going to |
409 // do silent uninstall. Try to close all running Chrome instances. | 410 // do silent uninstall. Try to close all running Chrome instances. |
410 #if !defined(CHROME_FRAME_BUILD) | 411 if (!InstallUtil::IsChromeFrameProcess()) |
411 CloseAllChromeProcesses(); | 412 CloseAllChromeProcesses(); |
412 #endif | |
413 } else { // no --force-uninstall so lets show some UI dialog boxes. | 413 } else { // no --force-uninstall so lets show some UI dialog boxes. |
414 status = IsChromeActiveOrUserCancelled(system_uninstall); | 414 status = IsChromeActiveOrUserCancelled(system_uninstall); |
415 if (status != installer_util::UNINSTALL_CONFIRMED && | 415 if (status != installer_util::UNINSTALL_CONFIRMED && |
416 status != installer_util::UNINSTALL_DELETE_PROFILE) | 416 status != installer_util::UNINSTALL_DELETE_PROFILE) |
417 return status; | 417 return status; |
418 | 418 |
419 // Check if we need admin rights to cleanup HKLM. If we do, try to launch | 419 // Check if we need admin rights to cleanup HKLM. If we do, try to launch |
420 // another uninstaller (silent) in elevated mode to do HKLM cleanup. | 420 // another uninstaller (silent) in elevated mode to do HKLM cleanup. |
421 // And continue uninstalling in the current process also to do HKCU cleanup. | 421 // And continue uninstalling in the current process also to do HKCU cleanup. |
422 if (remove_all && | 422 if (remove_all && |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 distribution_data); | 525 distribution_data); |
526 } | 526 } |
527 | 527 |
528 // Try and delete the preserved local state once the post-install | 528 // Try and delete the preserved local state once the post-install |
529 // operations are complete. | 529 // operations are complete. |
530 if (!local_state_path.empty()) | 530 if (!local_state_path.empty()) |
531 file_util::Delete(local_state_path, false); | 531 file_util::Delete(local_state_path, false); |
532 | 532 |
533 return ret; | 533 return ret; |
534 } | 534 } |
OLD | NEW |