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) || defined(TOOLKIT_VIEWS) || defined(USE_AURA)
191 void RenderWidgetHostViewChildFrame::ShowDisambiguationPopup(
192 const gfx::Rect& rect_pixels,
193 const SkBitmap& zoomed_bitmap) {
197 #if defined(OS_ANDROID)
198 void RenderWidgetHostViewChildFrame::LockCompositingSurface() {
201 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() {
205 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceInitialized(int host_id,
209 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceBuffersSwapped(
210 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
215 void RenderWidgetHostViewChildFrame::AcceleratedSurfacePostSubBuffer(
216 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
220 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
221 uint32 output_surface_id,
222 scoped_ptr<cc::CompositorFrame> frame) {
223 last_scroll_offset_ = frame->metadata.root_scroll_offset;
224 if (frame_connector_) {
225 frame_connector_->ChildFrameCompositorFrameSwapped(
227 host_->GetProcess()->GetID(),
228 host_->GetRoutingID(),
233 void RenderWidgetHostViewChildFrame::GetScreenInfo(
234 blink::WebScreenInfo* results) {
237 gfx::Rect RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
238 // We do not have any root window specific parts in this view.
239 return GetViewBounds();
242 #if defined(USE_AURA)
243 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent(
244 const TouchEventWithLatencyInfo& touch,
245 InputEventAckState ack_result) {
247 #endif // defined(USE_AURA)
249 bool RenderWidgetHostViewChildFrame::LockMouse() {
253 void RenderWidgetHostViewChildFrame::UnlockMouse() {
256 #if defined(OS_MACOSX)
257 void RenderWidgetHostViewChildFrame::SetActive(bool active) {
260 void RenderWidgetHostViewChildFrame::SetTakesFocusOnlyOnMouseDown(bool flag) {
263 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible) {
266 void RenderWidgetHostViewChildFrame::WindowFrameChanged() {
269 void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
272 bool RenderWidgetHostViewChildFrame::SupportsSpeech() const {
276 void RenderWidgetHostViewChildFrame::SpeakSelection() {
279 bool RenderWidgetHostViewChildFrame::IsSpeaking() const {
283 void RenderWidgetHostViewChildFrame::StopSpeaking() {
286 bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme(
287 const NativeWebKeyboardEvent& event) {
290 #endif // defined(OS_MACOSX)
292 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface(
293 const gfx::Rect& src_subrect,
294 const gfx::Size& /* dst_size */,
295 CopyFromCompositingSurfaceCallback& callback,
296 const SkColorType color_type) {
297 callback.Run(false, SkBitmap());
300 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
301 const gfx::Rect& src_subrect,
302 const scoped_refptr<media::VideoFrame>& target,
303 const base::Callback<void(bool)>& callback) {
308 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const {
312 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceSuspend() {
316 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceRelease() {
319 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface(
320 const gfx::Size& desired_size) {
324 gfx::GLSurfaceHandle RenderWidgetHostViewChildFrame::GetCompositingSurface() {
325 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT);
329 void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible(
330 gfx::NativeViewAccessible accessible_parent) {
333 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
337 #endif // defined(OS_WIN)
339 SkColorType RenderWidgetHostViewChildFrame::PreferredReadbackFormat() {
340 return kN32_SkColorType;
343 BrowserAccessibilityManager*
344 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
345 BrowserAccessibilityDelegate* delegate) {
346 return BrowserAccessibilityManager::Create(
347 BrowserAccessibilityManager::GetEmptyDocument(), delegate);
350 } // namespace content