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/accessibility/browser_accessibility_manager.h"
8 #include "content/browser/frame_host/cross_process_frame_connector.h"
9 #include "content/browser/renderer_host/render_widget_host_impl.h"
10 #include "content/common/gpu/gpu_messages.h"
11 #include "content/common/view_messages.h"
12 #include "content/public/browser/render_process_host.h"
16 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame(
17 RenderWidgetHost
* widget_host
)
18 : host_(RenderWidgetHostImpl::From(widget_host
)),
19 frame_connector_(NULL
) {
23 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
26 void RenderWidgetHostViewChildFrame::InitAsChild(
27 gfx::NativeView parent_view
) {
31 RenderWidgetHost
* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const {
35 void RenderWidgetHostViewChildFrame::SetSize(const gfx::Size
& size
) {
39 void RenderWidgetHostViewChildFrame::SetBounds(const gfx::Rect
& rect
) {
43 void RenderWidgetHostViewChildFrame::Focus() {
46 bool RenderWidgetHostViewChildFrame::HasFocus() const {
50 bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() const {
55 void RenderWidgetHostViewChildFrame::Show() {
59 void RenderWidgetHostViewChildFrame::Hide() {
63 bool RenderWidgetHostViewChildFrame::IsShowing() {
64 return !host_
->is_hidden();
67 gfx::Rect
RenderWidgetHostViewChildFrame::GetViewBounds() const {
70 rect
= frame_connector_
->ChildFrameRect();
74 gfx::Vector2dF
RenderWidgetHostViewChildFrame::GetLastScrollOffset() const {
75 return last_scroll_offset_
;
78 gfx::NativeView
RenderWidgetHostViewChildFrame::GetNativeView() const {
83 gfx::NativeViewId
RenderWidgetHostViewChildFrame::GetNativeViewId() const {
88 gfx::NativeViewAccessible
89 RenderWidgetHostViewChildFrame::GetNativeViewAccessible() {
94 void RenderWidgetHostViewChildFrame::SetBackgroundOpaque(bool opaque
) {
97 gfx::Size
RenderWidgetHostViewChildFrame::GetPhysicalBackingSize() const {
100 size
= frame_connector_
->ChildFrameRect().size();
104 void RenderWidgetHostViewChildFrame::InitAsPopup(
105 RenderWidgetHostView
* parent_host_view
,
106 const gfx::Rect
& pos
) {
110 void RenderWidgetHostViewChildFrame::InitAsFullscreen(
111 RenderWidgetHostView
* reference_host_view
) {
115 void RenderWidgetHostViewChildFrame::ImeCancelComposition() {
119 #if defined(OS_MACOSX) || defined(USE_AURA)
120 void RenderWidgetHostViewChildFrame::ImeCompositionRangeChanged(
121 const gfx::Range
& range
,
122 const std::vector
<gfx::Rect
>& character_bounds
) {
127 void RenderWidgetHostViewChildFrame::WasShown() {
128 if (!host_
->is_hidden())
130 host_
->WasShown(ui::LatencyInfo());
133 void RenderWidgetHostViewChildFrame::WasHidden() {
134 if (host_
->is_hidden())
139 void RenderWidgetHostViewChildFrame::MovePluginWindows(
140 const std::vector
<WebPluginGeometry
>& moves
) {
143 void RenderWidgetHostViewChildFrame::Blur() {
146 void RenderWidgetHostViewChildFrame::UpdateCursor(const WebCursor
& cursor
) {
149 void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading
) {
153 void RenderWidgetHostViewChildFrame::TextInputStateChanged(
154 const ViewHostMsg_TextInputState_Params
& params
) {
157 void RenderWidgetHostViewChildFrame::RenderProcessGone(
158 base::TerminationStatus status
,
160 if (frame_connector_
)
161 frame_connector_
->RenderProcessGone();
165 void RenderWidgetHostViewChildFrame::Destroy() {
166 if (frame_connector_
) {
167 frame_connector_
->set_view(NULL
);
168 frame_connector_
= NULL
;
171 host_
->SetView(NULL
);
173 base::MessageLoop::current()->DeleteSoon(FROM_HERE
, this);
176 void RenderWidgetHostViewChildFrame::SetTooltipText(
177 const base::string16
& tooltip_text
) {
180 void RenderWidgetHostViewChildFrame::SelectionChanged(
181 const base::string16
& text
,
183 const gfx::Range
& range
) {
186 void RenderWidgetHostViewChildFrame::SelectionBoundsChanged(
187 const ViewHostMsg_SelectionBounds_Params
& params
) {
190 #if defined(OS_ANDROID)
191 void RenderWidgetHostViewChildFrame::ShowDisambiguationPopup(
192 const gfx::Rect
& target_rect
,
193 const SkBitmap
& zoomed_bitmap
) {
196 void RenderWidgetHostViewChildFrame::LockCompositingSurface() {
199 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() {
203 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceInitialized(int host_id
,
207 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceBuffersSwapped(
208 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params
& params
,
210 if (frame_connector_
)
211 frame_connector_
->ChildFrameBuffersSwapped(params
, gpu_host_id
);
214 void RenderWidgetHostViewChildFrame::AcceleratedSurfacePostSubBuffer(
215 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params
& params
,
219 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
220 uint32 output_surface_id
,
221 scoped_ptr
<cc::CompositorFrame
> frame
) {
222 last_scroll_offset_
= frame
->metadata
.root_scroll_offset
;
223 if (frame_connector_
) {
224 frame_connector_
->ChildFrameCompositorFrameSwapped(
226 host_
->GetProcess()->GetID(),
227 host_
->GetRoutingID(),
232 void RenderWidgetHostViewChildFrame::GetScreenInfo(
233 blink::WebScreenInfo
* results
) {
236 gfx::Rect
RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
237 // We do not have any root window specific parts in this view.
238 return GetViewBounds();
241 #if defined(USE_AURA)
242 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent(
243 const TouchEventWithLatencyInfo
& touch
,
244 InputEventAckState ack_result
) {
246 #endif // defined(USE_AURA)
248 bool RenderWidgetHostViewChildFrame::LockMouse() {
252 void RenderWidgetHostViewChildFrame::UnlockMouse() {
255 #if defined(OS_MACOSX)
256 void RenderWidgetHostViewChildFrame::SetActive(bool active
) {
259 void RenderWidgetHostViewChildFrame::SetTakesFocusOnlyOnMouseDown(bool flag
) {
262 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible
) {
265 void RenderWidgetHostViewChildFrame::WindowFrameChanged() {
268 void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
271 bool RenderWidgetHostViewChildFrame::SupportsSpeech() const {
275 void RenderWidgetHostViewChildFrame::SpeakSelection() {
278 bool RenderWidgetHostViewChildFrame::IsSpeaking() const {
282 void RenderWidgetHostViewChildFrame::StopSpeaking() {
285 bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme(
286 const NativeWebKeyboardEvent
& event
) {
289 #endif // defined(OS_MACOSX)
291 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface(
292 const gfx::Rect
& src_subrect
,
293 const gfx::Size
& /* dst_size */,
294 const base::Callback
<void(bool, const SkBitmap
&)>& callback
,
295 const SkColorType color_type
) {
296 callback
.Run(false, SkBitmap());
299 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
300 const gfx::Rect
& src_subrect
,
301 const scoped_refptr
<media::VideoFrame
>& target
,
302 const base::Callback
<void(bool)>& callback
) {
307 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const {
311 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceSuspend() {
315 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceRelease() {
318 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface(
319 const gfx::Size
& desired_size
) {
323 gfx::GLSurfaceHandle
RenderWidgetHostViewChildFrame::GetCompositingSurface() {
324 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow
, gfx::TEXTURE_TRANSPORT
);
328 void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible(
329 gfx::NativeViewAccessible accessible_parent
) {
332 gfx::NativeViewId
RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
336 #endif // defined(OS_WIN)
338 SkColorType
RenderWidgetHostViewChildFrame::PreferredReadbackFormat() {
339 return kN32_SkColorType
;
342 BrowserAccessibilityManager
*
343 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
344 BrowserAccessibilityDelegate
* delegate
) {
345 return BrowserAccessibilityManager::Create(
346 BrowserAccessibilityManager::GetEmptyDocument(), delegate
);
349 } // namespace content