avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_RENDER_WIDGET_DELEGATE_H_ |
| 6 | #define CONTENT_RENDERER_RENDER_WIDGET_DELEGATE_H_ |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 7 | |
| 8 | #include "content/common/content_export.h" |
| 9 | |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 10 | namespace blink { |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 11 | class WebMouseEvent; |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 12 | class WebWidget; |
| 13 | class WebWidgetClient; |
| 14 | } // namespace blink |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 15 | |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 16 | namespace content { |
| 17 | |
| 18 | // |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 19 | // RenderWidgetDelegate |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 20 | // |
| 21 | // An interface implemented by an object owning a RenderWidget. This is |
| 22 | // intended to be temporary until the RenderViewImpl and RenderWidget classes |
ekaramad | 27ca69b1 | 2017-04-20 18:34:29 | [diff] [blame] | 23 | // are disentangled; see https://crbug.com/583347 and https://crbug.com/478281. |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 24 | class CONTENT_EXPORT RenderWidgetDelegate { |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 25 | public: |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 26 | virtual ~RenderWidgetDelegate() = default; |
| 27 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 28 | // Returns the WebWidget if the delegate has one. Otherwise it returns null, |
| 29 | // and RenderWidget will fall back to its own WebWidget. |
| 30 | virtual blink::WebWidget* GetWebWidgetForWidget() const = 0; |
| 31 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 32 | // As in RenderWidgetInputHandlerDelegate. Return true if the event was |
| 33 | // handled. |
| 34 | virtual bool RenderWidgetWillHandleMouseEventForWidget( |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 35 | const blink::WebMouseEvent& event) = 0; |
| 36 | |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 37 | // See comment in RenderWidgetHost::SetActive(). |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 38 | virtual void SetActiveForWidget(bool active) = 0; |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 39 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 40 | // Returns whether multiple windows are allowed for the widget. If true, then |
| 41 | // Show() may be called more than once. |
| 42 | virtual bool SupportsMultipleWindowsForWidget() = 0; |
| 43 | |
| 44 | // Called after RenderWidget services WebWidgetClient::DidHandleGestureEvent() |
| 45 | // if the event was not cancelled. |
| 46 | virtual void DidHandleGestureEventForWidget( |
| 47 | const blink::WebGestureEvent& event) = 0; |
| 48 | |
David Bokan | 11f6ef48 | 2019-03-18 17:47:27 | [diff] [blame] | 49 | // TODO(bokan): Temporary to unblock synthetic gesture events running under |
| 50 | // VR. https://crbug.com/940063 |
| 51 | virtual bool ShouldAckSyntheticInputImmediately() = 0; |
| 52 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 53 | // ================================== |
| 54 | // These methods called during closing of a RenderWidget. |
| 55 | // |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 56 | // Called after closing the RenderWidget and destroying the WebView. |
| 57 | virtual void DidCloseWidget() = 0; |
| 58 | // ================================== |
| 59 | |
| 60 | // ================================== |
| 61 | // These methods called during handling of a SynchronizeVisualProperties |
| 62 | // message to handle updating state on the delegate. |
| 63 | // |
danakj | 84bbf55 | 2019-01-21 21:33:31 | [diff] [blame] | 64 | // Called during handling a SynchronizeVisualProperties message, to close the |
| 65 | // current PagePopup if there is one. |
| 66 | virtual void CancelPagePopupForWidget() = 0; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 67 | // Called during handling a SynchronizeVisualProperties message, with the new |
| 68 | // display mode that will be applied to the RenderWidget. The display mode in |
| 69 | // the RenderWidget is already changed when this method is called. |
| 70 | virtual void ApplyNewDisplayModeForWidget( |
| 71 | const blink::WebDisplayMode& new_display_mode) = 0; |
| 72 | // Called during handling a SynchronizeVisualProperties message, if auto |
| 73 | // resize is enabled, with the new auto size limits. |
| 74 | virtual void ApplyAutoResizeLimitsForWidget(const gfx::Size& min_size, |
| 75 | const gfx::Size& max_size) = 0; |
| 76 | // Called during handling a SynchronizeVisualProperties message, if auto |
| 77 | // resize was enabled but is being disabled. |
| 78 | virtual void DisableAutoResizeForWidget() = 0; |
| 79 | // Called during handling a SynchronizeVisualProperties message, if the |
| 80 | // message informed that the focused node should be scrolled into view. |
| 81 | virtual void ScrollFocusedNodeIntoViewForWidget() = 0; |
| 82 | // ================================== |
| 83 | |
| 84 | // Called when RenderWidget receives a SetFocus event. |
| 85 | virtual void DidReceiveSetFocusEventForWidget() = 0; |
| 86 | |
| 87 | // Called after RenderWidget changes focus. |
| 88 | virtual void DidChangeFocusForWidget() = 0; |
| 89 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 90 | // Called when the RenderWidget handles |
| 91 | // LayerTreeViewDelegate::DidCommitCompositorFrame(). |
| 92 | virtual void DidCommitCompositorFrameForWidget() = 0; |
| 93 | |
| 94 | // Called when the RenderWidget handles |
| 95 | // LayerTreeViewDelegate::DidCompletePageScaleAnimation(). |
| 96 | virtual void DidCompletePageScaleAnimationForWidget() = 0; |
| 97 | |
| 98 | // Called to resize the WebWidget, so the delegate may change how resize |
| 99 | // happens. |
| 100 | virtual void ResizeWebWidgetForWidget( |
| 101 | const gfx::Size& size, |
| 102 | float top_controls_height, |
| 103 | float bottom_controls_height, |
| 104 | bool browser_controls_shrink_blink_size) = 0; |
| 105 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 106 | // Called when RenderWidget services RenderWidgetScreenMetricsEmulatorDelegate |
| 107 | // SetScreenMetricsEmulationParameters(). |
| 108 | virtual void SetScreenMetricsEmulationParametersForWidget( |
| 109 | bool enabled, |
| 110 | const blink::WebDeviceEmulationParams& params) = 0; |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | } // namespace content |
| 114 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 115 | #endif // CONTENT_RENDERER_RENDER_WIDGET_DELEGATE_H_ |