Commit 2a646824 authored by cpu@chromium.org's avatar cpu@chromium.org

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
parent 30fdb366
......@@ -172,6 +172,9 @@ void ExternalProtocolHandler::PrepopulateDictionary(DictionaryValue* win_pref) {
"mailto",
"news",
"snews",
#if defined(OS_WIN)
"ms-windows-store",
#endif
};
bool should_block;
......
......@@ -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",
......
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