diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 02:35:09 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 02:35:09 +0000 |
commit | 2a64682425c446c25e0fa5f352f7ed2a9ae22025 (patch) | |
tree | 1cf0b4985751deb238f1c84077628d5d0a5109eb /chrome/browser/platform_util_win.cc | |
parent | 30fdb36651388788b318cde3e9e86c29fd2bd79b (diff) | |
download | chromium_src-2a64682425c446c25e0fa5f352f7ed2a9ae22025.zip chromium_src-2a64682425c446c25e0fa5f352f7ed2a9ae22025.tar.gz chromium_src-2a64682425c446c25e0fa5f352f7ed2a9ae22025.tar.bz2 |
Make it so the windows store protocol is properly handled
The core problem is that the key that controls the execution of a protocol
HKEY_CLASSES_ROOT\<protocol>\Shell\Open\Command
Has changed, we expect the Default value to be a valid command like foo.exe %1
but this is no longer the case. This value can be empty and other values will
control what happens, for instance DelegateExecute.
This CL also whitelists the protocol, alternatively we could hardcode a meaniful
string to present to the user but that presents localization issues. We take the
same approach as IE and just launch the windows store if we see this protocol.
BUG=159096
TEST=see bug
Review URL: https://codereview.chromium.org/11316038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175678 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/platform_util_win.cc')
-rw-r--r-- | chrome/browser/platform_util_win.cc | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc index 256bb25..a5cfc50 100644 --- a/chrome/browser/platform_util_win.cc +++ b/chrome/browser/platform_util_win.cc @@ -19,6 +19,7 @@ #include "base/win/registry.h" #include "base/win/scoped_co_mem.h" #include "base/win/scoped_comptr.h" +#include "base/win/windows_version.h" #include "content/public/browser/browser_thread.h" #include "googleurl/src/gurl.h" #include "ui/base/win/shell.h" @@ -113,6 +114,22 @@ void ShowItemInFolderOnFileThread(const FilePath& full_path) { } } +// Old ShellExecute crashes the process when the command for a given scheme +// is empty. This function tells if it is. +bool ValidateShellCommandForScheme(const std::string& scheme) { + base::win::RegKey key; + std::wstring registry_path = ASCIIToWide(scheme) + + L"\\shell\\open\\command"; + key.Open(HKEY_CLASSES_ROOT, registry_path.c_str(), KEY_READ); + if (!key.Valid()) + return false; + DWORD size = 0; + key.ReadValue(NULL, NULL, &size, NULL); + if (size <= 2) + return false; + return true; +} + } // namespace namespace platform_util { @@ -148,20 +165,9 @@ void OpenExternal(const GURL& url) { return; } - base::win::RegKey key; - std::wstring registry_path = ASCIIToWide(url.scheme()) + - L"\\shell\\open\\command"; - key.Open(HKEY_CLASSES_ROOT, registry_path.c_str(), KEY_READ); - if (key.Valid()) { - DWORD size = 0; - key.ReadValue(NULL, NULL, &size, NULL); - if (size <= 2) { - // ShellExecute crashes the process when the command is empty. - // We check for "2" because it always returns the trailing NULL. - // TODO(nsylvain): we should also add a dialog to warn on errors. See - // bug 1136923. + if (base::win::GetVersion() < base::win::VERSION_WIN7) { + if (!ValidateShellCommandForScheme(url.scheme())) return; - } } if (reinterpret_cast<ULONG_PTR>(ShellExecuteA(NULL, "open", |