Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: chrome/browser/platform_util_win.cc

Issue 11316038: Make it so the windows store protocol is properly handled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/external_protocol/external_protocol_handler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/platform_util_win.cc
===================================================================
--- chrome/browser/platform_util_win.cc (revision 168012)
+++ chrome/browser/platform_util_win.cc (working copy)
@@ -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,21 @@
}
}
+// 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;
darin (slow to review) 2013/01/08 06:00:14 nit: 2 space indent
cpu_(ooo_6.6-7.5) 2013/01/08 19:01:16 Done.
+ return true;
+}
} // namespace
darin (slow to review) 2013/01/08 06:00:14 nit: new line before close of namespace
cpu_(ooo_6.6-7.5) 2013/01/08 19:01:16 Done.
namespace platform_util {
@@ -148,20 +164,9 @@
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) {
darin (slow to review) 2013/01/08 06:00:14 Why less than Win7 and not less than Win8? Win7 a
cpu_(ooo_6.6-7.5) 2013/01/08 19:01:16 Yes.
+ if (!ValidateShellCommandForScheme(url.scheme()))
jschuh 2013/01/08 04:06:00 I feel like Nicolas should sign off on this one gi
cpu_(ooo_6.6-7.5) 2013/01/08 19:01:16 Ok, I'll ping him.
jschuh 2013/01/08 19:22:37 I'm pretty sure I typed that after you handed me a
return;
- }
}
if (reinterpret_cast<ULONG_PTR>(ShellExecuteA(NULL, "open",
« no previous file with comments | « chrome/browser/external_protocol/external_protocol_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698