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::SetBackgroundColor(SkColor color
) {
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) || defined(OS_ANDROID)
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::TextInputTypeChanged(
154 ui::TextInputType type
,
155 ui::TextInputMode input_mode
,
156 bool can_compose_inline
,
161 void RenderWidgetHostViewChildFrame::RenderProcessGone(
162 base::TerminationStatus status
,
164 if (frame_connector_
)
165 frame_connector_
->RenderProcessGone();
169 void RenderWidgetHostViewChildFrame::Destroy() {
170 if (frame_connector_
) {
171 frame_connector_
->set_view(NULL
);
172 frame_connector_
= NULL
;
175 host_
->SetView(NULL
);
177 base::MessageLoop::current()->DeleteSoon(FROM_HERE
, this);
180 void RenderWidgetHostViewChildFrame::SetTooltipText(
181 const base::string16
& tooltip_text
) {
184 void RenderWidgetHostViewChildFrame::SelectionChanged(
185 const base::string16
& text
,
187 const gfx::Range
& range
) {
190 void RenderWidgetHostViewChildFrame::SelectionBoundsChanged(
191 const ViewHostMsg_SelectionBounds_Params
& params
) {
194 #if defined(OS_ANDROID)
195 void RenderWidgetHostViewChildFrame::LockCompositingSurface() {
198 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() {
202 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
203 uint32 output_surface_id
,
204 scoped_ptr
<cc::CompositorFrame
> frame
) {
205 last_scroll_offset_
= frame
->metadata
.root_scroll_offset
;
206 if (frame_connector_
) {
207 frame_connector_
->ChildFrameCompositorFrameSwapped(
209 host_
->GetProcess()->GetID(),
210 host_
->GetRoutingID(),
215 void RenderWidgetHostViewChildFrame::GetScreenInfo(
216 blink::WebScreenInfo
* results
) {
219 gfx::Rect
RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
220 // We do not have any root window specific parts in this view.
221 return GetViewBounds();
224 #if defined(USE_AURA)
225 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent(
226 const TouchEventWithLatencyInfo
& touch
,
227 InputEventAckState ack_result
) {
229 #endif // defined(USE_AURA)
231 bool RenderWidgetHostViewChildFrame::LockMouse() {
235 void RenderWidgetHostViewChildFrame::UnlockMouse() {
238 #if defined(OS_MACOSX)
239 void RenderWidgetHostViewChildFrame::SetActive(bool active
) {
242 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible
) {
245 void RenderWidgetHostViewChildFrame::WindowFrameChanged() {
248 void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
251 bool RenderWidgetHostViewChildFrame::SupportsSpeech() const {
255 void RenderWidgetHostViewChildFrame::SpeakSelection() {
258 bool RenderWidgetHostViewChildFrame::IsSpeaking() const {
262 void RenderWidgetHostViewChildFrame::StopSpeaking() {
265 bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme(
266 const NativeWebKeyboardEvent
& event
) {
269 #endif // defined(OS_MACOSX)
271 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface(
272 const gfx::Rect
& src_subrect
,
273 const gfx::Size
& /* dst_size */,
274 CopyFromCompositingSurfaceCallback
& callback
,
275 const SkColorType color_type
) {
276 callback
.Run(false, SkBitmap());
279 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
280 const gfx::Rect
& src_subrect
,
281 const scoped_refptr
<media::VideoFrame
>& target
,
282 const base::Callback
<void(bool)>& callback
) {
287 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const {
291 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface(
292 const gfx::Size
& desired_size
) {
296 gfx::GLSurfaceHandle
RenderWidgetHostViewChildFrame::GetCompositingSurface() {
297 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow
, gfx::NULL_TRANSPORT
);
301 void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible(
302 gfx::NativeViewAccessible accessible_parent
) {
305 gfx::NativeViewId
RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
309 #endif // defined(OS_WIN)
311 SkColorType
RenderWidgetHostViewChildFrame::PreferredReadbackFormat() {
312 return kN32_SkColorType
;
315 BrowserAccessibilityManager
*
316 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
317 BrowserAccessibilityDelegate
* delegate
) {
318 return BrowserAccessibilityManager::Create(
319 BrowserAccessibilityManager::GetEmptyDocument(), delegate
);
322 } // namespace content