OLD | NEW |
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() { |
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 Loading... |
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::CanLockMouse() 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 Loading... |
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 (!CanLockMouse() || !view_ || !view_->HasFocus()|| !view_->LockMouse()) { |
1155 // make sure that the mouse is unlocked when leaving fullscreen mode. | |
1156 if (!view_ || !view_->HasFocus() || !view_->LockMouse()) { | |
1157 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); | 1162 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); |
1158 } else { | 1163 } else { |
1159 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); | 1164 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); |
1160 } | 1165 } |
1161 } | 1166 } |
1162 | 1167 |
1163 void RenderWidgetHost::OnMsgUnlockMouse() { | 1168 void RenderWidgetHost::OnMsgUnlockMouse() { |
1164 if (IsMouseLocked()) | 1169 UnlockMouseIfNecessary(); |
1165 view_->UnlockMouse(); | |
1166 } | 1170 } |
1167 | 1171 |
1168 #if defined(OS_POSIX) | 1172 #if defined(OS_POSIX) |
1169 void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId window_id, | 1173 void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId window_id, |
1170 WebKit::WebScreenInfo* results) { | 1174 WebKit::WebScreenInfo* results) { |
1171 if (view_) | 1175 if (view_) |
1172 view_->GetScreenInfo(results); | 1176 view_->GetScreenInfo(results); |
1173 else | 1177 else |
1174 RenderWidgetHostView::GetDefaultScreenInfo(results); | 1178 RenderWidgetHostView::GetDefaultScreenInfo(results); |
1175 } | 1179 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 void RenderWidgetHost::Delete() { | 1385 void RenderWidgetHost::Delete() { |
1382 Send(new ViewMsg_Delete(routing_id())); | 1386 Send(new ViewMsg_Delete(routing_id())); |
1383 UserMetrics::RecordAction(UserMetricsAction("DeleteSelection")); | 1387 UserMetrics::RecordAction(UserMetricsAction("DeleteSelection")); |
1384 } | 1388 } |
1385 | 1389 |
1386 void RenderWidgetHost::SelectAll() { | 1390 void RenderWidgetHost::SelectAll() { |
1387 Send(new ViewMsg_SelectAll(routing_id())); | 1391 Send(new ViewMsg_SelectAll(routing_id())); |
1388 UserMetrics::RecordAction(UserMetricsAction("SelectAll")); | 1392 UserMetrics::RecordAction(UserMetricsAction("SelectAll")); |
1389 } | 1393 } |
1390 | 1394 |
OLD | NEW |