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

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: no functionality change 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // deal as RenderWidget::WasShown delays updating, so that the resize from 558 // deal as RenderWidget::WasShown delays updating, so that the resize from
559 // WasResized is usually processed before the renderer is painted. 559 // WasResized is usually processed before the renderer is painted.
560 WasResized(); 560 WasResized();
561 } 561 }
562 562
563 bool RenderWidgetHostImpl::GetResizeParams( 563 bool RenderWidgetHostImpl::GetResizeParams(
564 ViewMsg_Resize_Params* resize_params) { 564 ViewMsg_Resize_Params* resize_params) {
565 *resize_params = ViewMsg_Resize_Params(); 565 *resize_params = ViewMsg_Resize_Params();
566 566
567 GetWebScreenInfo(&resize_params->screen_info); 567 GetWebScreenInfo(&resize_params->screen_info);
568 resize_params->resizer_rect = GetRootWindowResizerRect(); 568 if (delegate_)
569 resize_params->resizer_rect = delegate_->GetRootWindowResizerRect(this);
569 570
570 if (view_) { 571 if (view_) {
571 resize_params->new_size = view_->GetRequestedRendererSize(); 572 resize_params->new_size = view_->GetRequestedRendererSize();
572 resize_params->physical_backing_size = view_->GetPhysicalBackingSize(); 573 resize_params->physical_backing_size = view_->GetPhysicalBackingSize();
573 resize_params->top_controls_height = view_->GetTopControlsHeight(); 574 resize_params->top_controls_height = view_->GetTopControlsHeight();
574 resize_params->top_controls_shrink_blink_size = 575 resize_params->top_controls_shrink_blink_size =
575 view_->DoTopControlsShrinkBlinkSize(); 576 view_->DoTopControlsShrinkBlinkSize();
576 resize_params->visible_viewport_size = view_->GetVisibleViewportSize(); 577 resize_params->visible_viewport_size = view_->GetVisibleViewportSize();
577 resize_params->is_fullscreen_granted = IsFullscreenGranted(); 578 resize_params->is_fullscreen_granted = IsFullscreenGranted();
578 resize_params->display_mode = GetDisplayMode(); 579 resize_params->display_mode = GetDisplayMode();
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 // Some keypresses that are accepted by the listener might have follow up 1090 // Some keypresses that are accepted by the listener might have follow up
1090 // char events, which should be ignored. 1091 // char events, which should be ignored.
1091 if (key_event.type == WebKeyboardEvent::RawKeyDown) 1092 if (key_event.type == WebKeyboardEvent::RawKeyDown)
1092 suppress_next_char_events_ = true; 1093 suppress_next_char_events_ = true;
1093 return; 1094 return;
1094 } 1095 }
1095 1096
1096 if (key_event.type == WebKeyboardEvent::Char && 1097 if (key_event.type == WebKeyboardEvent::Char &&
1097 (key_event.windowsKeyCode == ui::VKEY_RETURN || 1098 (key_event.windowsKeyCode == ui::VKEY_RETURN ||
1098 key_event.windowsKeyCode == ui::VKEY_SPACE)) { 1099 key_event.windowsKeyCode == ui::VKEY_SPACE)) {
1099 OnUserGesture(); 1100 if (delegate_)
1101 delegate_->OnUserGesture(this);
1100 } 1102 }
1101 1103
1102 // Double check the type to make sure caller hasn't sent us nonsense that 1104 // Double check the type to make sure caller hasn't sent us nonsense that
1103 // will mess up our key queue. 1105 // will mess up our key queue.
1104 if (!WebInputEvent::isKeyboardEventType(key_event.type)) 1106 if (!WebInputEvent::isKeyboardEventType(key_event.type))
1105 return; 1107 return;
1106 1108
1107 if (suppress_next_char_events_) { 1109 if (suppress_next_char_events_) {
1108 // If preceding RawKeyDown event was handled by the browser, then we need 1110 // If preceding RawKeyDown event was handled by the browser, then we need
1109 // suppress all Char events generated by it. Please note that, one 1111 // suppress all Char events generated by it. Please note that, one
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 bool keep_selection) { 1362 bool keep_selection) {
1361 Send(new InputMsg_ImeConfirmComposition( 1363 Send(new InputMsg_ImeConfirmComposition(
1362 GetRoutingID(), text, replacement_range, keep_selection)); 1364 GetRoutingID(), text, replacement_range, keep_selection));
1363 } 1365 }
1364 1366
1365 void RenderWidgetHostImpl::ImeCancelComposition() { 1367 void RenderWidgetHostImpl::ImeCancelComposition() {
1366 Send(new InputMsg_ImeSetComposition(GetRoutingID(), base::string16(), 1368 Send(new InputMsg_ImeSetComposition(GetRoutingID(), base::string16(),
1367 std::vector<blink::WebCompositionUnderline>(), 0, 0)); 1369 std::vector<blink::WebCompositionUnderline>(), 0, 0));
1368 } 1370 }
1369 1371
1370 gfx::Rect RenderWidgetHostImpl::GetRootWindowResizerRect() const {
1371 return gfx::Rect();
1372 }
1373
1374 void RenderWidgetHostImpl::RequestToLockMouse(bool user_gesture,
1375 bool last_unlocked_by_target) {
1376 // Directly reject to lock the mouse. Subclass can override this method to
1377 // decide whether to allow mouse lock or not.
1378 GotResponseToLockMouseRequest(false);
1379 }
1380
1381 void RenderWidgetHostImpl::RejectMouseLockOrUnlockIfNecessary() { 1372 void RenderWidgetHostImpl::RejectMouseLockOrUnlockIfNecessary() {
1382 DCHECK(!pending_mouse_lock_request_ || !IsMouseLocked()); 1373 DCHECK(!pending_mouse_lock_request_ || !IsMouseLocked());
1383 if (pending_mouse_lock_request_) { 1374 if (pending_mouse_lock_request_) {
1384 pending_mouse_lock_request_ = false; 1375 pending_mouse_lock_request_ = false;
1385 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); 1376 Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
1386 } else if (IsMouseLocked()) { 1377 } else if (IsMouseLocked()) {
1387 view_->UnlockMouse(); 1378 view_->UnlockMouse();
1388 } 1379 }
1389 } 1380 }
1390 1381
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 1416
1426 delete this; 1417 delete this;
1427 } 1418 }
1428 1419
1429 void RenderWidgetHostImpl::RendererIsUnresponsive() { 1420 void RenderWidgetHostImpl::RendererIsUnresponsive() {
1430 NotificationService::current()->Notify( 1421 NotificationService::current()->Notify(
1431 NOTIFICATION_RENDER_WIDGET_HOST_HANG, 1422 NOTIFICATION_RENDER_WIDGET_HOST_HANG,
1432 Source<RenderWidgetHost>(this), 1423 Source<RenderWidgetHost>(this),
1433 NotificationService::NoDetails()); 1424 NotificationService::NoDetails());
1434 is_unresponsive_ = true; 1425 is_unresponsive_ = true;
1435 NotifyRendererUnresponsive(); 1426 if (delegate_)
1427 delegate_->RendererUnresponsive(this);
1436 } 1428 }
1437 1429
1438 void RenderWidgetHostImpl::RendererIsResponsive() { 1430 void RenderWidgetHostImpl::RendererIsResponsive() {
1439 if (is_unresponsive_) { 1431 if (is_unresponsive_) {
1440 is_unresponsive_ = false; 1432 is_unresponsive_ = false;
1441 NotifyRendererResponsive(); 1433 if (delegate_)
1434 delegate_->RendererResponsive(this);
1442 } 1435 }
1443 } 1436 }
1444 1437
1445 void RenderWidgetHostImpl::ClearDisplayedGraphics() { 1438 void RenderWidgetHostImpl::ClearDisplayedGraphics() {
1446 NotifyNewContentRenderingTimeoutForTesting(); 1439 NotifyNewContentRenderingTimeoutForTesting();
1447 if (view_) 1440 if (view_)
1448 view_->ClearCompositorFrame(); 1441 view_->ClearCompositorFrame();
1449 } 1442 }
1450 1443
1451 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { 1444 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 if (IsMouseLocked()) { 1722 if (IsMouseLocked()) {
1730 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); 1723 Send(new ViewMsg_LockMouse_ACK(routing_id_, true));
1731 return; 1724 return;
1732 } 1725 }
1733 1726
1734 pending_mouse_lock_request_ = true; 1727 pending_mouse_lock_request_ = true;
1735 if (privileged && allow_privileged_mouse_lock_) { 1728 if (privileged && allow_privileged_mouse_lock_) {
1736 // Directly approve to lock the mouse. 1729 // Directly approve to lock the mouse.
1737 GotResponseToLockMouseRequest(true); 1730 GotResponseToLockMouseRequest(true);
1738 } else { 1731 } else {
1739 RequestToLockMouse(user_gesture, last_unlocked_by_target); 1732 if (delegate_) {
1733 delegate_->RequestToLockMouse(this, user_gesture,
1734 last_unlocked_by_target);
1735 return;
1736 }
1737 // If there's no delegate, just reject it.
1738 GotResponseToLockMouseRequest(false);
1740 } 1739 }
1741 } 1740 }
1742 1741
1743 void RenderWidgetHostImpl::OnUnlockMouse() { 1742 void RenderWidgetHostImpl::OnUnlockMouse() {
1744 RejectMouseLockOrUnlockIfNecessary(); 1743 RejectMouseLockOrUnlockIfNecessary();
1745 } 1744 }
1746 1745
1747 void RenderWidgetHostImpl::OnShowDisambiguationPopup( 1746 void RenderWidgetHostImpl::OnShowDisambiguationPopup(
1748 const gfx::Rect& rect_pixels, 1747 const gfx::Rect& rect_pixels,
1749 const gfx::Size& size, 1748 const gfx::Size& size,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 // events are being ignored in order to keep the renderer from getting 1844 // events are being ignored in order to keep the renderer from getting
1846 // confused about how many touches are active. 1845 // confused about how many touches are active.
1847 if (IgnoreInputEvents() && event.type != WebInputEvent::TouchCancel) 1846 if (IgnoreInputEvents() && event.type != WebInputEvent::TouchCancel)
1848 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; 1847 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
1849 1848
1850 if (!process_->HasConnection()) 1849 if (!process_->HasConnection())
1851 return INPUT_EVENT_ACK_STATE_UNKNOWN; 1850 return INPUT_EVENT_ACK_STATE_UNKNOWN;
1852 1851
1853 if (event.type == WebInputEvent::MouseDown || 1852 if (event.type == WebInputEvent::MouseDown ||
1854 event.type == WebInputEvent::GestureTapDown) { 1853 event.type == WebInputEvent::GestureTapDown) {
1855 OnUserGesture(); 1854 if (delegate_)
1855 delegate_->OnUserGesture(this);
1856 } 1856 }
1857 1857
1858 if (delegate_) { 1858 if (delegate_) {
1859 if (event.type == WebInputEvent::MouseDown || 1859 if (event.type == WebInputEvent::MouseDown ||
1860 event.type == WebInputEvent::GestureTapDown || 1860 event.type == WebInputEvent::GestureTapDown ||
1861 event.type == WebInputEvent::RawKeyDown) { 1861 event.type == WebInputEvent::RawKeyDown) {
1862 delegate_->OnUserInteraction(event.type); 1862 delegate_->OnUserInteraction(event.type);
1863 } 1863 }
1864 } 1864 }
1865 1865
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 1979
1980 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( 1980 void RenderWidgetHostImpl::OnSyntheticGestureCompleted(
1981 SyntheticGesture::Result result) { 1981 SyntheticGesture::Result result) {
1982 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); 1982 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID()));
1983 } 1983 }
1984 1984
1985 bool RenderWidgetHostImpl::IgnoreInputEvents() const { 1985 bool RenderWidgetHostImpl::IgnoreInputEvents() const {
1986 return ignore_input_events_ || process_->IgnoreInputEvents(); 1986 return ignore_input_events_ || process_->IgnoreInputEvents();
1987 } 1987 }
1988 1988
1989 void RenderWidgetHostImpl::StartUserGesture() {
1990 OnUserGesture();
1991 }
1992
1993 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) { 1989 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) {
1994 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); 1990 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque));
1995 } 1991 }
1996 1992
1997 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( 1993 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent(
1998 const std::vector<EditCommand>& commands) { 1994 const std::vector<EditCommand>& commands) {
1999 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); 1995 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands));
2000 } 1996 }
2001 1997
2002 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command, 1998 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 2059
2064 void RenderWidgetHostImpl::DelayedAutoResized() { 2060 void RenderWidgetHostImpl::DelayedAutoResized() {
2065 gfx::Size new_size = new_auto_size_; 2061 gfx::Size new_size = new_auto_size_;
2066 // Clear the new_auto_size_ since the empty value is used as a flag to 2062 // Clear the new_auto_size_ since the empty value is used as a flag to
2067 // indicate that no callback is in progress (i.e. without this line 2063 // indicate that no callback is in progress (i.e. without this line
2068 // DelayedAutoResized will not get called again). 2064 // DelayedAutoResized will not get called again).
2069 new_auto_size_.SetSize(0, 0); 2065 new_auto_size_.SetSize(0, 0);
2070 if (!auto_resize_enabled_) 2066 if (!auto_resize_enabled_)
2071 return; 2067 return;
2072 2068
2073 OnRenderAutoResized(new_size); 2069 if (delegate_)
2070 delegate_->ResizeDueToAutoResize(this, new_size);
2074 } 2071 }
2075 2072
2076 void RenderWidgetHostImpl::DetachDelegate() { 2073 void RenderWidgetHostImpl::DetachDelegate() {
2077 delegate_ = NULL; 2074 delegate_ = NULL;
2078 } 2075 }
2079 2076
2080 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { 2077 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) {
2081 ui::LatencyInfo::LatencyComponent window_snapshot_component; 2078 ui::LatencyInfo::LatencyComponent window_snapshot_component;
2082 if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, 2079 if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT,
2083 GetLatencyComponentId(), 2080 GetLatencyComponentId(),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 } 2188 }
2192 2189
2193 #if defined(OS_WIN) 2190 #if defined(OS_WIN)
2194 gfx::NativeViewAccessible 2191 gfx::NativeViewAccessible
2195 RenderWidgetHostImpl::GetParentNativeViewAccessible() { 2192 RenderWidgetHostImpl::GetParentNativeViewAccessible() {
2196 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; 2193 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL;
2197 } 2194 }
2198 #endif 2195 #endif
2199 2196
2200 } // namespace content 2197 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698