Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 // We should have never set those keys. | 576 // We should have never set those keys. |
| 577 return true; | 577 return true; |
| 578 } | 578 } |
| 579 | 579 |
| 580 FilePath chrome_exe(target_path.Append(kChromeExe)); | 580 FilePath chrome_exe(target_path.Append(kChromeExe)); |
| 581 | 581 |
| 582 // Delete Software\Classes\ChromeHTML. | 582 // Delete Software\Classes\ChromeHTML. |
| 583 // For user-level installs we now only write these entries in HKCU, but since | 583 // For user-level installs we now only write these entries in HKCU, but since |
| 584 // old installs did install them to HKLM we will try to remove them in HKLM as | 584 // old installs did install them to HKLM we will try to remove them in HKLM as |
| 585 // well anyways. | 585 // well anyways. |
| 586 string16 html_prog_id(ShellUtil::kRegClasses); | 586 const string16 prog_id(ShellUtil::kChromeHTMLProgId + browser_entry_suffix); |
| 587 html_prog_id.push_back(FilePath::kSeparators[0]); | 587 string16 reg_prog_id(ShellUtil::kRegClasses); |
| 588 html_prog_id.append(ShellUtil::kChromeHTMLProgId); | 588 reg_prog_id.push_back(FilePath::kSeparators[0]); |
| 589 html_prog_id.append(browser_entry_suffix); | 589 reg_prog_id.append(prog_id); |
| 590 InstallUtil::DeleteRegistryKey(root, html_prog_id); | 590 InstallUtil::DeleteRegistryKey(root, reg_prog_id); |
| 591 | 591 |
| 592 // Delete Software\Classes\Chrome (Same comment as above applies for this too) | 592 // Delete Software\Classes\Chrome (Same comment as above applies for this too) |
| 593 string16 chrome_app_id(ShellUtil::kRegClasses); | 593 string16 reg_app_id(ShellUtil::kRegClasses); |
| 594 chrome_app_id.push_back(FilePath::kSeparators[0]); | 594 reg_app_id.push_back(FilePath::kSeparators[0]); |
| 595 // Append the requested suffix manually here (as ShellUtil::GetBrowserModelId | 595 // Append the requested suffix manually here (as ShellUtil::GetBrowserModelId |
| 596 // would otherwise try to figure out the currently installed suffix). | 596 // would otherwise try to figure out the currently installed suffix). |
| 597 chrome_app_id.append(dist->GetBaseAppId() + browser_entry_suffix); | 597 reg_app_id.append(dist->GetBaseAppId() + browser_entry_suffix); |
| 598 InstallUtil::DeleteRegistryKey(root, chrome_app_id); | 598 InstallUtil::DeleteRegistryKey(root, reg_app_id); |
| 599 | 599 |
| 600 // Delete all Start Menu Internet registrations that refer to this Chrome. | 600 // Delete all Start Menu Internet registrations that refer to this Chrome. |
| 601 { | 601 { |
| 602 using base::win::RegistryKeyIterator; | 602 using base::win::RegistryKeyIterator; |
| 603 InstallUtil::ProgramCompare open_command_pred(chrome_exe); | 603 InstallUtil::ProgramCompare open_command_pred(chrome_exe); |
| 604 string16 client_name; | 604 string16 client_name; |
| 605 string16 client_key; | 605 string16 client_key; |
| 606 string16 open_key; | 606 string16 open_key; |
| 607 for (RegistryKeyIterator iter(root, ShellUtil::kRegStartMenuInternet); | 607 for (RegistryKeyIterator iter(root, ShellUtil::kRegStartMenuInternet); |
| 608 iter.Valid(); ++iter) { | 608 iter.Valid(); ++iter) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 642 app_key.push_back(FilePath::kSeparators[0]); | 642 app_key.push_back(FilePath::kSeparators[0]); |
| 643 app_key.append(installer::kChromeExe); | 643 app_key.append(installer::kChromeExe); |
| 644 InstallUtil::DeleteRegistryKey(root, app_key); | 644 InstallUtil::DeleteRegistryKey(root, app_key); |
| 645 | 645 |
| 646 // Delete the App Paths key that lets explorer find Chrome. | 646 // Delete the App Paths key that lets explorer find Chrome. |
| 647 string16 app_path_key(ShellUtil::kAppPathsRegistryKey); | 647 string16 app_path_key(ShellUtil::kAppPathsRegistryKey); |
| 648 app_path_key.push_back(FilePath::kSeparators[0]); | 648 app_path_key.push_back(FilePath::kSeparators[0]); |
| 649 app_path_key.append(installer::kChromeExe); | 649 app_path_key.append(installer::kChromeExe); |
| 650 InstallUtil::DeleteRegistryKey(root, app_path_key); | 650 InstallUtil::DeleteRegistryKey(root, app_path_key); |
| 651 | 651 |
| 652 // Cleanup OpenWithList | 652 // Cleanup OpenWithList |
|
robertshield
2012/08/05 15:01:12
Please add links to http://msdn.microsoft.com/en-u
gab
2012/08/06 19:39:27
Done.
| |
| 653 string16 open_with_key; | 653 string16 file_assoc_key; |
| 654 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { | 654 string16 open_with_list_key; |
| 655 open_with_key.assign(ShellUtil::kRegClasses); | 655 string16 open_with_progids_key; |
| 656 open_with_key.push_back(FilePath::kSeparators[0]); | 656 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; ++i) { |
| 657 open_with_key.append(ShellUtil::kFileAssociations[i]); | 657 file_assoc_key.assign(ShellUtil::kRegClasses); |
| 658 open_with_key.push_back(FilePath::kSeparators[0]); | 658 file_assoc_key.push_back(FilePath::kSeparators[0]); |
| 659 open_with_key.append(L"OpenWithList"); | 659 file_assoc_key.append(ShellUtil::kFileAssociations[i]); |
| 660 open_with_key.push_back(FilePath::kSeparators[0]); | 660 file_assoc_key.push_back(FilePath::kSeparators[0]); |
| 661 open_with_key.append(installer::kChromeExe); | 661 |
| 662 InstallUtil::DeleteRegistryKey(root, open_with_key); | 662 open_with_list_key.assign(file_assoc_key); |
| 663 open_with_list_key.append(L"OpenWithList"); | |
| 664 open_with_list_key.push_back(FilePath::kSeparators[0]); | |
| 665 open_with_list_key.append(installer::kChromeExe); | |
| 666 InstallUtil::DeleteRegistryKey(root, open_with_list_key); | |
| 667 | |
| 668 open_with_progids_key.assign(file_assoc_key); | |
| 669 open_with_progids_key.append(ShellUtil::kRegOpenWithProgids); | |
| 670 InstallUtil::DeleteRegistryValue(root, open_with_progids_key, prog_id); | |
| 663 } | 671 } |
| 664 | 672 |
| 665 // Cleanup in case Chrome had been made the default browser. | 673 // Cleanup in case Chrome had been made the default browser. |
| 666 | 674 |
| 667 // Delete the default value of SOFTWARE\Clients\StartMenuInternet if it | 675 // Delete the default value of SOFTWARE\Clients\StartMenuInternet if it |
| 668 // references this Chrome. Do this explicitly here for the case where HKCU is | 676 // references this Chrome. Do this explicitly here for the case where HKCU is |
| 669 // being processed; the iteration above will have no hits since registration | 677 // being processed; the iteration above will have no hits since registration |
| 670 // lives in HKLM. | 678 // lives in HKLM. |
| 671 InstallUtil::DeleteRegistryValueIf( | 679 InstallUtil::DeleteRegistryValueIf( |
| 672 root, ShellUtil::kRegStartMenuInternet, L"", | 680 root, ShellUtil::kRegStartMenuInternet, L"", |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1009 // Always remove the HKLM registration for system-level installs. For | 1017 // Always remove the HKLM registration for system-level installs. For |
| 1010 // user-level installs, only remove it if both: 1) this uninstall isn't a | 1018 // user-level installs, only remove it if both: 1) this uninstall isn't a |
| 1011 // self destruct following the installation of a system-level Chrome | 1019 // self destruct following the installation of a system-level Chrome |
| 1012 // (because the system-level Chrome owns the HKLM registration now), and 2) | 1020 // (because the system-level Chrome owns the HKLM registration now), and 2) |
| 1013 // this user has made Chrome their default browser (i.e. has shell | 1021 // this user has made Chrome their default browser (i.e. has shell |
| 1014 // integration entries registered with |suffix| (note: |suffix| will be the | 1022 // integration entries registered with |suffix| (note: |suffix| will be the |
| 1015 // empty string if required as it is obtained by | 1023 // empty string if required as it is obtained by |
| 1016 // GetCurrentInstallationSuffix() above)). | 1024 // GetCurrentInstallationSuffix() above)). |
| 1017 // TODO(gab): This can still leave parts of a suffixed install behind. To be | 1025 // TODO(gab): This can still leave parts of a suffixed install behind. To be |
| 1018 // able to remove them we would need to be able to remove only suffixed | 1026 // able to remove them we would need to be able to remove only suffixed |
| 1019 // entries (as it is now some of the shell integration entries are | 1027 // entries (as it is now some of the registry entries (e.g. App Paths) are |
| 1020 // unsuffixed; thus removing suffixed installs is prohibited in HKLM if | 1028 // unsuffixed; thus removing suffixed installs is prohibited in HKLM if |
| 1021 // !|remove_all| for now). | 1029 // !|remove_all| for now). |
| 1022 if (installer_state.system_install() || | 1030 if (installer_state.system_install() || |
| 1023 (remove_all && | 1031 (remove_all && |
| 1024 ShellUtil::QuickIsChromeRegisteredInHKLM( | 1032 ShellUtil::QuickIsChromeRegisteredInHKLM( |
| 1025 browser_dist, chrome_exe, suffix))) { | 1033 browser_dist, chrome_exe, suffix))) { |
| 1026 DeleteChromeRegistrationKeys(browser_dist, HKEY_LOCAL_MACHINE, suffix, | 1034 DeleteChromeRegistrationKeys(browser_dist, HKEY_LOCAL_MACHINE, suffix, |
| 1027 installer_state.target_path(), &ret); | 1035 installer_state.target_path(), &ret); |
| 1028 } | 1036 } |
| 1029 | 1037 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1137 | 1145 |
| 1138 // Try and delete the preserved local state once the post-install | 1146 // Try and delete the preserved local state once the post-install |
| 1139 // operations are complete. | 1147 // operations are complete. |
| 1140 if (!backup_state_file.empty()) | 1148 if (!backup_state_file.empty()) |
| 1141 file_util::Delete(backup_state_file, false); | 1149 file_util::Delete(backup_state_file, false); |
| 1142 | 1150 |
| 1143 return ret; | 1151 return ret; |
| 1144 } | 1152 } |
| 1145 | 1153 |
| 1146 } // namespace installer | 1154 } // namespace installer |
| OLD | NEW |