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::UpdateCursor(const WebCursor
& cursor
) {
136 void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading
) {
140 void RenderWidgetHostViewChildFrame::TextInputTypeChanged(
141 ui::TextInputType type
,
142 ui::TextInputMode input_mode
,
143 bool can_compose_inline
,
145 // TODO(kenrb): Implement.
148 void RenderWidgetHostViewChildFrame::RenderProcessGone(
149 base::TerminationStatus status
,
151 if (frame_connector_
)
152 frame_connector_
->RenderProcessGone();
156 void RenderWidgetHostViewChildFrame::Destroy() {
157 if (frame_connector_
) {
158 frame_connector_
->set_view(NULL
);
159 frame_connector_
= NULL
;
162 host_
->SetView(NULL
);
164 base::MessageLoop::current()->DeleteSoon(FROM_HERE
, this);
167 void RenderWidgetHostViewChildFrame::SetTooltipText(
168 const base::string16
& tooltip_text
) {
171 void RenderWidgetHostViewChildFrame::SelectionChanged(
172 const base::string16
& text
,
174 const gfx::Range
& range
) {
177 void RenderWidgetHostViewChildFrame::SelectionBoundsChanged(
178 const ViewHostMsg_SelectionBounds_Params
& params
) {
181 #if defined(OS_ANDROID)
182 void RenderWidgetHostViewChildFrame::LockCompositingSurface() {
185 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() {
189 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
190 uint32 output_surface_id
,
191 scoped_ptr
<cc::CompositorFrame
> frame
) {
192 last_scroll_offset_
= frame
->metadata
.root_scroll_offset
;
193 if (frame_connector_
) {
194 frame_connector_
->ChildFrameCompositorFrameSwapped(
196 host_
->GetProcess()->GetID(),
197 host_
->GetRoutingID(),
202 void RenderWidgetHostViewChildFrame::GetScreenInfo(
203 blink::WebScreenInfo
* results
) {
206 gfx::Rect
RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
207 // We do not have any root window specific parts in this view.
208 return GetViewBounds();
211 #if defined(USE_AURA)
212 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent(
213 const TouchEventWithLatencyInfo
& touch
,
214 InputEventAckState ack_result
) {
216 #endif // defined(USE_AURA)
218 bool RenderWidgetHostViewChildFrame::LockMouse() {
222 void RenderWidgetHostViewChildFrame::UnlockMouse() {
225 #if defined(OS_MACOSX)
226 void RenderWidgetHostViewChildFrame::SetActive(bool active
) {
229 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible
) {
232 void RenderWidgetHostViewChildFrame::WindowFrameChanged() {
235 void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
238 bool RenderWidgetHostViewChildFrame::SupportsSpeech() const {
242 void RenderWidgetHostViewChildFrame::SpeakSelection() {
245 bool RenderWidgetHostViewChildFrame::IsSpeaking() const {
249 void RenderWidgetHostViewChildFrame::StopSpeaking() {
252 bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme(
253 const NativeWebKeyboardEvent
& event
) {
256 #endif // defined(OS_MACOSX)
258 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface(
259 const gfx::Rect
& src_subrect
,
260 const gfx::Size
& /* dst_size */,
261 ReadbackRequestCallback
& callback
,
262 const SkColorType preferred_color_type
) {
263 callback
.Run(SkBitmap(), READBACK_FAILED
);
266 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
267 const gfx::Rect
& src_subrect
,
268 const scoped_refptr
<media::VideoFrame
>& target
,
269 const base::Callback
<void(bool)>& callback
) {
274 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const {
278 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface(
279 const gfx::Size
& desired_size
) {
283 gfx::GLSurfaceHandle
RenderWidgetHostViewChildFrame::GetCompositingSurface() {
284 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow
, gfx::NULL_TRANSPORT
);
288 void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible(
289 gfx::NativeViewAccessible accessible_parent
) {
292 gfx::NativeViewId
RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
296 #endif // defined(OS_WIN)
298 BrowserAccessibilityManager
*
299 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
300 BrowserAccessibilityDelegate
* delegate
) {
301 return BrowserAccessibilityManager::Create(
302 BrowserAccessibilityManager::GetEmptyDocument(), delegate
);
305 } // namespace content