| 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 19 matching lines...) Expand all Loading... |
| 628 L"", InstallUtil::ValueEquals(client_name)); | 628 L"", InstallUtil::ValueEquals(client_name)); |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 } | 631 } |
| 632 } | 632 } |
| 633 | 633 |
| 634 // Delete Software\RegisteredApplications\Chromium | 634 // Delete Software\RegisteredApplications\Chromium |
| 635 InstallUtil::DeleteRegistryValue(root, ShellUtil::kRegRegisteredApplications, | 635 InstallUtil::DeleteRegistryValue(root, ShellUtil::kRegRegisteredApplications, |
| 636 dist->GetBaseAppName() + browser_entry_suffix); | 636 dist->GetBaseAppName() + browser_entry_suffix); |
| 637 | 637 |
| 638 // Delete Software\Classes\Applications\chrome.exe | 638 // Delete the App Paths and Applications keys that let Explorer find Chrome: |
| 639 // http://msdn.microsoft.com/en-us/library/windows/desktop/ee872121 |
| 639 string16 app_key(ShellUtil::kRegClasses); | 640 string16 app_key(ShellUtil::kRegClasses); |
| 640 app_key.push_back(FilePath::kSeparators[0]); | 641 app_key.push_back(FilePath::kSeparators[0]); |
| 641 app_key.append(L"Applications"); | 642 app_key.append(L"Applications"); |
| 642 app_key.push_back(FilePath::kSeparators[0]); | 643 app_key.push_back(FilePath::kSeparators[0]); |
| 643 app_key.append(installer::kChromeExe); | 644 app_key.append(installer::kChromeExe); |
| 644 InstallUtil::DeleteRegistryKey(root, app_key); | 645 InstallUtil::DeleteRegistryKey(root, app_key); |
| 645 | 646 |
| 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 and OpenWithProgids: |
| 653 string16 open_with_key; | 653 // http://msdn.microsoft.com/en-us/library/bb166549 |
| 654 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { | 654 string16 file_assoc_key; |
| 655 open_with_key.assign(ShellUtil::kRegClasses); | 655 string16 open_with_list_key; |
| 656 open_with_key.push_back(FilePath::kSeparators[0]); | 656 string16 open_with_progids_key; |
| 657 open_with_key.append(ShellUtil::kFileAssociations[i]); | 657 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; ++i) { |
| 658 open_with_key.push_back(FilePath::kSeparators[0]); | 658 file_assoc_key.assign(ShellUtil::kRegClasses); |
| 659 open_with_key.append(L"OpenWithList"); | 659 file_assoc_key.push_back(FilePath::kSeparators[0]); |
| 660 open_with_key.push_back(FilePath::kSeparators[0]); | 660 file_assoc_key.append(ShellUtil::kFileAssociations[i]); |
| 661 open_with_key.append(installer::kChromeExe); | 661 file_assoc_key.push_back(FilePath::kSeparators[0]); |
| 662 InstallUtil::DeleteRegistryKey(root, open_with_key); | 662 |
| 663 open_with_list_key.assign(file_assoc_key); |
| 664 open_with_list_key.append(L"OpenWithList"); |
| 665 open_with_list_key.push_back(FilePath::kSeparators[0]); |
| 666 open_with_list_key.append(installer::kChromeExe); |
| 667 InstallUtil::DeleteRegistryKey(root, open_with_list_key); |
| 668 |
| 669 open_with_progids_key.assign(file_assoc_key); |
| 670 open_with_progids_key.append(ShellUtil::kRegOpenWithProgids); |
| 671 InstallUtil::DeleteRegistryValue(root, open_with_progids_key, prog_id); |
| 663 } | 672 } |
| 664 | 673 |
| 665 // Cleanup in case Chrome had been made the default browser. | 674 // Cleanup in case Chrome had been made the default browser. |
| 666 | 675 |
| 667 // Delete the default value of SOFTWARE\Clients\StartMenuInternet if it | 676 // Delete the default value of SOFTWARE\Clients\StartMenuInternet if it |
| 668 // references this Chrome. Do this explicitly here for the case where HKCU is | 677 // 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 | 678 // being processed; the iteration above will have no hits since registration |
| 670 // lives in HKLM. | 679 // lives in HKLM. |
| 671 InstallUtil::DeleteRegistryValueIf( | 680 InstallUtil::DeleteRegistryValueIf( |
| 672 root, ShellUtil::kRegStartMenuInternet, L"", | 681 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 | 1018 // 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 | 1019 // 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 | 1020 // self destruct following the installation of a system-level Chrome |
| 1012 // (because the system-level Chrome owns the HKLM registration now), and 2) | 1021 // (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 | 1022 // this user has made Chrome their default browser (i.e. has shell |
| 1014 // integration entries registered with |suffix| (note: |suffix| will be the | 1023 // integration entries registered with |suffix| (note: |suffix| will be the |
| 1015 // empty string if required as it is obtained by | 1024 // empty string if required as it is obtained by |
| 1016 // GetCurrentInstallationSuffix() above)). | 1025 // GetCurrentInstallationSuffix() above)). |
| 1017 // TODO(gab): This can still leave parts of a suffixed install behind. To be | 1026 // 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 | 1027 // 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 | 1028 // 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 | 1029 // unsuffixed; thus removing suffixed installs is prohibited in HKLM if |
| 1021 // !|remove_all| for now). | 1030 // !|remove_all| for now). |
| 1022 if (installer_state.system_install() || | 1031 if (installer_state.system_install() || |
| 1023 (remove_all && | 1032 (remove_all && |
| 1024 ShellUtil::QuickIsChromeRegisteredInHKLM( | 1033 ShellUtil::QuickIsChromeRegisteredInHKLM( |
| 1025 browser_dist, chrome_exe, suffix))) { | 1034 browser_dist, chrome_exe, suffix))) { |
| 1026 DeleteChromeRegistrationKeys(browser_dist, HKEY_LOCAL_MACHINE, suffix, | 1035 DeleteChromeRegistrationKeys(browser_dist, HKEY_LOCAL_MACHINE, suffix, |
| 1027 installer_state.target_path(), &ret); | 1036 installer_state.target_path(), &ret); |
| 1028 } | 1037 } |
| 1029 | 1038 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 | 1146 |
| 1138 // Try and delete the preserved local state once the post-install | 1147 // Try and delete the preserved local state once the post-install |
| 1139 // operations are complete. | 1148 // operations are complete. |
| 1140 if (!backup_state_file.empty()) | 1149 if (!backup_state_file.empty()) |
| 1141 file_util::Delete(backup_state_file, false); | 1150 file_util::Delete(backup_state_file, false); |
| 1142 | 1151 |
| 1143 return ret; | 1152 return ret; |
| 1144 } | 1153 } |
| 1145 | 1154 |
| 1146 } // namespace installer | 1155 } // namespace installer |
| OLD | NEW |