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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host.h" 5 #include "content/browser/renderer_host/render_widget_host.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 376
377 void RenderWidgetHost::GotFocus() { 377 void RenderWidgetHost::GotFocus() {
378 Focus(); 378 Focus();
379 } 379 }
380 380
381 void RenderWidgetHost::Focus() { 381 void RenderWidgetHost::Focus() {
382 Send(new ViewMsg_SetFocus(routing_id_, true)); 382 Send(new ViewMsg_SetFocus(routing_id_, true));
383 } 383 }
384 384
385 void RenderWidgetHost::Blur() { 385 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
386 if (IsMouseLocked()) 386 UnlockMouseIfNecessary();
387 view_->UnlockMouse();
388 387
389 Send(new ViewMsg_SetFocus(routing_id_, false)); 388 Send(new ViewMsg_SetFocus(routing_id_, false));
390 } 389 }
391 390
392 void RenderWidgetHost::LostCapture() { 391 void RenderWidgetHost::LostCapture() {
393 Send(new ViewMsg_MouseCaptureLost(routing_id_)); 392 Send(new ViewMsg_MouseCaptureLost(routing_id_));
394 } 393 }
395 394
396 void RenderWidgetHost::LostMouseLock() { 395 void RenderWidgetHost::LostMouseLock() {
397 Send(new ViewMsg_MouseLockLost(routing_id_)); 396 Send(new ViewMsg_MouseLockLost(routing_id_));
398 } 397 }
399 398
400 void RenderWidgetHost::ViewDestroyed() { 399 void RenderWidgetHost::ViewDestroyed() {
401 if (IsMouseLocked()) 400 UnlockMouseIfNecessary();
402 view_->UnlockMouse();
403 401
404 // TODO(evanm): tracking this may no longer be necessary; 402 // TODO(evanm): tracking this may no longer be necessary;
405 // eliminate this function if so. 403 // eliminate this function if so.
406 SetView(NULL); 404 SetView(NULL);
407 } 405 }
408 406
409 void RenderWidgetHost::SetIsLoading(bool is_loading) { 407 void RenderWidgetHost::SetIsLoading(bool is_loading) {
410 is_loading_ = is_loading; 408 is_loading_ = is_loading;
411 if (!view_) 409 if (!view_)
412 return; 410 return;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 792
795 void RenderWidgetHost::ImeConfirmComposition() { 793 void RenderWidgetHost::ImeConfirmComposition() {
796 Send(new ViewMsg_ImeConfirmComposition(routing_id(), string16())); 794 Send(new ViewMsg_ImeConfirmComposition(routing_id(), string16()));
797 } 795 }
798 796
799 void RenderWidgetHost::ImeCancelComposition() { 797 void RenderWidgetHost::ImeCancelComposition() {
800 Send(new ViewMsg_ImeSetComposition(routing_id(), string16(), 798 Send(new ViewMsg_ImeSetComposition(routing_id(), string16(),
801 std::vector<WebKit::WebCompositionUnderline>(), 0, 0)); 799 std::vector<WebKit::WebCompositionUnderline>(), 0, 0));
802 } 800 }
803 801
802 bool RenderWidgetHost::HasMouseLockPermission() const {
803 return false;
804 }
805
806 void RenderWidgetHost::UnlockMouseIfNecessary() {
807 if (IsMouseLocked())
808 view_->UnlockMouse();
809 }
810
804 bool RenderWidgetHost::IsMouseLocked() const { 811 bool RenderWidgetHost::IsMouseLocked() const {
805 return view_ ? view_->mouse_locked() : false; 812 return view_ ? view_->mouse_locked() : false;
806 } 813 }
807 814
808 void RenderWidgetHost::Destroy() { 815 void RenderWidgetHost::Destroy() {
809 NotificationService::current()->Notify( 816 NotificationService::current()->Notify(
810 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 817 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
811 Source<RenderWidgetHost>(this), 818 Source<RenderWidgetHost>(this),
812 NotificationService::NoDetails()); 819 NotificationService::NoDetails());
813 820
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 #elif defined(OS_WIN) 1151 #elif defined(OS_WIN)
1145 if (view_) 1152 if (view_)
1146 view_->ShowCompositorHostWindow(is_accelerated_compositing_active_); 1153 view_->ShowCompositorHostWindow(is_accelerated_compositing_active_);
1147 #elif defined(TOOLKIT_USES_GTK) 1154 #elif defined(TOOLKIT_USES_GTK)
1148 if (view_) 1155 if (view_)
1149 view_->AcceleratedCompositingActivated(activated); 1156 view_->AcceleratedCompositingActivated(activated);
1150 #endif 1157 #endif
1151 } 1158 }
1152 1159
1153 void RenderWidgetHost::OnMsgLockMouse() { 1160 void RenderWidgetHost::OnMsgLockMouse() {
1154 // TODO(yzshen): Only allow to lock the mouse when in fullscreen mode, and 1161 if (!HasMouseLockPermission() || !view_ || !view_->HasFocus()||
1155 // make sure that the mouse is unlocked when leaving fullscreen mode. 1162 !view_->LockMouse()) {
1156 if (!view_ || !view_->HasFocus() || !view_->LockMouse()) {
1157 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); 1163 Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
1158 } else { 1164 } else {
1159 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); 1165 Send(new ViewMsg_LockMouse_ACK(routing_id_, true));
1160 } 1166 }
1161 } 1167 }
1162 1168
1163 void RenderWidgetHost::OnMsgUnlockMouse() { 1169 void RenderWidgetHost::OnMsgUnlockMouse() {
1164 if (IsMouseLocked()) 1170 UnlockMouseIfNecessary();
1165 view_->UnlockMouse();
1166 } 1171 }
1167 1172
1168 #if defined(OS_POSIX) 1173 #if defined(OS_POSIX)
1169 void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId window_id, 1174 void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId window_id,
1170 WebKit::WebScreenInfo* results) { 1175 WebKit::WebScreenInfo* results) {
1171 if (view_) 1176 if (view_)
1172 view_->GetScreenInfo(results); 1177 view_->GetScreenInfo(results);
1173 else 1178 else
1174 RenderWidgetHostView::GetDefaultScreenInfo(results); 1179 RenderWidgetHostView::GetDefaultScreenInfo(results);
1175 } 1180 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 void RenderWidgetHost::Delete() { 1386 void RenderWidgetHost::Delete() {
1382 Send(new ViewMsg_Delete(routing_id())); 1387 Send(new ViewMsg_Delete(routing_id()));
1383 UserMetrics::RecordAction(UserMetricsAction("DeleteSelection")); 1388 UserMetrics::RecordAction(UserMetricsAction("DeleteSelection"));
1384 } 1389 }
1385 1390
1386 void RenderWidgetHost::SelectAll() { 1391 void RenderWidgetHost::SelectAll() {
1387 Send(new ViewMsg_SelectAll(routing_id())); 1392 Send(new ViewMsg_SelectAll(routing_id()));
1388 UserMetrics::RecordAction(UserMetricsAction("SelectAll")); 1393 UserMetrics::RecordAction(UserMetricsAction("SelectAll"));
1389 } 1394 }
1390 1395
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698