summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/browser.cc4
-rw-r--r--chrome/browser/ui/browser.h3
-rw-r--r--chrome/browser/ui/browser_browsertest.cc14
-rw-r--r--chrome/browser/ui/fullscreen_controller.cc6
-rw-r--r--chrome/browser/ui/fullscreen_controller.h2
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc4
-rw-r--r--content/browser/renderer_host/render_view_host_impl.h2
-rw-r--r--content/browser/renderer_host/render_widget_host_impl.cc6
-rw-r--r--content/browser/renderer_host/render_widget_host_impl.h4
-rw-r--r--content/browser/web_contents/web_contents_impl.cc4
-rw-r--r--content/browser/web_contents/web_contents_impl.h2
-rw-r--r--content/common/view_messages.h3
-rw-r--r--content/public/browser/render_view_host_delegate.h2
-rw-r--r--content/public/browser/web_contents_delegate.h3
-rw-r--r--content/renderer/mouse_lock_dispatcher.cc8
15 files changed, 40 insertions, 27 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index b7dce022..01b5d69 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -4035,8 +4035,8 @@ void Browser::FindReply(WebContents* tab,
active_match_ordinal, final_update);
}
-void Browser::RequestToLockMouse(WebContents* tab) {
- fullscreen_controller_->RequestToLockMouse(tab);
+void Browser::RequestToLockMouse(WebContents* tab, bool user_gesture) {
+ fullscreen_controller_->RequestToLockMouse(tab, user_gesture);
}
void Browser::LostMouseLock() {
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 0eaa194..fc8490d 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -1062,7 +1062,8 @@ class Browser : public TabHandlerDelegate,
int active_match_ordinal,
bool final_update) OVERRIDE;
- virtual void RequestToLockMouse(content::WebContents* tab) OVERRIDE;
+ virtual void RequestToLockMouse(content::WebContents* tab,
+ bool user_gesture) OVERRIDE;
virtual void LostMouseLock() OVERRIDE;
// Overridden from CoreTabHelperDelegate:
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index 8e65ade..4ad632c 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -247,8 +247,8 @@ class BrowserTest : public ExtensionBrowserTest {
ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen);
}
- void RequestToLockMouse(content::WebContents* tab) {
- browser()->RequestToLockMouse(tab);
+ void RequestToLockMouse(content::WebContents* tab, bool user_gesture) {
+ browser()->RequestToLockMouse(tab, user_gesture);
}
void LostMouseLock() {
@@ -1028,7 +1028,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) {
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true));
// Request mouse lock and verify the bubble is waiting for user confirmation.
- RequestToLockMouse(fullscreen_tab);
+ RequestToLockMouse(fullscreen_tab, true);
ASSERT_TRUE(IsMouseLockPermissionRequested());
// Accept mouse lock and verify bubble no longer shows confirmation buttons.
@@ -1041,7 +1041,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) {
WebContents* tab = browser()->GetSelectedWebContents();
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
- RequestToLockMouse(tab);
+ RequestToLockMouse(tab, true);
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
@@ -1082,7 +1082,7 @@ void BrowserTest::TestFullscreenMouseLockContentSettings() {
// Validate that mouse lock defaults to asking permision.
ASSERT_FALSE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLockedOrPending());
- RequestToLockMouse(tab);
+ RequestToLockMouse(tab, true);
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_TRUE(IsMouseLockedOrPending());
LostMouseLock();
@@ -1096,7 +1096,7 @@ void BrowserTest::TestFullscreenMouseLockContentSettings() {
// Now, mouse lock should not prompt for permission.
ASSERT_FALSE(IsMouseLockedOrPending());
ASSERT_FALSE(IsMouseLockPermissionRequested());
- RequestToLockMouse(tab);
+ RequestToLockMouse(tab, true);
ASSERT_TRUE(IsMouseLockedOrPending());
ASSERT_FALSE(IsMouseLockPermissionRequested());
LostMouseLock();
@@ -1112,7 +1112,7 @@ void BrowserTest::TestFullscreenMouseLockContentSettings() {
// Now, mouse lock should not be pending.
ASSERT_FALSE(IsMouseLockedOrPending());
ASSERT_FALSE(IsMouseLockPermissionRequested());
- RequestToLockMouse(tab);
+ RequestToLockMouse(tab, true);
ASSERT_FALSE(IsMouseLockedOrPending());
ASSERT_FALSE(IsMouseLockPermissionRequested());
}
diff --git a/chrome/browser/ui/fullscreen_controller.cc b/chrome/browser/ui/fullscreen_controller.cc
index f0e3514..80aeaf0 100644
--- a/chrome/browser/ui/fullscreen_controller.cc
+++ b/chrome/browser/ui/fullscreen_controller.cc
@@ -59,7 +59,11 @@ bool FullscreenController::IsMouseLockedOrPending() const {
return mouse_lock_state_ != MOUSELOCK_NOT_REQUESTED;
}
-void FullscreenController::RequestToLockMouse(WebContents* tab) {
+void FullscreenController::RequestToLockMouse(WebContents* tab,
+ bool /* user_gesture */) {
+ // TODO(scheib) user_gesture required for Mouse Lock in Windowed Mode.
+ // See http://crbug.com/107013, which will land in multiple patches.
+
// Mouse Lock is only permitted when browser is in tab fullscreen.
if (!IsFullscreenForTabOrPending(tab)) {
tab->GotResponseToLockMouseRequest(false);
diff --git a/chrome/browser/ui/fullscreen_controller.h b/chrome/browser/ui/fullscreen_controller.h
index 35d09eb..f9d9fb9bb 100644
--- a/chrome/browser/ui/fullscreen_controller.h
+++ b/chrome/browser/ui/fullscreen_controller.h
@@ -55,7 +55,7 @@ class FullscreenController : public base::RefCounted<FullscreenController> {
bool IsMouseLockedOrPending() const;
// Requests.
- void RequestToLockMouse(content::WebContents* tab);
+ void RequestToLockMouse(content::WebContents* tab, bool user_gesture);
void ToggleFullscreenModeForTab(content::WebContents* tab,
bool enter_fullscreen);
#if defined(OS_MACOSX)
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index f39f457..6ebe0bc 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -1461,8 +1461,8 @@ void RenderViewHostImpl::NotifyRendererResponsive() {
delegate_->RendererResponsive(this);
}
-void RenderViewHostImpl::RequestToLockMouse() {
- delegate_->RequestToLockMouse();
+void RenderViewHostImpl::RequestToLockMouse(bool user_gesture) {
+ delegate_->RequestToLockMouse(user_gesture);
}
bool RenderViewHostImpl::IsFullscreen() const {
diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h
index 2e1a6dc..19eb9a8 100644
--- a/content/browser/renderer_host/render_view_host_impl.h
+++ b/content/browser/renderer_host/render_view_host_impl.h
@@ -419,7 +419,7 @@ class CONTENT_EXPORT RenderViewHostImpl
virtual void NotifyRendererUnresponsive() OVERRIDE;
virtual void NotifyRendererResponsive() OVERRIDE;
virtual void OnRenderAutoResized(const gfx::Size& size) OVERRIDE;
- virtual void RequestToLockMouse() OVERRIDE;
+ virtual void RequestToLockMouse(bool user_gesture) OVERRIDE;
virtual bool IsFullscreen() const OVERRIDE;
virtual void OnMsgFocus() OVERRIDE;
virtual void OnMsgBlur() OVERRIDE;
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 85c53c5..781eccb 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -1069,7 +1069,7 @@ gfx::Rect RenderWidgetHostImpl::GetRootWindowResizerRect() const {
return gfx::Rect();
}
-void RenderWidgetHostImpl::RequestToLockMouse() {
+void RenderWidgetHostImpl::RequestToLockMouse(bool /* user_gesture */) {
// Directly reject to lock the mouse. Subclass can override this method to
// decide whether to allow mouse lock or not.
GotResponseToLockMouseRequest(false);
@@ -1512,7 +1512,7 @@ void RenderWidgetHostImpl::OnMsgDidActivateAcceleratedCompositing(
view_->OnAcceleratedCompositingStateChange();
}
-void RenderWidgetHostImpl::OnMsgLockMouse() {
+void RenderWidgetHostImpl::OnMsgLockMouse(bool user_gesture) {
if (pending_mouse_lock_request_) {
Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
return;
@@ -1522,7 +1522,7 @@ void RenderWidgetHostImpl::OnMsgLockMouse() {
}
pending_mouse_lock_request_ = true;
- RequestToLockMouse();
+ RequestToLockMouse(user_gesture);
}
void RenderWidgetHostImpl::OnMsgUnlockMouse() {
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h
index 9a0e175..673f29f 100644
--- a/content/browser/renderer_host/render_widget_host_impl.h
+++ b/content/browser/renderer_host/render_widget_host_impl.h
@@ -419,7 +419,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost,
// to allow mouse lock.
// Once the request is approved or rejected, GotResponseToLockMouseRequest()
// will be called.
- virtual void RequestToLockMouse();
+ virtual void RequestToLockMouse(bool user_gesture);
void RejectMouseLockOrUnlockIfNecessary();
bool IsMouseLocked() const;
@@ -495,7 +495,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost,
void OnMsgDidActivateAcceleratedCompositing(bool activated);
- void OnMsgLockMouse();
+ void OnMsgLockMouse(bool user_gesture);
void OnMsgUnlockMouse();
#if defined(OS_POSIX) || defined(USE_AURA)
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 4085804..d31126b 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1005,9 +1005,9 @@ bool WebContentsImpl::IsFullscreenForCurrentTab() const {
return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false;
}
-void WebContentsImpl::RequestToLockMouse() {
+void WebContentsImpl::RequestToLockMouse(bool user_gesture) {
if (delegate_) {
- delegate_->RequestToLockMouse(this);
+ delegate_->RequestToLockMouse(this, user_gesture);
} else {
GotResponseToLockMouseRequest(false);
}
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 522af97..a2fcba7 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -334,7 +334,7 @@ class CONTENT_EXPORT WebContentsImpl
virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
- virtual void RequestToLockMouse() OVERRIDE;
+ virtual void RequestToLockMouse(bool user_gesture) OVERRIDE;
virtual void LostMouseLock() OVERRIDE;
// RenderViewHostManager::Delegate -------------------------------------------
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index 22a9404..8edcf91 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -1995,7 +1995,8 @@ IPC_MESSAGE_CONTROL1(ViewHostMsg_MediaLogEvent,
// Requests to lock the mouse. Will result in a ViewMsg_LockMouse_ACK message
// being sent back.
-IPC_MESSAGE_ROUTED0(ViewHostMsg_LockMouse)
+IPC_MESSAGE_ROUTED1(ViewHostMsg_LockMouse,
+ bool /* user_gesture */)
// Requests to unlock the mouse. A ViewMsg_MouseLockLost message will be sent
// whenever the mouse is unlocked (which may or may not be caused by
diff --git a/content/public/browser/render_view_host_delegate.h b/content/public/browser/render_view_host_delegate.h
index 0e19323..31251b5 100644
--- a/content/public/browser/render_view_host_delegate.h
+++ b/content/public/browser/render_view_host_delegate.h
@@ -397,7 +397,7 @@ class CONTENT_EXPORT RenderViewHostDelegate : public IPC::Channel::Listener {
// Requests to lock the mouse. Once the request is approved or rejected,
// GotResponseToLockMouseRequest() will be called on the requesting render
// view host.
- virtual void RequestToLockMouse() {}
+ virtual void RequestToLockMouse(bool user_gesture) {}
// Notification that the view has lost the mouse lock.
virtual void LostMouseLock() {}
diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h
index 569d1ec..ecfdb7a 100644
--- a/content/public/browser/web_contents_delegate.h
+++ b/content/public/browser/web_contents_delegate.h
@@ -391,7 +391,8 @@ class CONTENT_EXPORT WebContentsDelegate {
// Requests to lock the mouse. Once the request is approved or rejected,
// GotResponseToLockMouseRequest() will be called on the requesting tab
// contents.
- virtual void RequestToLockMouse(WebContents* web_contents) {}
+ virtual void RequestToLockMouse(WebContents* web_contents,
+ bool user_gesture) {}
// Notification that the page has lost the mouse lock.
virtual void LostMouseLock() {}
diff --git a/content/renderer/mouse_lock_dispatcher.cc b/content/renderer/mouse_lock_dispatcher.cc
index 41ed654..886067c 100644
--- a/content/renderer/mouse_lock_dispatcher.cc
+++ b/content/renderer/mouse_lock_dispatcher.cc
@@ -6,6 +6,7 @@
#include "content/common/view_messages.h"
#include "content/renderer/render_view_impl.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
@@ -28,7 +29,12 @@ bool MouseLockDispatcher::LockMouse(LockTarget* target) {
pending_lock_request_ = true;
target_ = target;
- Send(new ViewHostMsg_LockMouse(routing_id()));
+ bool user_gesture =
+ render_view_impl_->webview() &&
+ render_view_impl_->webview()->mainFrame() &&
+ render_view_impl_->webview()->mainFrame()->isProcessingUserGesture();
+
+ Send(new ViewHostMsg_LockMouse(routing_id(), user_gesture));
return true;
}