summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornsylvain@google.com <nsylvain@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-08 22:33:45 +0000
committernsylvain@google.com <nsylvain@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-08 22:33:45 +0000
commit703e6c7fe28d047272032d2060b8b7331b43431f (patch)
tree0d8251ed2c0e2728921b1b9f650cdd631f2bba49
parentc1d552277262b3e1bcb2f9ca797a02757d021185 (diff)
downloadchromium_src-703e6c7fe28d047272032d2060b8b7331b43431f.zip
chromium_src-703e6c7fe28d047272032d2060b8b7331b43431f.tar.gz
chromium_src-703e6c7fe28d047272032d2060b8b7331b43431f.tar.bz2
Change the external protocol handler to look at the
command that will be run before warning the user. If the command is empty, there is no reason to warn. I removed a dcheck. This dcheck is good, but unfortunately we can't use g_browser_process in the io_thread. Review URL: http://codereview.chromium.org/1632 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1871 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/edit_drop_target.h6
-rw-r--r--chrome/browser/external_protocol_dialog.cc19
-rw-r--r--chrome/browser/external_protocol_dialog.h18
-rw-r--r--chrome/browser/external_protocol_handler.cc10
4 files changed, 35 insertions, 18 deletions
diff --git a/chrome/browser/autocomplete/edit_drop_target.h b/chrome/browser/autocomplete/edit_drop_target.h
index 0d0a12d..354843e 100644
--- a/chrome/browser/autocomplete/edit_drop_target.h
+++ b/chrome/browser/autocomplete/edit_drop_target.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_AUTOCOMPLETE_EDIT_DROP_TARGET_H__
-#define CHROME_BROWSER_AUTOCOMPLETE_EDIT_DROP_TARGET_H__
+#ifndef CHROME_BROWSER_AUTOCOMPLETE_EDIT_DROP_TARGET_H_
+#define CHROME_BROWSER_AUTOCOMPLETE_EDIT_DROP_TARGET_H_
#include "base/base_drop_target.h"
@@ -55,5 +55,5 @@ class EditDropTarget : public BaseDropTarget {
DISALLOW_EVIL_CONSTRUCTORS(EditDropTarget);
};
-#endif // CHROME_BROWSER_AUTOCOMPLETE_EDIT_DROP_TARGET_H__
+#endif // CHROME_BROWSER_AUTOCOMPLETE_EDIT_DROP_TARGET_H_
diff --git a/chrome/browser/external_protocol_dialog.cc b/chrome/browser/external_protocol_dialog.cc
index f8aa349..d3834b5 100644
--- a/chrome/browser/external_protocol_dialog.cc
+++ b/chrome/browser/external_protocol_dialog.cc
@@ -29,11 +29,12 @@ const int kMessageWidth = 400;
// static
void ExternalProtocolDialog::RunExternalProtocolDialog(
- const GURL& url, int render_process_host_id, int routing_id) {
+ const GURL& url, const std::wstring& command, int render_process_host_id,
+ int routing_id) {
TabContents* tab_contents = tab_util::GetTabContentsByID(
render_process_host_id, routing_id);
ExternalProtocolDialog* handler =
- new ExternalProtocolDialog(tab_contents, url);
+ new ExternalProtocolDialog(tab_contents, url, command);
}
ExternalProtocolDialog::~ExternalProtocolDialog() {
@@ -89,7 +90,8 @@ ChromeViews::View* ExternalProtocolDialog::GetContentsView() {
// ExternalProtocolDialog, private:
ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents,
- const GURL& url)
+ const GURL& url,
+ const std::wstring& command)
: tab_contents_(tab_contents),
url_(url) {
std::wstring message_text = l10n_util::GetStringF(
@@ -98,8 +100,7 @@ ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents,
ASCIIToWide(url.possibly_invalid_spec())) + L"\n\n";
message_text += l10n_util::GetStringF(
- IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH,
- GetApplicationForProtocol()) + L"\n\n";
+ IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, command) + L"\n\n";
message_text += l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_WARNING);
@@ -118,10 +119,12 @@ ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents,
ChromeViews::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this)->Show();
}
-std::wstring ExternalProtocolDialog::GetApplicationForProtocol() {
- std::wstring url_spec = ASCIIToWide(url_.possibly_invalid_spec());
+/* static */
+std::wstring ExternalProtocolDialog::GetApplicationForProtocol(
+ const GURL& url) {
+ std::wstring url_spec = ASCIIToWide(url.possibly_invalid_spec());
std::wstring cmd_key_path =
- ASCIIToWide(url_.scheme() + "\\shell\\open\\command");
+ ASCIIToWide(url.scheme() + "\\shell\\open\\command");
RegKey cmd_key(HKEY_CLASSES_ROOT, cmd_key_path.c_str(), KEY_READ);
size_t split_offset = url_spec.find(L':');
if (split_offset == std::wstring::npos)
diff --git a/chrome/browser/external_protocol_dialog.h b/chrome/browser/external_protocol_dialog.h
index 4d5868e..0c48e34 100644
--- a/chrome/browser/external_protocol_dialog.h
+++ b/chrome/browser/external_protocol_dialog.h
@@ -15,12 +15,23 @@ class ExternalProtocolDialog : public ChromeViews::DialogDelegate {
public:
// Creates and runs a External Protocol dialog box.
// |url| - The url of the request.
+ // |command| - the command that ShellExecute will run.
// |render_process_host_id| and |routing_id| are used by
// tab_util::GetTabContentsByID to aquire the tab contents associated with
// this dialog.
+ // NOTE: There is a race between the Time of Check and the Time Of Use for
+ // the command line. Since the caller (web page) does not have access
+ // to change the command line by itself, we do not do anything special
+ // to protect against this scenario.
static void RunExternalProtocolDialog(const GURL& url,
+ const std::wstring& command,
int render_process_host_id,
int routing_id);
+
+ // Returns the path of the application to be launched given the protocol
+ // of the requested url. Returns an empty string on failure.
+ static std::wstring GetApplicationForProtocol(const GURL& url);
+
virtual ~ExternalProtocolDialog();
// ChromeViews::DialogDelegate Methods:
@@ -39,11 +50,8 @@ class ExternalProtocolDialog : public ChromeViews::DialogDelegate {
private:
// RunExternalProtocolDialog calls this private constructor.
ExternalProtocolDialog(TabContents* tab_contents,
- const GURL& url);
-
- // Returns the path of the application to be launched given the protocol
- // of the requested url. Returns an empty string on failure.
- std::wstring GetApplicationForProtocol();
+ const GURL& url,
+ const std::wstring& command);
// The message box view whose commands we handle.
MessageBoxView* message_box_view_;
diff --git a/chrome/browser/external_protocol_handler.cc b/chrome/browser/external_protocol_handler.cc
index 5467e3a..3860f5f 100644
--- a/chrome/browser/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol_handler.cc
@@ -113,9 +113,17 @@ void ExternalProtocolHandler::LaunchUrl(const GURL& url,
return;
if (block_state == UNKNOWN) {
+ std::wstring command = ExternalProtocolDialog::GetApplicationForProtocol(
+ escaped_url);
+ if (command.empty()) {
+ // ShellExecute won't do anything. Don't bother warning the user.
+ return;
+ }
+
// Ask the user if they want to allow the protocol. This will call
// LaunchUrlWithoutSecurityCheck if the user decides to accept the protocol.
ExternalProtocolDialog::RunExternalProtocolDialog(escaped_url,
+ command,
render_process_host_id,
tab_contents_id);
return;
@@ -135,8 +143,6 @@ void ExternalProtocolHandler::LaunchUrl(const GURL& url,
// static
void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(const GURL& url) {
- DCHECK(g_browser_process->io_thread()->message_loop() ==
- MessageLoop::current());
// Quote the input scheme to be sure that the command does not have
// parameters unexpected by the external program. This url should already
// have been escaped.