blob: 4052e67b1b0770dce3ca39aa32f24f0eca2bc8e2 [file] [log] [blame]
avi40b5be7a2016-03-03 21:13:441// 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. Wong7bbf22d2018-12-20 00:27:275#ifndef CONTENT_RENDERER_RENDER_WIDGET_DELEGATE_H_
6#define CONTENT_RENDERER_RENDER_WIDGET_DELEGATE_H_
avi40b5be7a2016-03-03 21:13:447
8#include "content/common/content_export.h"
9
avid7d6b2e2016-03-04 19:41:1710namespace blink {
avid7d6b2e2016-03-04 19:41:1711class WebMouseEvent;
Albert J. Wong7bbf22d2018-12-20 00:27:2712class WebWidget;
13class WebWidgetClient;
14} // namespace blink
avid7d6b2e2016-03-04 19:41:1715
avi40b5be7a2016-03-03 21:13:4416namespace content {
17
18//
Albert J. Wong7bbf22d2018-12-20 00:27:2719// RenderWidgetDelegate
avi40b5be7a2016-03-03 21:13:4420//
21// An interface implemented by an object owning a RenderWidget. This is
22// intended to be temporary until the RenderViewImpl and RenderWidget classes
ekaramad27ca69b12017-04-20 18:34:2923// are disentangled; see https://crbug.com/583347 and https://crbug.com/478281.
Albert J. Wong7bbf22d2018-12-20 00:27:2724class CONTENT_EXPORT RenderWidgetDelegate {
avi40b5be7a2016-03-03 21:13:4425 public:
Albert J. Wong7bbf22d2018-12-20 00:27:2726 virtual ~RenderWidgetDelegate() = default;
27
danakja2c9d0a92018-07-25 20:01:1828 // 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
danakja2c9d0a92018-07-25 20:01:1832 // As in RenderWidgetInputHandlerDelegate. Return true if the event was
33 // handled.
34 virtual bool RenderWidgetWillHandleMouseEventForWidget(
avid7d6b2e2016-03-04 19:41:1735 const blink::WebMouseEvent& event) = 0;
36
Albert J. Wongcb004632018-07-10 22:58:2537 // See comment in RenderWidgetHost::SetActive().
danakja2c9d0a92018-07-25 20:01:1838 virtual void SetActiveForWidget(bool active) = 0;
Albert J. Wongcb004632018-07-10 22:58:2539
danakja2c9d0a92018-07-25 20:01:1840 // 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 Bokan11f6ef482019-03-18 17:47:2749 // TODO(bokan): Temporary to unblock synthetic gesture events running under
50 // VR. https://crbug.com/940063
51 virtual bool ShouldAckSyntheticInputImmediately() = 0;
52
danakja2c9d0a92018-07-25 20:01:1853 // ==================================
54 // These methods called during closing of a RenderWidget.
55 //
danakja2c9d0a92018-07-25 20:01:1856 // 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 //
danakj84bbf552019-01-21 21:33:3164 // Called during handling a SynchronizeVisualProperties message, to close the
65 // current PagePopup if there is one.
66 virtual void CancelPagePopupForWidget() = 0;
danakja2c9d0a92018-07-25 20:01:1867 // 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
danakja2c9d0a92018-07-25 20:01:1890 // 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
danakja2c9d0a92018-07-25 20:01:18106 // Called when RenderWidget services RenderWidgetScreenMetricsEmulatorDelegate
107 // SetScreenMetricsEmulationParameters().
108 virtual void SetScreenMetricsEmulationParametersForWidget(
109 bool enabled,
110 const blink::WebDeviceEmulationParams& params) = 0;
avi40b5be7a2016-03-03 21:13:44111};
112
113} // namespace content
114
Albert J. Wong7bbf22d2018-12-20 00:27:27115#endif // CONTENT_RENDERER_RENDER_WIDGET_DELEGATE_H_