summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-28 18:35:24 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-28 18:35:24 +0000
commit14ce83fb15ddb2dbd3c8a6d81a78435209359ff8 (patch)
treeba450456add7d7a46378aa8ba61438cbbbff7c3b /chrome
parentbe8d1790c1e2bfbc2d21004415ea0cfe36e76eb2 (diff)
downloadchromium_src-14ce83fb15ddb2dbd3c8a6d81a78435209359ff8.zip
chromium_src-14ce83fb15ddb2dbd3c8a6d81a78435209359ff8.tar.gz
chromium_src-14ce83fb15ddb2dbd3c8a6d81a78435209359ff8.tar.bz2
Generalize the code that checks for user actions in the render view to work on all platforms.
Also, on linux, assume the user denies every download which we would have prompted him with. BUG=12709 TEST=windows is still carpet-bombing resilient and linux can download from the same page more than once. Review URL: http://codereview.chromium.org/113925 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_process.cc4
-rw-r--r--chrome/browser/browser_process.h2
-rw-r--r--chrome/browser/download/download_request_manager.cc9
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc4
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h4
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc4
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h10
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc7
-rw-r--r--chrome/browser/tab_contents/tab_contents.h2
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_win.cc4
11 files changed, 28 insertions, 24 deletions
diff --git a/chrome/browser/browser_process.cc b/chrome/browser/browser_process.cc
index 8f29cbc..a646a9e 100644
--- a/chrome/browser/browser_process.cc
+++ b/chrome/browser/browser_process.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,7 +6,7 @@
BrowserProcess* g_browser_process = NULL;
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_LINUX)
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index 7e1a46f..86cee4e 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -130,7 +130,7 @@ class BrowserProcess {
virtual MemoryModel memory_model() = 0;
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_LINUX)
DownloadRequestManager* download_request_manager();
#endif
diff --git a/chrome/browser/download/download_request_manager.cc b/chrome/browser/download/download_request_manager.cc
index 4364700..d779b66 100644
--- a/chrome/browser/download/download_request_manager.cc
+++ b/chrome/browser/download/download_request_manager.cc
@@ -66,10 +66,15 @@ void DownloadRequestManager::TabDownloadState::PromptUserForDownload(
if (is_showing_prompt())
return; // Already showing prompt.
- if (DownloadRequestManager::delegate_)
+ if (DownloadRequestManager::delegate_) {
NotifyCallbacks(DownloadRequestManager::delegate_->ShouldAllowDownload());
- else
+ } else {
dialog_delegate_ = DownloadRequestDialogDelegate::Create(tab, this);
+ // TODO(estade): the dialog delegate isn't yet implemented on linux. Just
+ // assume we shouldn't allow the download.
+ if (dialog_delegate_ == NULL)
+ NotifyCallbacks(false);
+ }
}
void DownloadRequestManager::TabDownloadState::Cancel() {
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 44c0023..421615f 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1277,8 +1277,8 @@ void RenderViewHost::UnhandledKeyboardEvent(
}
}
-void RenderViewHost::OnEnterOrSpace() {
- delegate_->OnEnterOrSpace();
+void RenderViewHost::OnUserGesture() {
+ delegate_->OnUserGesture();
}
void RenderViewHost::OnMissingPluginStatus(int status) {
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 9c08f11..c28af30 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -434,7 +434,7 @@ class RenderViewHost : public RenderWidgetHost {
protected:
// RenderWidgetHost protected overrides.
virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event);
- virtual void OnEnterOrSpace();
+ virtual void OnUserGesture();
virtual void NotifyRendererUnresponsive();
virtual void NotifyRendererResponsive();
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index 75a80d4..7668b9c 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -421,10 +421,10 @@ class RenderViewHostDelegate {
int32 page_id,
const webkit_glue::WebApplicationInfo& app_info) { }
- // Notification the user has pressed enter or space while focus was on the
+ // Notification the user has made a gesture while focus was on the
// page. This is used to avoid uninitiated user downloads (aka carpet
// bombing), see DownloadRequestManager for details.
- virtual void OnEnterOrSpace() { }
+ virtual void OnUserGesture() { }
// If this view is used to host an external tab container.
virtual bool IsExternalTabContainer() const { return false; }
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index 9e196e9..36e6085 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -301,6 +301,8 @@ void RenderWidgetHost::ForwardMouseEvent(const WebMouseEvent& mouse_event) {
return;
}
mouse_move_pending_ = true;
+ } else if (mouse_event.type == WebInputEvent::MouseDown) {
+ OnUserGesture();
}
ForwardInputEvent(mouse_event, sizeof(WebMouseEvent));
@@ -316,7 +318,7 @@ void RenderWidgetHost::ForwardKeyboardEvent(
if (key_event.type == WebKeyboardEvent::Char &&
(key_event.windowsKeyCode == base::VKEY_RETURN ||
key_event.windowsKeyCode == base::VKEY_SPACE)) {
- OnEnterOrSpace();
+ OnUserGesture();
}
// Double check the type to make sure caller hasn't sent us nonsense that
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index 8e12099..8936e48 100644
--- a/chrome/browser/renderer_host/render_widget_host.h
+++ b/chrome/browser/renderer_host/render_widget_host.h
@@ -275,10 +275,12 @@ class RenderWidgetHost : public IPC::Channel::Listener {
// overridden by RenderView to send upwards to its delegate.
virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {}
- // Notification that the user pressed the enter key or the spacebar. The
- // render view host overrides this to forward the information to its delegate
- // (see corresponding function in RenderViewHostDelegate).
- virtual void OnEnterOrSpace() {}
+ // Notification that the user has made some kind of input that could
+ // perform an action. The render view host overrides this to forward the
+ // information to its delegate (see corresponding function in
+ // RenderViewHostDelegate). The gestures that count are 1) any mouse down
+ // event and 2) enter or space key presses.
+ virtual void OnUserGesture() {}
// Callbacks for notification when the renderer becomes unresponsive to user
// input events, and subsequently responsive again. RenderViewHost overrides
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 0b27087..e3a0bb6 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2299,10 +2299,9 @@ void TabContents::OnDidGetApplicationInfo(
&GearsCreateShortcutCallbackFunctor::Run));
}
-void TabContents::OnEnterOrSpace() {
- // See comment in RenderViewHostDelegate::OnEnterOrSpace as to why we do this.
-#if defined(OS_WIN)
- // TODO(port): this is stubbed in BrowserProcess
+void TabContents::OnUserGesture() {
+ // See comment in RenderViewHostDelegate::OnUserGesture as to why we do this.
+#if defined(OS_WIN) || defined(OS_LINUX)
DownloadRequestManager* drm = g_browser_process->download_request_manager();
if (drm)
drm->OnUserGesture(this);
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index a77e2cd..7e3a70f 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -841,7 +841,7 @@ class TabContents : public PageNavigator,
virtual void OnDidGetApplicationInfo(
int32 page_id,
const webkit_glue::WebApplicationInfo& info);
- virtual void OnEnterOrSpace();
+ virtual void OnUserGesture();
virtual void OnFindReply(int request_id,
int number_of_matches,
const gfx::Rect& selection_rect,
diff --git a/chrome/browser/tab_contents/tab_contents_view_win.cc b/chrome/browser/tab_contents/tab_contents_view_win.cc
index f254820..fac170d 100644
--- a/chrome/browser/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_win.cc
@@ -415,10 +415,6 @@ LRESULT TabContentsViewWin::OnMouseRange(UINT msg,
// Make sure this TabContents is activated when it is clicked on.
if (tab_contents()->delegate())
tab_contents()->delegate()->ActivateContents(tab_contents());
- DownloadRequestManager* drm =
- g_browser_process->download_request_manager();
- if (drm)
- drm->OnUserGesture(tab_contents());
break;
}
case WM_MOUSEMOVE: