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 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
7 #include "content/browser/frame_host/cross_process_frame_connector.h"
8 #include "content/browser/renderer_host/render_widget_host_impl.h"
9 #include "content/common/gpu/gpu_messages.h"
10 #include "content/common/view_messages.h"
11 #include "content/public/browser/render_process_host.h"
15 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame(
16 RenderWidgetHost
* widget_host
)
17 : host_(RenderWidgetHostImpl::From(widget_host
)),
18 frame_connector_(NULL
) {
22 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
25 void RenderWidgetHostViewChildFrame::InitAsChild(
26 gfx::NativeView parent_view
) {
30 RenderWidgetHost
* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const {
34 void RenderWidgetHostViewChildFrame::SetSize(const gfx::Size
& size
) {
38 void RenderWidgetHostViewChildFrame::SetBounds(const gfx::Rect
& rect
) {
42 void RenderWidgetHostViewChildFrame::Focus() {
45 bool RenderWidgetHostViewChildFrame::HasFocus() const {
49 bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() const {
54 void RenderWidgetHostViewChildFrame::Show() {
58 void RenderWidgetHostViewChildFrame::Hide() {
62 bool RenderWidgetHostViewChildFrame::IsShowing() {
63 return !host_
->is_hidden();
66 gfx::Rect
RenderWidgetHostViewChildFrame::GetViewBounds() const {
69 rect
= frame_connector_
->ChildFrameRect();
73 gfx::NativeView
RenderWidgetHostViewChildFrame::GetNativeView() const {
78 gfx::NativeViewId
RenderWidgetHostViewChildFrame::GetNativeViewId() const {
83 gfx::NativeViewAccessible
84 RenderWidgetHostViewChildFrame::GetNativeViewAccessible() {
89 void RenderWidgetHostViewChildFrame::SetBackgroundOpaque(bool opaque
) {
92 gfx::Size
RenderWidgetHostViewChildFrame::GetPhysicalBackingSize() const {
95 size
= frame_connector_
->ChildFrameRect().size();
99 void RenderWidgetHostViewChildFrame::InitAsPopup(
100 RenderWidgetHostView
* parent_host_view
,
101 const gfx::Rect
& pos
) {
105 void RenderWidgetHostViewChildFrame::InitAsFullscreen(
106 RenderWidgetHostView
* reference_host_view
) {
110 void RenderWidgetHostViewChildFrame::ImeCancelComposition() {
114 #if defined(OS_MACOSX) || defined(USE_AURA)
115 void RenderWidgetHostViewChildFrame::ImeCompositionRangeChanged(
116 const gfx::Range
& range
,
117 const std::vector
<gfx::Rect
>& character_bounds
) {
122 void RenderWidgetHostViewChildFrame::WasShown() {
123 if (!host_
->is_hidden())
125 host_
->WasShown(ui::LatencyInfo());
128 void RenderWidgetHostViewChildFrame::WasHidden() {
129 if (host_
->is_hidden())
134 void RenderWidgetHostViewChildFrame::MovePluginWindows(
135 const std::vector
<WebPluginGeometry
>& moves
) {
138 void RenderWidgetHostViewChildFrame::Blur() {
141 void RenderWidgetHostViewChildFrame::UpdateCursor(const WebCursor
& cursor
) {
144 void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading
) {
148 void RenderWidgetHostViewChildFrame::TextInputStateChanged(
149 const ViewHostMsg_TextInputState_Params
& params
) {
152 void RenderWidgetHostViewChildFrame::RenderProcessGone(
153 base::TerminationStatus status
,
155 if (frame_connector_
)
156 frame_connector_
->RenderProcessGone();
160 void RenderWidgetHostViewChildFrame::Destroy() {
161 if (frame_connector_
) {
162 frame_connector_
->set_view(NULL
);
163 frame_connector_
= NULL
;
166 host_
->SetView(NULL
);
168 base::MessageLoop::current()->DeleteSoon(FROM_HERE
, this);
171 void RenderWidgetHostViewChildFrame::SetTooltipText(
172 const base::string16
& tooltip_text
) {
175 void RenderWidgetHostViewChildFrame::SelectionChanged(
176 const base::string16
& text
,
178 const gfx::Range
& range
) {
181 void RenderWidgetHostViewChildFrame::SelectionBoundsChanged(
182 const ViewHostMsg_SelectionBounds_Params
& params
) {
185 #if defined(OS_ANDROID)
186 void RenderWidgetHostViewChildFrame::ShowDisambiguationPopup(
187 const gfx::Rect
& target_rect
,
188 const SkBitmap
& zoomed_bitmap
) {
191 void RenderWidgetHostViewChildFrame::LockCompositingSurface() {
194 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() {
198 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceInitialized(int host_id
,
202 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceBuffersSwapped(
203 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params
& params
,
205 if (frame_connector_
)
206 frame_connector_
->ChildFrameBuffersSwapped(params
, gpu_host_id
);
209 void RenderWidgetHostViewChildFrame::AcceleratedSurfacePostSubBuffer(
210 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params
& params
,
214 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
215 uint32 output_surface_id
,
216 scoped_ptr
<cc::CompositorFrame
> frame
) {
217 if (frame_connector_
) {
218 frame_connector_
->ChildFrameCompositorFrameSwapped(
220 host_
->GetProcess()->GetID(),
221 host_
->GetRoutingID(),
226 void RenderWidgetHostViewChildFrame::GetScreenInfo(
227 blink::WebScreenInfo
* results
) {
230 gfx::Rect
RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
231 // We do not have any root window specific parts in this view.
232 return GetViewBounds();
235 #if defined(USE_AURA)
236 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent(
237 const TouchEventWithLatencyInfo
& touch
,
238 InputEventAckState ack_result
) {
240 #endif // defined(USE_AURA)
242 bool RenderWidgetHostViewChildFrame::LockMouse() {
246 void RenderWidgetHostViewChildFrame::UnlockMouse() {
249 #if defined(OS_MACOSX)
250 void RenderWidgetHostViewChildFrame::SetActive(bool active
) {
253 void RenderWidgetHostViewChildFrame::SetTakesFocusOnlyOnMouseDown(bool flag
) {
256 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible
) {
259 void RenderWidgetHostViewChildFrame::WindowFrameChanged() {
262 void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
265 bool RenderWidgetHostViewChildFrame::SupportsSpeech() const {
269 void RenderWidgetHostViewChildFrame::SpeakSelection() {
272 bool RenderWidgetHostViewChildFrame::IsSpeaking() const {
276 void RenderWidgetHostViewChildFrame::StopSpeaking() {
279 bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme(
280 const NativeWebKeyboardEvent
& event
) {
283 #endif // defined(OS_MACOSX)
285 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface(
286 const gfx::Rect
& src_subrect
,
287 const gfx::Size
& /* dst_size */,
288 const base::Callback
<void(bool, const SkBitmap
&)>& callback
,
289 const SkColorType color_type
) {
290 callback
.Run(false, SkBitmap());
293 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
294 const gfx::Rect
& src_subrect
,
295 const scoped_refptr
<media::VideoFrame
>& target
,
296 const base::Callback
<void(bool)>& callback
) {
301 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const {
305 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceSuspend() {
309 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceRelease() {
312 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface(
313 const gfx::Size
& desired_size
) {
317 gfx::GLSurfaceHandle
RenderWidgetHostViewChildFrame::GetCompositingSurface() {
318 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow
, gfx::TEXTURE_TRANSPORT
);
322 void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible(
323 gfx::NativeViewAccessible accessible_parent
) {
326 gfx::NativeViewId
RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
330 #endif // defined(OS_WIN)
332 SkColorType
RenderWidgetHostViewChildFrame::PreferredReadbackFormat() {
333 return kN32_SkColorType
;
336 BrowserAccessibilityManager
*
337 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
338 BrowserAccessibilityDelegate
* delegate
) {
339 // This eventually needs to be implemented for cross-process iframes.
340 // http://crbug.com/368298
344 } // namespace content