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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 1410313006: Separate RenderViewHost from RenderWidgetHost, part 5: move calls to the RenderWidgetHostDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 // deal as RenderWidget::WasShown delays updating, so that the resize from 566 // deal as RenderWidget::WasShown delays updating, so that the resize from
567 // WasResized is usually processed before the renderer is painted. 567 // WasResized is usually processed before the renderer is painted.
568 WasResized(); 568 WasResized();
569 } 569 }
570 570
571 bool RenderWidgetHostImpl::GetResizeParams( 571 bool RenderWidgetHostImpl::GetResizeParams(
572 ViewMsg_Resize_Params* resize_params) { 572 ViewMsg_Resize_Params* resize_params) {
573 *resize_params = ViewMsg_Resize_Params(); 573 *resize_params = ViewMsg_Resize_Params();
574 574
575 GetWebScreenInfo(&resize_params->screen_info); 575 GetWebScreenInfo(&resize_params->screen_info);
576 resize_params->resizer_rect = GetRootWindowResizerRect(); 576 if (delegate_)
577 resize_params->resizer_rect = delegate_->GetRootWindowResizerRect(this);
577 578
578 if (view_) { 579 if (view_) {
579 resize_params->new_size = view_->GetRequestedRendererSize(); 580 resize_params->new_size = view_->GetRequestedRendererSize();
580 resize_params->physical_backing_size = view_->GetPhysicalBackingSize(); 581 resize_params->physical_backing_size = view_->GetPhysicalBackingSize();
581 resize_params->top_controls_height = view_->GetTopControlsHeight(); 582 resize_params->top_controls_height = view_->GetTopControlsHeight();
582 resize_params->top_controls_shrink_blink_size = 583 resize_params->top_controls_shrink_blink_size =
583 view_->DoTopControlsShrinkBlinkSize(); 584 view_->DoTopControlsShrinkBlinkSize();
584 resize_params->visible_viewport_size = view_->GetVisibleViewportSize(); 585 resize_params->visible_viewport_size = view_->GetVisibleViewportSize();
585 resize_params->is_fullscreen_granted = IsFullscreenGranted(); 586 resize_params->is_fullscreen_granted = IsFullscreenGranted();
586 resize_params->display_mode = GetDisplayMode(); 587 resize_params->display_mode = GetDisplayMode();
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 // Some keypresses that are accepted by the listener might have follow up 1098 // Some keypresses that are accepted by the listener might have follow up
1098 // char events, which should be ignored. 1099 // char events, which should be ignored.
1099 if (key_event.type == WebKeyboardEvent::RawKeyDown) 1100 if (key_event.type == WebKeyboardEvent::RawKeyDown)
1100 suppress_next_char_events_ = true; 1101 suppress_next_char_events_ = true;
1101 return; 1102 return;
1102 } 1103 }
1103 1104
1104 if (key_event.type == WebKeyboardEvent::Char && 1105 if (key_event.type == WebKeyboardEvent::Char &&
1105 (key_event.windowsKeyCode == ui::VKEY_RETURN || 1106 (key_event.windowsKeyCode == ui::VKEY_RETURN ||
1106 key_event.windowsKeyCode == ui::VKEY_SPACE)) { 1107 key_event.windowsKeyCode == ui::VKEY_SPACE)) {
1107 OnUserGesture(); 1108 if (delegate_)
1109 delegate_->OnUserGesture(this);
1108 } 1110 }
1109 1111
1110 // Double check the type to make sure caller hasn't sent us nonsense that 1112 // Double check the type to make sure caller hasn't sent us nonsense that
1111 // will mess up our key queue. 1113 // will mess up our key queue.
1112 if (!WebInputEvent::isKeyboardEventType(key_event.type)) 1114 if (!WebInputEvent::isKeyboardEventType(key_event.type))
1113 return; 1115 return;
1114 1116
1115 if (suppress_next_char_events_) { 1117 if (suppress_next_char_events_) {
1116 // If preceding RawKeyDown event was handled by the browser, then we need 1118 // If preceding RawKeyDown event was handled by the browser, then we need
1117 // suppress all Char events generated by it. Please note that, one 1119 // suppress all Char events generated by it. Please note that, one
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 bool keep_selection) { 1370 bool keep_selection) {
1369 Send(new InputMsg_ImeConfirmComposition( 1371 Send(new InputMsg_ImeConfirmComposition(
1370 GetRoutingID(), text, replacement_range, keep_selection)); 1372 GetRoutingID(), text, replacement_range, keep_selection));
1371 } 1373 }
1372 1374
1373 void RenderWidgetHostImpl::ImeCancelComposition() { 1375 void RenderWidgetHostImpl::ImeCancelComposition() {
1374 Send(new InputMsg_ImeSetComposition(GetRoutingID(), base::string16(), 1376 Send(new InputMsg_ImeSetComposition(GetRoutingID(), base::string16(),
1375 std::vector<blink::WebCompositionUnderline>(), 0, 0)); 1377 std::vector<blink::WebCompositionUnderline>(), 0, 0));
1376 } 1378 }
1377 1379
1378 gfx::Rect RenderWidgetHostImpl::GetRootWindowResizerRect() const {
1379 return gfx::Rect();
1380 }
1381
1382 void RenderWidgetHostImpl::RequestToLockMouse(bool user_gesture,
1383 bool last_unlocked_by_target) {
1384 // Directly reject to lock the mouse. Subclass can override this method to
1385 // decide whether to allow mouse lock or not.
1386 GotResponseToLockMouseRequest(false);
1387 }
1388
1389 void RenderWidgetHostImpl::RejectMouseLockOrUnlockIfNecessary() { 1380 void RenderWidgetHostImpl::RejectMouseLockOrUnlockIfNecessary() {
1390 DCHECK(!pending_mouse_lock_request_ || !IsMouseLocked()); 1381 DCHECK(!pending_mouse_lock_request_ || !IsMouseLocked());
1391 if (pending_mouse_lock_request_) { 1382 if (pending_mouse_lock_request_) {
1392 pending_mouse_lock_request_ = false; 1383 pending_mouse_lock_request_ = false;
1393 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); 1384 Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
1394 } else if (IsMouseLocked()) { 1385 } else if (IsMouseLocked()) {
1395 view_->UnlockMouse(); 1386 view_->UnlockMouse();
1396 } 1387 }
1397 } 1388 }
1398 1389
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 1424
1434 delete this; 1425 delete this;
1435 } 1426 }
1436 1427
1437 void RenderWidgetHostImpl::RendererIsUnresponsive() { 1428 void RenderWidgetHostImpl::RendererIsUnresponsive() {
1438 NotificationService::current()->Notify( 1429 NotificationService::current()->Notify(
1439 NOTIFICATION_RENDER_WIDGET_HOST_HANG, 1430 NOTIFICATION_RENDER_WIDGET_HOST_HANG,
1440 Source<RenderWidgetHost>(this), 1431 Source<RenderWidgetHost>(this),
1441 NotificationService::NoDetails()); 1432 NotificationService::NoDetails());
1442 is_unresponsive_ = true; 1433 is_unresponsive_ = true;
1443 NotifyRendererUnresponsive(); 1434 if (delegate_)
1435 delegate_->RendererUnresponsive(this);
1444 } 1436 }
1445 1437
1446 void RenderWidgetHostImpl::RendererIsResponsive() { 1438 void RenderWidgetHostImpl::RendererIsResponsive() {
1447 if (is_unresponsive_) { 1439 if (is_unresponsive_) {
1448 is_unresponsive_ = false; 1440 is_unresponsive_ = false;
1449 NotifyRendererResponsive(); 1441 if (delegate_)
1442 delegate_->RendererResponsive(this);
1450 } 1443 }
1451 } 1444 }
1452 1445
1453 void RenderWidgetHostImpl::ClearDisplayedGraphics() { 1446 void RenderWidgetHostImpl::ClearDisplayedGraphics() {
1454 NotifyNewContentRenderingTimeoutForTesting(); 1447 NotifyNewContentRenderingTimeoutForTesting();
1455 if (view_) 1448 if (view_)
1456 view_->ClearCompositorFrame(); 1449 view_->ClearCompositorFrame();
1457 } 1450 }
1458 1451
1459 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { 1452 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 if (IsMouseLocked()) { 1730 if (IsMouseLocked()) {
1738 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); 1731 Send(new ViewMsg_LockMouse_ACK(routing_id_, true));
1739 return; 1732 return;
1740 } 1733 }
1741 1734
1742 pending_mouse_lock_request_ = true; 1735 pending_mouse_lock_request_ = true;
1743 if (privileged && allow_privileged_mouse_lock_) { 1736 if (privileged && allow_privileged_mouse_lock_) {
1744 // Directly approve to lock the mouse. 1737 // Directly approve to lock the mouse.
1745 GotResponseToLockMouseRequest(true); 1738 GotResponseToLockMouseRequest(true);
1746 } else { 1739 } else {
1747 RequestToLockMouse(user_gesture, last_unlocked_by_target); 1740 if (delegate_) {
1741 delegate_->RequestToLockMouse(this, user_gesture,
1742 last_unlocked_by_target);
1743 return;
1744 }
1745 // If there's no delegate, just reject it.
1746 GotResponseToLockMouseRequest(false);
1748 } 1747 }
1749 } 1748 }
1750 1749
1751 void RenderWidgetHostImpl::OnUnlockMouse() { 1750 void RenderWidgetHostImpl::OnUnlockMouse() {
1752 RejectMouseLockOrUnlockIfNecessary(); 1751 RejectMouseLockOrUnlockIfNecessary();
1753 } 1752 }
1754 1753
1755 void RenderWidgetHostImpl::OnShowDisambiguationPopup( 1754 void RenderWidgetHostImpl::OnShowDisambiguationPopup(
1756 const gfx::Rect& rect_pixels, 1755 const gfx::Rect& rect_pixels,
1757 const gfx::Size& size, 1756 const gfx::Size& size,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 // events are being ignored in order to keep the renderer from getting 1852 // events are being ignored in order to keep the renderer from getting
1854 // confused about how many touches are active. 1853 // confused about how many touches are active.
1855 if (IgnoreInputEvents() && event.type != WebInputEvent::TouchCancel) 1854 if (IgnoreInputEvents() && event.type != WebInputEvent::TouchCancel)
1856 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; 1855 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
1857 1856
1858 if (!process_->HasConnection()) 1857 if (!process_->HasConnection())
1859 return INPUT_EVENT_ACK_STATE_UNKNOWN; 1858 return INPUT_EVENT_ACK_STATE_UNKNOWN;
1860 1859
1861 if (event.type == WebInputEvent::MouseDown || 1860 if (event.type == WebInputEvent::MouseDown ||
1862 event.type == WebInputEvent::GestureTapDown) { 1861 event.type == WebInputEvent::GestureTapDown) {
1863 OnUserGesture(); 1862 if (delegate_)
1863 delegate_->OnUserGesture(this);
1864 } 1864 }
1865 1865
1866 if (delegate_) { 1866 if (delegate_) {
1867 if (event.type == WebInputEvent::MouseDown || 1867 if (event.type == WebInputEvent::MouseDown ||
1868 event.type == WebInputEvent::GestureTapDown || 1868 event.type == WebInputEvent::GestureTapDown ||
1869 event.type == WebInputEvent::RawKeyDown) { 1869 event.type == WebInputEvent::RawKeyDown) {
1870 delegate_->OnUserInteraction(event.type); 1870 delegate_->OnUserInteraction(event.type);
1871 } else if (event.type == WebInputEvent::MouseWheel) { 1871 } else if (event.type == WebInputEvent::MouseWheel) {
1872 if (mouse_wheel_coalesce_timer_->Elapsed().InSecondsF() > 1872 if (mouse_wheel_coalesce_timer_->Elapsed().InSecondsF() >
1873 kMouseWheelCoalesceIntervalInSeconds) { 1873 kMouseWheelCoalesceIntervalInSeconds) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 1994
1995 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( 1995 void RenderWidgetHostImpl::OnSyntheticGestureCompleted(
1996 SyntheticGesture::Result result) { 1996 SyntheticGesture::Result result) {
1997 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); 1997 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID()));
1998 } 1998 }
1999 1999
2000 bool RenderWidgetHostImpl::IgnoreInputEvents() const { 2000 bool RenderWidgetHostImpl::IgnoreInputEvents() const {
2001 return ignore_input_events_ || process_->IgnoreInputEvents(); 2001 return ignore_input_events_ || process_->IgnoreInputEvents();
2002 } 2002 }
2003 2003
2004 void RenderWidgetHostImpl::StartUserGesture() {
2005 OnUserGesture();
2006 }
2007
2008 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) { 2004 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) {
2009 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); 2005 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque));
2010 } 2006 }
2011 2007
2012 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( 2008 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent(
2013 const std::vector<EditCommand>& commands) { 2009 const std::vector<EditCommand>& commands) {
2014 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); 2010 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands));
2015 } 2011 }
2016 2012
2017 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command, 2013 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 2074
2079 void RenderWidgetHostImpl::DelayedAutoResized() { 2075 void RenderWidgetHostImpl::DelayedAutoResized() {
2080 gfx::Size new_size = new_auto_size_; 2076 gfx::Size new_size = new_auto_size_;
2081 // Clear the new_auto_size_ since the empty value is used as a flag to 2077 // Clear the new_auto_size_ since the empty value is used as a flag to
2082 // indicate that no callback is in progress (i.e. without this line 2078 // indicate that no callback is in progress (i.e. without this line
2083 // DelayedAutoResized will not get called again). 2079 // DelayedAutoResized will not get called again).
2084 new_auto_size_.SetSize(0, 0); 2080 new_auto_size_.SetSize(0, 0);
2085 if (!auto_resize_enabled_) 2081 if (!auto_resize_enabled_)
2086 return; 2082 return;
2087 2083
2088 OnRenderAutoResized(new_size); 2084 if (delegate_)
2085 delegate_->ResizeDueToAutoResize(this, new_size);
2089 } 2086 }
2090 2087
2091 void RenderWidgetHostImpl::DetachDelegate() { 2088 void RenderWidgetHostImpl::DetachDelegate() {
2092 delegate_ = NULL; 2089 delegate_ = NULL;
2093 } 2090 }
2094 2091
2095 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { 2092 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) {
2096 ui::LatencyInfo::LatencyComponent window_snapshot_component; 2093 ui::LatencyInfo::LatencyComponent window_snapshot_component;
2097 if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, 2094 if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT,
2098 GetLatencyComponentId(), 2095 GetLatencyComponentId(),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 } 2203 }
2207 2204
2208 #if defined(OS_WIN) 2205 #if defined(OS_WIN)
2209 gfx::NativeViewAccessible 2206 gfx::NativeViewAccessible
2210 RenderWidgetHostImpl::GetParentNativeViewAccessible() { 2207 RenderWidgetHostImpl::GetParentNativeViewAccessible() {
2211 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; 2208 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL;
2212 } 2209 }
2213 #endif 2210 #endif
2214 2211
2215 } // namespace content 2212 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698