Commit f5a05dc4 authored by gab@chromium.org's avatar gab@chromium.org

Register Chrome in Open With... for File Associations at install on Windows.

Refactor shell_util.cc to use ScopedVector<RegistryEntry> instead of std::list<RegistryEntry*>

BUG=139597
TEST=Chrome shows up in the Open With context menu immediately post-install (not after first-run/make default).
Make sure App Paths still work (i.e. launch "chrome.exe" from Run dialog).

For the OpenWith test (say you're testing OpenWith for .htm files), make sure that you delete Chrome ProgIds from:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.htm\OpenWithProgids
(they are automatically copied there by Windows so if you have previously installed Chrome on this machine and made it default at least once Windows will have picked this up already).

Review URL: https://chromiumcodereview.appspot.com/10823178

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150234 0039d316-1c4b-4281-b951-d872f2087c98
parent c3fdbdf7
...@@ -392,7 +392,7 @@ void RegisterChromeOnMachine(const InstallerState& installer_state, ...@@ -392,7 +392,7 @@ void RegisterChromeOnMachine(const InstallerState& installer_state,
AddChromeToMediaPlayerList(); AddChromeToMediaPlayerList();
// Make Chrome the default browser if desired when possible. Otherwise, only // Make Chrome the default browser if desired when possible. Otherwise, only
// register it for shell integration. // register it with Windows.
BrowserDistribution* dist = product.distribution(); BrowserDistribution* dist = product.distribution();
const string16 chrome_exe( const string16 chrome_exe(
installer_state.target_path().Append(installer::kChromeExe).value()); installer_state.target_path().Append(installer::kChromeExe).value());
......
...@@ -592,19 +592,19 @@ bool DeleteChromeRegistrationKeys(BrowserDistribution* dist, HKEY root, ...@@ -592,19 +592,19 @@ bool DeleteChromeRegistrationKeys(BrowserDistribution* dist, HKEY root,
// For user-level installs we now only write these entries in HKCU, but since // For user-level installs we now only write these entries in HKCU, but since
// old installs did install them to HKLM we will try to remove them in HKLM as // old installs did install them to HKLM we will try to remove them in HKLM as
// well anyways. // well anyways.
string16 html_prog_id(ShellUtil::kRegClasses); const string16 prog_id(ShellUtil::kChromeHTMLProgId + browser_entry_suffix);
html_prog_id.push_back(FilePath::kSeparators[0]); string16 reg_prog_id(ShellUtil::kRegClasses);
html_prog_id.append(ShellUtil::kChromeHTMLProgId); reg_prog_id.push_back(FilePath::kSeparators[0]);
html_prog_id.append(browser_entry_suffix); reg_prog_id.append(prog_id);
InstallUtil::DeleteRegistryKey(root, html_prog_id); InstallUtil::DeleteRegistryKey(root, reg_prog_id);
// Delete Software\Classes\Chrome (Same comment as above applies for this too) // Delete Software\Classes\Chrome (Same comment as above applies for this too)
string16 chrome_app_id(ShellUtil::kRegClasses); string16 reg_app_id(ShellUtil::kRegClasses);
chrome_app_id.push_back(FilePath::kSeparators[0]); reg_app_id.push_back(FilePath::kSeparators[0]);
// Append the requested suffix manually here (as ShellUtil::GetBrowserModelId // Append the requested suffix manually here (as ShellUtil::GetBrowserModelId
// would otherwise try to figure out the currently installed suffix). // would otherwise try to figure out the currently installed suffix).
chrome_app_id.append(dist->GetBaseAppId() + browser_entry_suffix); reg_app_id.append(dist->GetBaseAppId() + browser_entry_suffix);
InstallUtil::DeleteRegistryKey(root, chrome_app_id); InstallUtil::DeleteRegistryKey(root, reg_app_id);
// Delete all Start Menu Internet registrations that refer to this Chrome. // Delete all Start Menu Internet registrations that refer to this Chrome.
{ {
...@@ -644,7 +644,8 @@ bool DeleteChromeRegistrationKeys(BrowserDistribution* dist, HKEY root, ...@@ -644,7 +644,8 @@ bool DeleteChromeRegistrationKeys(BrowserDistribution* dist, HKEY root,
InstallUtil::DeleteRegistryValue(root, ShellUtil::kRegRegisteredApplications, InstallUtil::DeleteRegistryValue(root, ShellUtil::kRegRegisteredApplications,
dist->GetBaseAppName() + browser_entry_suffix); dist->GetBaseAppName() + browser_entry_suffix);
// Delete Software\Classes\Applications\chrome.exe // Delete the App Paths and Applications keys that let Explorer find Chrome:
// http://msdn.microsoft.com/en-us/library/windows/desktop/ee872121
string16 app_key(ShellUtil::kRegClasses); string16 app_key(ShellUtil::kRegClasses);
app_key.push_back(FilePath::kSeparators[0]); app_key.push_back(FilePath::kSeparators[0]);
app_key.append(L"Applications"); app_key.append(L"Applications");
...@@ -652,23 +653,31 @@ bool DeleteChromeRegistrationKeys(BrowserDistribution* dist, HKEY root, ...@@ -652,23 +653,31 @@ bool DeleteChromeRegistrationKeys(BrowserDistribution* dist, HKEY root,
app_key.append(installer::kChromeExe); app_key.append(installer::kChromeExe);
InstallUtil::DeleteRegistryKey(root, app_key); InstallUtil::DeleteRegistryKey(root, app_key);
// Delete the App Paths key that lets explorer find Chrome.
string16 app_path_key(ShellUtil::kAppPathsRegistryKey); string16 app_path_key(ShellUtil::kAppPathsRegistryKey);
app_path_key.push_back(FilePath::kSeparators[0]); app_path_key.push_back(FilePath::kSeparators[0]);
app_path_key.append(installer::kChromeExe); app_path_key.append(installer::kChromeExe);
InstallUtil::DeleteRegistryKey(root, app_path_key); InstallUtil::DeleteRegistryKey(root, app_path_key);
// Cleanup OpenWithList // Cleanup OpenWithList and OpenWithProgids:
string16 open_with_key; // http://msdn.microsoft.com/en-us/library/bb166549
for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { string16 file_assoc_key;
open_with_key.assign(ShellUtil::kRegClasses); string16 open_with_list_key;
open_with_key.push_back(FilePath::kSeparators[0]); string16 open_with_progids_key;
open_with_key.append(ShellUtil::kFileAssociations[i]); for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; ++i) {
open_with_key.push_back(FilePath::kSeparators[0]); file_assoc_key.assign(ShellUtil::kRegClasses);
open_with_key.append(L"OpenWithList"); file_assoc_key.push_back(FilePath::kSeparators[0]);
open_with_key.push_back(FilePath::kSeparators[0]); file_assoc_key.append(ShellUtil::kFileAssociations[i]);
open_with_key.append(installer::kChromeExe); file_assoc_key.push_back(FilePath::kSeparators[0]);
InstallUtil::DeleteRegistryKey(root, open_with_key);
open_with_list_key.assign(file_assoc_key);
open_with_list_key.append(L"OpenWithList");
open_with_list_key.push_back(FilePath::kSeparators[0]);
open_with_list_key.append(installer::kChromeExe);
InstallUtil::DeleteRegistryKey(root, open_with_list_key);
open_with_progids_key.assign(file_assoc_key);
open_with_progids_key.append(ShellUtil::kRegOpenWithProgids);
InstallUtil::DeleteRegistryValue(root, open_with_progids_key, prog_id);
} }
// Cleanup in case Chrome had been made the default browser. // Cleanup in case Chrome had been made the default browser.
...@@ -1025,7 +1034,7 @@ InstallStatus UninstallProduct(const InstallationState& original_state, ...@@ -1025,7 +1034,7 @@ InstallStatus UninstallProduct(const InstallationState& original_state,
// GetCurrentInstallationSuffix() above)). // GetCurrentInstallationSuffix() above)).
// TODO(gab): This can still leave parts of a suffixed install behind. To be // TODO(gab): This can still leave parts of a suffixed install behind. To be
// able to remove them we would need to be able to remove only suffixed // able to remove them we would need to be able to remove only suffixed
// entries (as it is now some of the shell integration entries are // entries (as it is now some of the registry entries (e.g. App Paths) are
// unsuffixed; thus removing suffixed installs is prohibited in HKLM if // unsuffixed; thus removing suffixed installs is prohibited in HKLM if
// !|remove_all| for now). // !|remove_all| for now).
if (installer_state.system_install() || if (installer_state.system_install() ||
......
This diff is collapsed.
...@@ -124,6 +124,9 @@ class ShellUtil { ...@@ -124,6 +124,9 @@ class ShellUtil {
// Registry value name for the DelegateExecute verb handler. // Registry value name for the DelegateExecute verb handler.
static const wchar_t* kRegDelegateExecute; static const wchar_t* kRegDelegateExecute;
// Registry value name for the OpenWithProgids entry for file associations.
static const wchar_t* kRegOpenWithProgids;
// Returns true if |chrome_exe| is registered in HKLM with |suffix|. // Returns true if |chrome_exe| is registered in HKLM with |suffix|.
// Note: This only checks one deterministic key in HKLM for |chrome_exe| and // Note: This only checks one deterministic key in HKLM for |chrome_exe| and
// doesn't otherwise validate a full Chrome install in HKLM. // doesn't otherwise validate a full Chrome install in HKLM.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment