| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } else { | 236 } else { |
| 237 LOG(ERROR) << "Failed to launch chrome.exe for uninstall confirmation."; | 237 LOG(ERROR) << "Failed to launch chrome.exe for uninstall confirmation."; |
| 238 } | 238 } |
| 239 | 239 |
| 240 return installer_util::UNINSTALL_CONFIRMED; | 240 return installer_util::UNINSTALL_CONFIRMED; |
| 241 } | 241 } |
| 242 } // namespace | 242 } // namespace |
| 243 | 243 |
| 244 | 244 |
| 245 bool installer_setup::DeleteChromeRegistrationKeys(HKEY root, | 245 bool installer_setup::DeleteChromeRegistrationKeys(HKEY root, |
| 246 const std::wstring& browser_entry_suffix, |
| 246 installer_util::InstallStatus& exit_code) { | 247 installer_util::InstallStatus& exit_code) { |
| 247 RegKey key(root, L"", KEY_ALL_ACCESS); | 248 RegKey key(root, L"", KEY_ALL_ACCESS); |
| 248 | 249 |
| 249 // Delete Software\Classes\ChromeHTML, | 250 // Delete Software\Classes\ChromeHTML, |
| 250 std::wstring html_prog_id(ShellUtil::kRegClasses); | 251 std::wstring html_prog_id(ShellUtil::kRegClasses); |
| 251 file_util::AppendToPath(&html_prog_id, ShellUtil::kChromeHTMLProgId); | 252 file_util::AppendToPath(&html_prog_id, ShellUtil::kChromeHTMLProgId); |
| 252 DeleteRegistryKey(key, html_prog_id); | 253 DeleteRegistryKey(key, html_prog_id); |
| 253 | 254 |
| 254 // Delete Software\Classes\ChromeExt, | 255 // Delete Software\Classes\ChromeExt, |
| 255 std::wstring ext_prog_id(ShellUtil::kRegClasses); | 256 std::wstring ext_prog_id(ShellUtil::kRegClasses); |
| 256 file_util::AppendToPath(&ext_prog_id, ShellUtil::kChromeExtProgId); | 257 file_util::AppendToPath(&ext_prog_id, ShellUtil::kChromeExtProgId); |
| 257 DeleteRegistryKey(key, ext_prog_id); | 258 DeleteRegistryKey(key, ext_prog_id); |
| 258 | 259 |
| 259 // Delete Software\Classes\.crx, | 260 // Delete Software\Classes\.crx, |
| 260 std::wstring ext_association(ShellUtil::kRegClasses); | 261 std::wstring ext_association(ShellUtil::kRegClasses); |
| 261 ext_association.append(L"\\."); | 262 ext_association.append(L"\\."); |
| 262 ext_association.append(chrome::kExtensionFileExtension); | 263 ext_association.append(chrome::kExtensionFileExtension); |
| 263 DeleteRegistryKey(key, ext_association); | 264 DeleteRegistryKey(key, ext_association); |
| 264 | 265 |
| 265 // Delete Software\Clients\StartMenuInternet\chrome.exe | 266 // Delete Software\Clients\StartMenuInternet\Chromium |
| 266 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 267 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 267 std::wstring set_access_key(ShellUtil::kRegStartMenuInternet); | 268 std::wstring set_access_key(ShellUtil::kRegStartMenuInternet); |
| 268 file_util::AppendToPath(&set_access_key, dist->GetApplicationName()); | 269 file_util::AppendToPath(&set_access_key, dist->GetApplicationName()); |
| 269 DeleteRegistryKey(key, set_access_key); | 270 DeleteRegistryKey(key, set_access_key); |
| 271 |
| 270 // We have renamed the StartMenuInternet\chrome.exe to | 272 // We have renamed the StartMenuInternet\chrome.exe to |
| 271 // StartMenuInternet\Chromium so for old users we still need to delete | 273 // StartMenuInternet\Chromium so for old users we still need to delete |
| 272 // the old key. | 274 // the old key. |
| 273 std::wstring old_set_access_key(ShellUtil::kRegStartMenuInternet); | 275 std::wstring old_set_access_key(ShellUtil::kRegStartMenuInternet); |
| 274 file_util::AppendToPath(&old_set_access_key, installer_util::kChromeExe); | 276 file_util::AppendToPath(&old_set_access_key, installer_util::kChromeExe); |
| 275 DeleteRegistryKey(key, old_set_access_key); | 277 DeleteRegistryKey(key, old_set_access_key); |
| 276 | 278 |
| 277 // Delete Software\RegisteredApplications\Chrome | 279 // Delete Software\RegisteredApplications\Chromium |
| 278 DeleteRegistryValue(root, ShellUtil::kRegRegisteredApplications, | 280 DeleteRegistryValue(root, ShellUtil::kRegRegisteredApplications, |
| 279 dist->GetApplicationName()); | 281 dist->GetApplicationName()); |
| 280 | 282 |
| 283 // Delete Software\Classes\ChromeHTML.<user> |
| 284 // Delete Software\Classes\ChromeExt.<user> |
| 285 // Delete Software\Clients\StartMenuInternet\Chromium.<user> |
| 286 // Delete Software\RegisteredApplications\Chromium.<user> |
| 287 if (!browser_entry_suffix.empty()) { |
| 288 html_prog_id.append(browser_entry_suffix); |
| 289 DeleteRegistryKey(key, html_prog_id); |
| 290 ext_prog_id.append(browser_entry_suffix); |
| 291 DeleteRegistryKey(key, ext_prog_id); |
| 292 set_access_key.append(browser_entry_suffix); |
| 293 DeleteRegistryKey(key, set_access_key); |
| 294 DeleteRegistryValue(root, ShellUtil::kRegRegisteredApplications, |
| 295 dist->GetApplicationName() + browser_entry_suffix); |
| 296 } |
| 297 |
| 281 // Delete Software\Classes\Applications\chrome.exe | 298 // Delete Software\Classes\Applications\chrome.exe |
| 282 std::wstring app_key(ShellUtil::kRegClasses); | 299 std::wstring app_key(ShellUtil::kRegClasses); |
| 283 file_util::AppendToPath(&app_key, L"Applications"); | 300 file_util::AppendToPath(&app_key, L"Applications"); |
| 284 file_util::AppendToPath(&app_key, installer_util::kChromeExe); | 301 file_util::AppendToPath(&app_key, installer_util::kChromeExe); |
| 285 DeleteRegistryKey(key, app_key); | 302 DeleteRegistryKey(key, app_key); |
| 286 | 303 |
| 287 // Delete the App Paths key that lets explorer find Chrome. | 304 // Delete the App Paths key that lets explorer find Chrome. |
| 288 std::wstring app_path_key(ShellUtil::kAppPathsRegistryKey); | 305 std::wstring app_path_key(ShellUtil::kAppPathsRegistryKey); |
| 289 file_util::AppendToPath(&app_path_key, installer_util::kChromeExe); | 306 file_util::AppendToPath(&app_path_key, installer_util::kChromeExe); |
| 290 DeleteRegistryKey(key, app_path_key); | 307 DeleteRegistryKey(key, app_path_key); |
| 291 | 308 |
| 292 //Cleanup OpenWithList | 309 //Cleanup OpenWithList |
| 293 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { | 310 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { |
| 294 std::wstring open_with_key(ShellUtil::kRegClasses); | 311 std::wstring open_with_key(ShellUtil::kRegClasses); |
| 295 file_util::AppendToPath(&open_with_key, ShellUtil::kFileAssociations[i]); | 312 file_util::AppendToPath(&open_with_key, ShellUtil::kFileAssociations[i]); |
| 296 file_util::AppendToPath(&open_with_key, L"OpenWithList"); | 313 file_util::AppendToPath(&open_with_key, L"OpenWithList"); |
| 297 file_util::AppendToPath(&open_with_key, installer_util::kChromeExe); | 314 file_util::AppendToPath(&open_with_key, installer_util::kChromeExe); |
| 298 DeleteRegistryKey(key, open_with_key); | 315 DeleteRegistryKey(key, open_with_key); |
| 299 } | 316 } |
| 300 | 317 |
| 301 key.Close(); | 318 key.Close(); |
| 302 exit_code = installer_util::UNINSTALL_SUCCESSFUL; | 319 exit_code = installer_util::UNINSTALL_SUCCESSFUL; |
| 303 return true; | 320 return true; |
| 304 } | 321 } |
| 305 | 322 |
| 306 installer_util::InstallStatus installer_setup::UninstallChrome( | 323 installer_util::InstallStatus installer_setup::UninstallChrome( |
| 307 const std::wstring& exe_path, bool system_uninstall, | 324 const std::wstring& exe_path, bool system_uninstall, |
| 308 bool remove_all, bool force_uninstall, | 325 bool remove_all, bool force_uninstall, |
| 309 const CommandLine& cmd_line, const wchar_t* cmd_params) { | 326 const CommandLine& cmd_line, const wchar_t* cmd_params) { |
| 327 std::wstring suffix; |
| 328 ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix); |
| 310 installer_util::InstallStatus status = installer_util::UNINSTALL_CONFIRMED; | 329 installer_util::InstallStatus status = installer_util::UNINSTALL_CONFIRMED; |
| 311 if (force_uninstall) { | 330 if (force_uninstall) { |
| 312 // Since --force-uninstall command line option is used, we are going to | 331 // Since --force-uninstall command line option is used, we are going to |
| 313 // do silent uninstall. Try to close all running Chrome instances. | 332 // do silent uninstall. Try to close all running Chrome instances. |
| 314 CloseAllChromeProcesses(); | 333 CloseAllChromeProcesses(); |
| 315 } else { // no --force-uninstall so lets show some UI dialog boxes. | 334 } else { // no --force-uninstall so lets show some UI dialog boxes. |
| 316 status = IsChromeActiveOrUserCancelled(system_uninstall); | 335 status = IsChromeActiveOrUserCancelled(system_uninstall); |
| 317 if (status != installer_util::UNINSTALL_CONFIRMED && | 336 if (status != installer_util::UNINSTALL_CONFIRMED && |
| 318 status != installer_util::UNINSTALL_DELETE_PROFILE) | 337 status != installer_util::UNINSTALL_DELETE_PROFILE) |
| 319 return status; | 338 return status; |
| 320 | 339 |
| 321 // Check if we need admin rights to cleanup HKLM. If we do, try to launch | 340 // Check if we need admin rights to cleanup HKLM. If we do, try to launch |
| 322 // another uninstaller (silent) in elevated mode to do HKLM cleanup. | 341 // another uninstaller (silent) in elevated mode to do HKLM cleanup. |
| 323 // And continue uninstalling in the current process also to do HKCU cleanup. | 342 // And continue uninstalling in the current process also to do HKCU cleanup. |
| 324 if (remove_all && | 343 if (remove_all && |
| 325 ShellUtil::AdminNeededForRegistryCleanup() && | 344 ShellUtil::AdminNeededForRegistryCleanup() && |
| 326 !::IsUserAnAdmin() && | 345 !::IsUserAnAdmin() && |
| 327 (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) && | 346 (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) && |
| 328 !cmd_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { | 347 !cmd_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { |
| 329 std::wstring exe = cmd_line.program(); | 348 std::wstring exe = cmd_line.program(); |
| 330 std::wstring params(cmd_params); | 349 std::wstring params(cmd_params); |
| 331 // Append --run-as-admin flag to let the new instance of setup.exe know | 350 // Append --run-as-admin flag to let the new instance of setup.exe know |
| 332 // that we already tried to launch ourselves as admin. | 351 // that we already tried to launch ourselves as admin. |
| 333 params.append(L" --"); | 352 params.append(L" --"); |
| 334 params.append(installer_util::switches::kRunAsAdmin); | 353 params.append(installer_util::switches::kRunAsAdmin); |
| 335 // Append --remove-chrome-registration to remove registry keys only. | 354 // Append --remove-chrome-registration to remove registry keys only. |
| 336 params.append(L" --"); | 355 params.append(L" --"); |
| 337 params.append(installer_util::switches::kRemoveChromeRegistration); | 356 params.append(installer_util::switches::kRemoveChromeRegistration); |
| 357 if (!suffix.empty()) { |
| 358 params.append(L" --"); |
| 359 params.append(installer_util::switches::kRegisterChromeBrowserSuffix); |
| 360 params.append(L"=\"" + suffix + L"\""); |
| 361 } |
| 338 DWORD exit_code = installer_util::UNKNOWN_STATUS; | 362 DWORD exit_code = installer_util::UNKNOWN_STATUS; |
| 339 InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code); | 363 InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code); |
| 340 } | 364 } |
| 341 } | 365 } |
| 342 | 366 |
| 343 // Get the version of installed Chrome (if any) | 367 // Get the version of installed Chrome (if any) |
| 344 scoped_ptr<installer::Version> | 368 scoped_ptr<installer::Version> |
| 345 installed_version(InstallUtil::GetChromeVersion(system_uninstall)); | 369 installed_version(InstallUtil::GetChromeVersion(system_uninstall)); |
| 346 | 370 |
| 347 // Chrome is not in use so lets uninstall Chrome by deleting various files | 371 // Chrome is not in use so lets uninstall Chrome by deleting various files |
| (...skipping 11 matching lines...) Expand all Loading... |
| 359 // Note that we must retrieve the distribution-specific data before deleting | 383 // Note that we must retrieve the distribution-specific data before deleting |
| 360 // dist->GetVersionKey(). | 384 // dist->GetVersionKey(). |
| 361 std::wstring distribution_data(dist->GetDistributionData(&key)); | 385 std::wstring distribution_data(dist->GetDistributionData(&key)); |
| 362 | 386 |
| 363 // Remove Control Panel uninstall link and Omaha product key. | 387 // Remove Control Panel uninstall link and Omaha product key. |
| 364 DeleteRegistryKey(key, dist->GetUninstallRegPath()); | 388 DeleteRegistryKey(key, dist->GetUninstallRegPath()); |
| 365 DeleteRegistryKey(key, dist->GetVersionKey()); | 389 DeleteRegistryKey(key, dist->GetVersionKey()); |
| 366 | 390 |
| 367 // Remove all Chrome registration keys. | 391 // Remove all Chrome registration keys. |
| 368 installer_util::InstallStatus ret = installer_util::UNKNOWN_STATUS; | 392 installer_util::InstallStatus ret = installer_util::UNKNOWN_STATUS; |
| 369 DeleteChromeRegistrationKeys(reg_root, ret); | 393 DeleteChromeRegistrationKeys(reg_root, suffix, ret); |
| 370 | 394 |
| 371 // For user level install also we end up creating some keys in HKLM if user | 395 // For user level install also we end up creating some keys in HKLM if user |
| 372 // sets Chrome as default browser. So delete those as well (needs admin). | 396 // sets Chrome as default browser. So delete those as well (needs admin). |
| 373 if (remove_all && !system_uninstall) | 397 if (remove_all && !system_uninstall) |
| 374 DeleteChromeRegistrationKeys(HKEY_LOCAL_MACHINE, ret); | 398 DeleteChromeRegistrationKeys(HKEY_LOCAL_MACHINE, suffix, ret); |
| 375 | 399 |
| 376 // Delete shared registry keys as well (these require admin rights) if | 400 // Delete shared registry keys as well (these require admin rights) if |
| 377 // remove_all option is specified. | 401 // remove_all option is specified. |
| 378 if (remove_all) { | 402 if (remove_all) { |
| 379 // Delete media player registry key that exists only in HKLM. | 403 // Delete media player registry key that exists only in HKLM. |
| 380 RegKey hklm_key(HKEY_LOCAL_MACHINE, L"", KEY_ALL_ACCESS); | 404 RegKey hklm_key(HKEY_LOCAL_MACHINE, L"", KEY_ALL_ACCESS); |
| 381 std::wstring reg_path(installer::kMediaPlayerRegPath); | 405 std::wstring reg_path(installer::kMediaPlayerRegPath); |
| 382 file_util::AppendToPath(®_path, installer_util::kChromeExe); | 406 file_util::AppendToPath(®_path, installer_util::kChromeExe); |
| 383 DeleteRegistryKey(hklm_key, reg_path); | 407 DeleteRegistryKey(hklm_key, reg_path); |
| 384 hklm_key.Close(); | 408 hklm_key.Close(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 distribution_data); | 440 distribution_data); |
| 417 } | 441 } |
| 418 | 442 |
| 419 // Try and delete the preserved local state once the post-install | 443 // Try and delete the preserved local state once the post-install |
| 420 // operations are complete. | 444 // operations are complete. |
| 421 if (!local_state_path.empty()) | 445 if (!local_state_path.empty()) |
| 422 file_util::Delete(local_state_path, false); | 446 file_util::Delete(local_state_path, false); |
| 423 | 447 |
| 424 return ret; | 448 return ret; |
| 425 } | 449 } |
| OLD | NEW |