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

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: 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
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..dd7f10b634880ff1ce40d2d12d8ae19b429938ca 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() {
sky 2011/09/28 22:58:04 What if the user minimizes the window when you hav
yzshen1 2011/09/29 20:41:04 Chrome will lose focus so it exits the mouse lock
- 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::HasMouseLockPermission() const {
+ return false;
+}
+
+void RenderWidgetHost::UnlockMouseIfNecessary() {
+ if (IsMouseLocked())
+ view_->UnlockMouse();
+}
+
bool RenderWidgetHost::IsMouseLocked() const {
return view_ ? view_->mouse_locked() : false;
}
@@ -1151,9 +1158,8 @@ 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 (!HasMouseLockPermission() || !view_ || !view_->HasFocus()||
+ !view_->LockMouse()) {
Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
} else {
Send(new ViewMsg_LockMouse_ACK(routing_id_, true));
@@ -1161,8 +1167,7 @@ void RenderWidgetHost::OnMsgLockMouse() {
}
void RenderWidgetHost::OnMsgUnlockMouse() {
- if (IsMouseLocked())
- view_->UnlockMouse();
+ UnlockMouseIfNecessary();
}
#if defined(OS_POSIX)

Powered by Google App Engine
This is Rietveld 408576698