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() {
56 if (!host_
->is_hidden())
58 host_
->WasShown(ui::LatencyInfo());
61 void RenderWidgetHostViewChildFrame::Hide() {
62 if (host_
->is_hidden())
67 bool RenderWidgetHostViewChildFrame::IsShowing() {
68 return !host_
->is_hidden();
71 gfx::Rect
RenderWidgetHostViewChildFrame::GetViewBounds() const {
74 rect
= frame_connector_
->ChildFrameRect();
78 gfx::Vector2dF
RenderWidgetHostViewChildFrame::GetLastScrollOffset() const {
79 return last_scroll_offset_
;
82 gfx::NativeView
RenderWidgetHostViewChildFrame::GetNativeView() const {
87 gfx::NativeViewId
RenderWidgetHostViewChildFrame::GetNativeViewId() const {
92 gfx::NativeViewAccessible
93 RenderWidgetHostViewChildFrame::GetNativeViewAccessible() {
98 void RenderWidgetHostViewChildFrame::SetBackgroundColor(SkColor color
) {
101 gfx::Size
RenderWidgetHostViewChildFrame::GetPhysicalBackingSize() const {
103 if (frame_connector_
)
104 size
= frame_connector_
->ChildFrameRect().size();
108 void RenderWidgetHostViewChildFrame::InitAsPopup(
109 RenderWidgetHostView
* parent_host_view
,
110 const gfx::Rect
& bounds
) {
114 void RenderWidgetHostViewChildFrame::InitAsFullscreen(
115 RenderWidgetHostView
* reference_host_view
) {
119 void RenderWidgetHostViewChildFrame::ImeCancelComposition() {
123 void RenderWidgetHostViewChildFrame::ImeCompositionRangeChanged(
124 const gfx::Range
& range
,
125 const std::vector
<gfx::Rect
>& character_bounds
) {
129 void RenderWidgetHostViewChildFrame::MovePluginWindows(
130 const std::vector
<WebPluginGeometry
>& moves
) {
133 void RenderWidgetHostViewChildFrame::Blur() {
136 void RenderWidgetHostViewChildFrame::UpdateCursor(const WebCursor
& cursor
) {
139 void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading
) {
143 void RenderWidgetHostViewChildFrame::TextInputTypeChanged(
144 ui::TextInputType type
,
145 ui::TextInputMode input_mode
,
146 bool can_compose_inline
,
148 // TODO(kenrb): Implement.
151 void RenderWidgetHostViewChildFrame::RenderProcessGone(
152 base::TerminationStatus status
,
154 if (frame_connector_
)
155 frame_connector_
->RenderProcessGone();
159 void RenderWidgetHostViewChildFrame::Destroy() {
160 if (frame_connector_
) {
161 frame_connector_
->set_view(NULL
);
162 frame_connector_
= NULL
;
165 host_
->SetView(NULL
);
167 base::MessageLoop::current()->DeleteSoon(FROM_HERE
, this);
170 void RenderWidgetHostViewChildFrame::SetTooltipText(
171 const base::string16
& tooltip_text
) {
174 void RenderWidgetHostViewChildFrame::SelectionChanged(
175 const base::string16
& text
,
177 const gfx::Range
& range
) {
180 void RenderWidgetHostViewChildFrame::SelectionBoundsChanged(
181 const ViewHostMsg_SelectionBounds_Params
& params
) {
184 #if defined(OS_ANDROID)
185 void RenderWidgetHostViewChildFrame::LockCompositingSurface() {
188 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() {
192 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
193 uint32 output_surface_id
,
194 scoped_ptr
<cc::CompositorFrame
> frame
) {
195 last_scroll_offset_
= frame
->metadata
.root_scroll_offset
;
196 if (frame_connector_
) {
197 frame_connector_
->ChildFrameCompositorFrameSwapped(
199 host_
->GetProcess()->GetID(),
200 host_
->GetRoutingID(),
205 void RenderWidgetHostViewChildFrame::GetScreenInfo(
206 blink::WebScreenInfo
* results
) {
209 gfx::Rect
RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
210 // We do not have any root window specific parts in this view.
211 return GetViewBounds();
214 #if defined(USE_AURA)
215 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent(
216 const TouchEventWithLatencyInfo
& touch
,
217 InputEventAckState ack_result
) {
219 #endif // defined(USE_AURA)
221 bool RenderWidgetHostViewChildFrame::LockMouse() {
225 void RenderWidgetHostViewChildFrame::UnlockMouse() {
228 #if defined(OS_MACOSX)
229 void RenderWidgetHostViewChildFrame::SetActive(bool active
) {
232 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible
) {
235 void RenderWidgetHostViewChildFrame::WindowFrameChanged() {
238 void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
241 bool RenderWidgetHostViewChildFrame::SupportsSpeech() const {
245 void RenderWidgetHostViewChildFrame::SpeakSelection() {
248 bool RenderWidgetHostViewChildFrame::IsSpeaking() const {
252 void RenderWidgetHostViewChildFrame::StopSpeaking() {
255 bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme(
256 const NativeWebKeyboardEvent
& event
) {
259 #endif // defined(OS_MACOSX)
261 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface(
262 const gfx::Rect
& src_subrect
,
263 const gfx::Size
& /* dst_size */,
264 ReadbackRequestCallback
& callback
,
265 const SkColorType color_type
) {
266 callback
.Run(SkBitmap(), READBACK_NOT_SUPPORTED
);
269 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
270 const gfx::Rect
& src_subrect
,
271 const scoped_refptr
<media::VideoFrame
>& target
,
272 const base::Callback
<void(bool)>& callback
) {
277 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const {
281 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface(
282 const gfx::Size
& desired_size
) {
286 gfx::GLSurfaceHandle
RenderWidgetHostViewChildFrame::GetCompositingSurface() {
287 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow
, gfx::NULL_TRANSPORT
);
291 void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible(
292 gfx::NativeViewAccessible accessible_parent
) {
295 gfx::NativeViewId
RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
299 #endif // defined(OS_WIN)
301 SkColorType
RenderWidgetHostViewChildFrame::PreferredReadbackFormat() {
302 return kN32_SkColorType
;
305 BrowserAccessibilityManager
*
306 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
307 BrowserAccessibilityDelegate
* delegate
) {
308 return BrowserAccessibilityManager::Create(
309 BrowserAccessibilityManager::GetEmptyDocument(), delegate
);
312 } // namespace content