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

Unified Diff: content/browser/renderer_host/render_widget_host.cc

Issue 8072011: Only allow to lock the mouse when the tab is in fullscreen mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make changes in response to review comments & sync. Created 9 years, 3 months 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 | « content/browser/renderer_host/render_widget_host.h ('k') | content/browser/tab_contents/tab_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host.cc
diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc
index 01077f770a631292037d2f0339ef4fcc7748da86..88a4f2e39a10a6b6b5f3aaff452f8d4b8e64e414 100644
--- a/content/browser/renderer_host/render_widget_host.cc
+++ b/content/browser/renderer_host/render_widget_host.cc
@@ -383,8 +383,7 @@ void RenderWidgetHost::Focus() {
}
void RenderWidgetHost::Blur() {
- if (IsMouseLocked())
- view_->UnlockMouse();
+ UnlockMouseIfNecessary();
Send(new ViewMsg_SetFocus(routing_id_, false));
}
@@ -398,8 +397,7 @@ void RenderWidgetHost::LostMouseLock() {
}
void RenderWidgetHost::ViewDestroyed() {
- if (IsMouseLocked())
- view_->UnlockMouse();
+ UnlockMouseIfNecessary();
// TODO(evanm): tracking this may no longer be necessary;
// eliminate this function if so.
@@ -801,6 +799,15 @@ void RenderWidgetHost::ImeCancelComposition() {
std::vector<WebKit::WebCompositionUnderline>(), 0, 0));
}
+bool RenderWidgetHost::CanLockMouse() const {
+ return false;
+}
+
+void RenderWidgetHost::UnlockMouseIfNecessary() {
+ if (IsMouseLocked())
+ view_->UnlockMouse();
+}
+
bool RenderWidgetHost::IsMouseLocked() const {
return view_ ? view_->mouse_locked() : false;
}
@@ -1151,9 +1158,7 @@ void RenderWidgetHost::OnMsgDidActivateAcceleratedCompositing(bool activated) {
}
void RenderWidgetHost::OnMsgLockMouse() {
- // TODO(yzshen): Only allow to lock the mouse when in fullscreen mode, and
- // make sure that the mouse is unlocked when leaving fullscreen mode.
- if (!view_ || !view_->HasFocus() || !view_->LockMouse()) {
+ if (!CanLockMouse() || !view_ || !view_->HasFocus()|| !view_->LockMouse()) {
Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
} else {
Send(new ViewMsg_LockMouse_ACK(routing_id_, true));
@@ -1161,8 +1166,7 @@ void RenderWidgetHost::OnMsgLockMouse() {
}
void RenderWidgetHost::OnMsgUnlockMouse() {
- if (IsMouseLocked())
- view_->UnlockMouse();
+ UnlockMouseIfNecessary();
}
#if defined(OS_POSIX)
« no previous file with comments | « content/browser/renderer_host/render_widget_host.h ('k') | content/browser/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698