1 // Copyright 2014 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.
5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/resources/returned_resource.h"
10 #include "cc/surfaces/surface_factory_client.h"
11 #include "cc/surfaces/surface_id_allocator.h"
12 #include "content/browser/compositor/image_transport_factory.h"
13 #include "content/browser/renderer_host/render_widget_host_view_base.h"
14 #include "content/common/content_export.h"
15 #include "content/public/browser/readback_types.h"
16 #include "ui/compositor/compositor.h"
17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/native_widget_types.h"
22 enum class SurfaceDrawStatus
;
26 class CrossProcessFrameConnector
;
27 class RenderWidgetHost
;
28 class RenderWidgetHostImpl
;
29 class RenderWidgetHostViewChildFrameTest
;
31 // RenderWidgetHostViewChildFrame implements the view for a RenderWidgetHost
32 // associated with content being rendered in a separate process from
33 // content that is embedding it. This is not a platform-specific class; rather,
34 // the embedding renderer process implements the platform containing the
35 // widget, and the top-level frame's RenderWidgetHostView will ultimately
36 // manage all native widget interaction.
38 // See comments in render_widget_host_view.h about this class and its members.
39 class CONTENT_EXPORT RenderWidgetHostViewChildFrame
40 : public RenderWidgetHostViewBase
,
41 public cc::SurfaceFactoryClient
{
43 explicit RenderWidgetHostViewChildFrame(RenderWidgetHost
* widget
);
44 ~RenderWidgetHostViewChildFrame() override
;
46 void set_cross_process_frame_connector(
47 CrossProcessFrameConnector
* frame_connector
) {
48 frame_connector_
= frame_connector
;
51 // RenderWidgetHostView implementation.
52 void InitAsChild(gfx::NativeView parent_view
) override
;
53 RenderWidgetHost
* GetRenderWidgetHost() const override
;
54 void SetSize(const gfx::Size
& size
) override
;
55 void SetBounds(const gfx::Rect
& rect
) override
;
56 void Focus() override
;
57 bool HasFocus() const override
;
58 bool IsSurfaceAvailableForCopy() const override
;
61 bool IsShowing() override
;
62 gfx::Rect
GetViewBounds() const override
;
63 gfx::Vector2dF
GetLastScrollOffset() const override
;
64 gfx::NativeView
GetNativeView() const override
;
65 gfx::NativeViewId
GetNativeViewId() const override
;
66 gfx::NativeViewAccessible
GetNativeViewAccessible() override
;
67 void SetBackgroundColor(SkColor color
) override
;
68 gfx::Size
GetPhysicalBackingSize() const override
;
70 // RenderWidgetHostViewBase implementation.
71 void InitAsPopup(RenderWidgetHostView
* parent_host_view
,
72 const gfx::Rect
& bounds
) override
;
73 void InitAsFullscreen(RenderWidgetHostView
* reference_host_view
) override
;
74 void MovePluginWindows(const std::vector
<WebPluginGeometry
>& moves
) override
;
75 void UpdateCursor(const WebCursor
& cursor
) override
;
76 void SetIsLoading(bool is_loading
) override
;
77 void TextInputTypeChanged(ui::TextInputType type
,
78 ui::TextInputMode input_mode
,
79 bool can_compose_inline
,
81 void ImeCancelComposition() override
;
82 void ImeCompositionRangeChanged(
83 const gfx::Range
& range
,
84 const std::vector
<gfx::Rect
>& character_bounds
) override
;
85 void RenderProcessGone(base::TerminationStatus status
,
86 int error_code
) override
;
87 void Destroy() override
;
88 void SetTooltipText(const base::string16
& tooltip_text
) override
;
89 void SelectionChanged(const base::string16
& text
,
91 const gfx::Range
& range
) override
;
92 void SelectionBoundsChanged(
93 const ViewHostMsg_SelectionBounds_Params
& params
) override
;
94 void CopyFromCompositingSurface(
95 const gfx::Rect
& src_subrect
,
96 const gfx::Size
& dst_size
,
97 ReadbackRequestCallback
& callback
,
98 const SkColorType preferred_color_type
) override
;
99 void CopyFromCompositingSurfaceToVideoFrame(
100 const gfx::Rect
& src_subrect
,
101 const scoped_refptr
<media::VideoFrame
>& target
,
102 const base::Callback
<void(bool)>& callback
) override
;
103 bool CanCopyToVideoFrame() const override
;
104 bool HasAcceleratedSurface(const gfx::Size
& desired_size
) override
;
105 void OnSwapCompositorFrame(uint32 output_surface_id
,
106 scoped_ptr
<cc::CompositorFrame
> frame
) override
;
107 void GetScreenInfo(blink::WebScreenInfo
* results
) override
;
108 gfx::Rect
GetBoundsInRootWindow() override
;
109 gfx::GLSurfaceHandle
GetCompositingSurface() override
;
110 #if defined(USE_AURA)
111 void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo
& touch
,
112 InputEventAckState ack_result
) override
;
113 #endif // defined(USE_AURA)
114 bool LockMouse() override
;
115 void UnlockMouse() override
;
116 uint32_t GetSurfaceIdNamespace() override
;
118 #if defined(OS_MACOSX)
119 // RenderWidgetHostView implementation.
120 void SetActive(bool active
) override
;
121 void SetWindowVisibility(bool visible
) override
;
122 void WindowFrameChanged() override
;
123 void ShowDefinitionForSelection() override
;
124 bool SupportsSpeech() const override
;
125 void SpeakSelection() override
;
126 bool IsSpeaking() const override
;
127 void StopSpeaking() override
;
129 // RenderWidgetHostViewBase implementation.
130 bool PostProcessEventForPluginIme(
131 const NativeWebKeyboardEvent
& event
) override
;
132 #endif // defined(OS_MACOSX)
134 // RenderWidgetHostViewBase implementation.
135 #if defined(OS_ANDROID)
136 void LockCompositingSurface() override
;
137 void UnlockCompositingSurface() override
;
138 #endif // defined(OS_ANDROID)
141 void SetParentNativeViewAccessible(
142 gfx::NativeViewAccessible accessible_parent
) override
;
143 gfx::NativeViewId
GetParentForWindowlessPlugin() const override
;
145 BrowserAccessibilityManager
* CreateBrowserAccessibilityManager(
146 BrowserAccessibilityDelegate
* delegate
) override
;
148 // cc::SurfaceFactoryClient implementation.
149 void ReturnResources(const cc::ReturnedResourceArray
& resources
) override
;
152 friend class RenderWidgetHostView
;
153 friend class RenderWidgetHostViewChildFrameTest
;
155 void SurfaceDrawn(uint32 output_surface_id
, cc::SurfaceDrawStatus drawn
);
157 // The last scroll offset of the view.
158 gfx::Vector2dF last_scroll_offset_
;
160 // Members will become private when RenderWidgetHostViewGuest is removed.
162 RenderWidgetHostImpl
* host_
;
164 // Flag determining whether we render into a compositing Surface.
167 // Surface-related state.
168 scoped_ptr
<cc::SurfaceIdAllocator
> id_allocator_
;
169 scoped_ptr
<cc::SurfaceFactory
> surface_factory_
;
170 cc::SurfaceId surface_id_
;
171 uint32 next_surface_sequence_
;
172 uint32 last_output_surface_id_
;
173 gfx::Size current_surface_size_
;
174 float current_surface_scale_factor_
;
175 uint32 ack_pending_count_
;
176 cc::ReturnedResourceArray surface_returned_resources_
;
178 // frame_connector_ provides a platform abstraction. Messages
179 // sent through it are routed to the embedding renderer process.
180 CrossProcessFrameConnector
* frame_connector_
;
183 base::WeakPtr
<RenderWidgetHostViewChildFrame
> AsWeakPtr() {
184 return weak_factory_
.GetWeakPtr();
187 base::WeakPtrFactory
<RenderWidgetHostViewChildFrame
> weak_factory_
;
188 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewChildFrame
);
191 } // namespace content
193 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_