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/frame_host/cross_process_frame_connector.h"
8 #include "content/browser/renderer_host/render_widget_host_impl.h"
9 #include "content/common/gpu/gpu_messages.h"
10 #include "content/common/view_messages.h"
11 #include "content/public/browser/render_process_host.h"
15 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame(
16 RenderWidgetHost* widget_host)
17 : host_(RenderWidgetHostImpl::From(widget_host)),
18 frame_connector_(NULL) {
22 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
25 void RenderWidgetHostViewChildFrame::InitAsChild(
26 gfx::NativeView parent_view) {
30 RenderWidgetHost* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const {
34 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();
71 rect.set_width(size_.width());
72 rect.set_height(size_.height());
76 gfx::NativeView RenderWidgetHostViewChildFrame::GetNativeView() const {
81 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetNativeViewId() const {
86 gfx::NativeViewAccessible
87 RenderWidgetHostViewChildFrame::GetNativeViewAccessible() {
92 void RenderWidgetHostViewChildFrame::SetBackground(
93 const SkBitmap& background) {
96 gfx::Size RenderWidgetHostViewChildFrame::GetPhysicalBackingSize() const {
100 void RenderWidgetHostViewChildFrame::InitAsPopup(
101 RenderWidgetHostView* parent_host_view,
102 const gfx::Rect& pos) {
106 void RenderWidgetHostViewChildFrame::InitAsFullscreen(
107 RenderWidgetHostView* reference_host_view) {
111 void RenderWidgetHostViewChildFrame::ImeCancelComposition() {
115 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
116 void RenderWidgetHostViewChildFrame::ImeCompositionRangeChanged(
117 const gfx::Range& range,
118 const std::vector<gfx::Rect>& character_bounds) {
123 void RenderWidgetHostViewChildFrame::DidUpdateBackingStore(
124 const gfx::Rect& scroll_rect,
125 const gfx::Vector2d& scroll_delta,
126 const std::vector<gfx::Rect>& copy_rects,
127 const std::vector<ui::LatencyInfo>& latency_info) {
131 void RenderWidgetHostViewChildFrame::WasShown() {
132 if (!host_->is_hidden())
137 void RenderWidgetHostViewChildFrame::WasHidden() {
138 if (host_->is_hidden())
143 void RenderWidgetHostViewChildFrame::MovePluginWindows(
144 const gfx::Vector2d& scroll_offset,
145 const std::vector<WebPluginGeometry>& moves) {
148 void RenderWidgetHostViewChildFrame::Blur() {
151 void RenderWidgetHostViewChildFrame::UpdateCursor(const WebCursor& cursor) {
154 void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading) {
158 void RenderWidgetHostViewChildFrame::TextInputTypeChanged(
159 ui::TextInputType type,
160 ui::TextInputMode input_mode,
161 bool can_compose_inline) {
165 void RenderWidgetHostViewChildFrame::RenderProcessGone(
166 base::TerminationStatus status,
168 if (frame_connector_)
169 frame_connector_->RenderProcessGone();
172 void RenderWidgetHostViewChildFrame::Destroy() {
173 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 void RenderWidgetHostViewChildFrame::ScrollOffsetChanged() {
197 void RenderWidgetHostViewChildFrame::OnAcceleratedCompositingStateChange() {
200 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceInitialized(int host_id,
204 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceBuffersSwapped(
205 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
207 if (frame_connector_)
208 frame_connector_->ChildFrameBuffersSwapped(params, gpu_host_id);
211 void RenderWidgetHostViewChildFrame::AcceleratedSurfacePostSubBuffer(
212 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
216 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
217 uint32 output_surface_id,
218 scoped_ptr<cc::CompositorFrame> frame) {
219 if (frame_connector_) {
220 frame_connector_->ChildFrameCompositorFrameSwapped(
222 host_->GetProcess()->GetID(),
223 host_->GetRoutingID(),
228 void RenderWidgetHostViewChildFrame::GetScreenInfo(
229 blink::WebScreenInfo* results) {
232 gfx::Rect RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
233 // We do not have any root window specific parts in this view.
234 return GetViewBounds();
237 #if defined(OS_WIN) || defined(USE_AURA)
238 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent(
239 const TouchEventWithLatencyInfo& touch,
240 InputEventAckState ack_result) {
242 #endif // defined(OS_WIN) || defined(USE_AURA)
244 bool RenderWidgetHostViewChildFrame::LockMouse() {
248 void RenderWidgetHostViewChildFrame::UnlockMouse() {
251 #if defined(OS_MACOSX)
252 void RenderWidgetHostViewChildFrame::SetActive(bool active) {
255 void RenderWidgetHostViewChildFrame::SetTakesFocusOnlyOnMouseDown(bool flag) {
258 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible) {
261 void RenderWidgetHostViewChildFrame::WindowFrameChanged() {
264 void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
267 bool RenderWidgetHostViewChildFrame::SupportsSpeech() const {
271 void RenderWidgetHostViewChildFrame::SpeakSelection() {
274 bool RenderWidgetHostViewChildFrame::IsSpeaking() const {
278 void RenderWidgetHostViewChildFrame::StopSpeaking() {
281 bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme(
282 const NativeWebKeyboardEvent& event) {
285 #endif // defined(OS_MACOSX)
287 #if defined(OS_ANDROID)
288 void RenderWidgetHostViewChildFrame::ShowDisambiguationPopup(
289 const gfx::Rect& target_rect,
290 const SkBitmap& zoomed_bitmap) {
292 #endif // defined(OS_ANDROID)
294 #if defined(TOOLKIT_GTK)
295 GdkEventButton* RenderWidgetHostViewChildFrame::GetLastMouseDown() {
299 gfx::NativeView RenderWidgetHostViewChildFrame::BuildInputMethodsGtkMenu() {
302 #endif // defined(TOOLKIT_GTK)
304 BackingStore* RenderWidgetHostViewChildFrame::AllocBackingStore(
305 const gfx::Size& size) {
310 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface(
311 const gfx::Rect& src_subrect,
312 const gfx::Size& /* dst_size */,
313 const base::Callback<void(bool, const SkBitmap&)>& callback,
314 const SkBitmap::Config config) {
315 callback.Run(false, SkBitmap());
318 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
319 const gfx::Rect& src_subrect,
320 const scoped_refptr<media::VideoFrame>& target,
321 const base::Callback<void(bool)>& callback) {
326 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const {
330 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceSuspend() {
334 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceRelease() {
337 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface(
338 const gfx::Size& desired_size) {
342 gfx::GLSurfaceHandle RenderWidgetHostViewChildFrame::GetCompositingSurface() {
343 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT);
346 void RenderWidgetHostViewChildFrame::SetHasHorizontalScrollbar(
347 bool has_horizontal_scrollbar) {
350 void RenderWidgetHostViewChildFrame::SetScrollOffsetPinning(
351 bool is_pinned_to_left, bool is_pinned_to_right) {
355 void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible(
356 gfx::NativeViewAccessible accessible_parent) {
359 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
363 #endif // defined(OS_WIN)
365 } // namespace content