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.
4
5#include "content/browser/frame_host/render_widget_host_view_child_frame.h"
6
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"
13
14namespace content {
15
16RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame(
17    RenderWidgetHost* widget_host)
18    : host_(RenderWidgetHostImpl::From(widget_host)),
19      frame_connector_(NULL) {
20  host_->SetView(this);
21}
22
23RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
24}
25
26void RenderWidgetHostViewChildFrame::InitAsChild(
27    gfx::NativeView parent_view) {
28  NOTREACHED();
29}
30
31RenderWidgetHost* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const {
32  return host_;
33}
34
35void RenderWidgetHostViewChildFrame::SetSize(const gfx::Size& size) {
36  host_->WasResized();
37}
38
39void RenderWidgetHostViewChildFrame::SetBounds(const gfx::Rect& rect) {
40  SetSize(rect.size());
41}
42
43void RenderWidgetHostViewChildFrame::Focus() {
44}
45
46bool RenderWidgetHostViewChildFrame::HasFocus() const {
47  return false;
48}
49
50bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() const {
51  NOTIMPLEMENTED();
52  return false;
53}
54
55void RenderWidgetHostViewChildFrame::Show() {
56  WasShown();
57}
58
59void RenderWidgetHostViewChildFrame::Hide() {
60  WasHidden();
61}
62
63bool RenderWidgetHostViewChildFrame::IsShowing() {
64  return !host_->is_hidden();
65}
66
67gfx::Rect RenderWidgetHostViewChildFrame::GetViewBounds() const {
68  gfx::Rect rect;
69  if (frame_connector_)
70    rect = frame_connector_->ChildFrameRect();
71  return rect;
72}
73
74gfx::Vector2dF RenderWidgetHostViewChildFrame::GetLastScrollOffset() const {
75  return last_scroll_offset_;
76}
77
78gfx::NativeView RenderWidgetHostViewChildFrame::GetNativeView() const {
79  NOTREACHED();
80  return NULL;
81}
82
83gfx::NativeViewId RenderWidgetHostViewChildFrame::GetNativeViewId() const {
84  NOTREACHED();
85  return 0;
86}
87
88gfx::NativeViewAccessible
89RenderWidgetHostViewChildFrame::GetNativeViewAccessible() {
90  NOTREACHED();
91  return NULL;
92}
93
94void RenderWidgetHostViewChildFrame::SetBackgroundOpaque(bool opaque) {
95}
96
97gfx::Size RenderWidgetHostViewChildFrame::GetPhysicalBackingSize() const {
98  gfx::Size size;
99  if (frame_connector_)
100    size = frame_connector_->ChildFrameRect().size();
101  return size;
102}
103
104void RenderWidgetHostViewChildFrame::InitAsPopup(
105    RenderWidgetHostView* parent_host_view,
106    const gfx::Rect& pos) {
107  NOTREACHED();
108}
109
110void RenderWidgetHostViewChildFrame::InitAsFullscreen(
111    RenderWidgetHostView* reference_host_view) {
112  NOTREACHED();
113}
114
115void RenderWidgetHostViewChildFrame::ImeCancelComposition() {
116  NOTREACHED();
117}
118
119#if defined(OS_MACOSX) || defined(USE_AURA)
120void RenderWidgetHostViewChildFrame::ImeCompositionRangeChanged(
121    const gfx::Range& range,
122    const std::vector<gfx::Rect>& character_bounds) {
123  NOTREACHED();
124}
125#endif
126
127void RenderWidgetHostViewChildFrame::WasShown() {
128  if (!host_->is_hidden())
129    return;
130  host_->WasShown(ui::LatencyInfo());
131}
132
133void RenderWidgetHostViewChildFrame::WasHidden() {
134  if (host_->is_hidden())
135    return;
136  host_->WasHidden();
137}
138
139void RenderWidgetHostViewChildFrame::MovePluginWindows(
140    const std::vector<WebPluginGeometry>& moves) {
141}
142
143void RenderWidgetHostViewChildFrame::Blur() {
144}
145
146void RenderWidgetHostViewChildFrame::UpdateCursor(const WebCursor& cursor) {
147}
148
149void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading) {
150  NOTREACHED();
151}
152
153void RenderWidgetHostViewChildFrame::TextInputTypeChanged(
154    ui::TextInputType type,
155    ui::TextInputMode input_mode,
156    bool can_compose_inline) {
157  NOTREACHED();
158}
159
160void RenderWidgetHostViewChildFrame::RenderProcessGone(
161    base::TerminationStatus status,
162    int error_code) {
163  if (frame_connector_)
164    frame_connector_->RenderProcessGone();
165  Destroy();
166}
167
168void RenderWidgetHostViewChildFrame::Destroy() {
169  if (frame_connector_) {
170    frame_connector_->set_view(NULL);
171    frame_connector_ = NULL;
172  }
173
174  host_->SetView(NULL);
175  host_ = NULL;
176  base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
177}
178
179void RenderWidgetHostViewChildFrame::SetTooltipText(
180    const base::string16& tooltip_text) {
181}
182
183void RenderWidgetHostViewChildFrame::SelectionChanged(
184    const base::string16& text,
185    size_t offset,
186    const gfx::Range& range) {
187}
188
189void RenderWidgetHostViewChildFrame::SelectionBoundsChanged(
190    const ViewHostMsg_SelectionBounds_Params& params) {
191}
192
193#if defined(OS_ANDROID) || defined(TOOLKIT_VIEWS) || defined(USE_AURA)
194void RenderWidgetHostViewChildFrame::ShowDisambiguationPopup(
195    const gfx::Rect& rect_pixels,
196    const SkBitmap& zoomed_bitmap) {
197}
198#endif
199
200#if defined(OS_ANDROID)
201void RenderWidgetHostViewChildFrame::LockCompositingSurface() {
202}
203
204void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() {
205}
206#endif
207
208void RenderWidgetHostViewChildFrame::AcceleratedSurfaceInitialized(int host_id,
209                                                              int route_id) {
210}
211
212void RenderWidgetHostViewChildFrame::AcceleratedSurfaceBuffersSwapped(
213    const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
214    int gpu_host_id) {
215  NOTREACHED();
216}
217
218void RenderWidgetHostViewChildFrame::AcceleratedSurfacePostSubBuffer(
219    const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
220    int gpu_host_id) {
221}
222
223void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
224      uint32 output_surface_id,
225      scoped_ptr<cc::CompositorFrame> frame) {
226  last_scroll_offset_ = frame->metadata.root_scroll_offset;
227  if (frame_connector_) {
228    frame_connector_->ChildFrameCompositorFrameSwapped(
229        output_surface_id,
230        host_->GetProcess()->GetID(),
231        host_->GetRoutingID(),
232        frame.Pass());
233  }
234}
235
236void RenderWidgetHostViewChildFrame::GetScreenInfo(
237    blink::WebScreenInfo* results) {
238}
239
240gfx::Rect RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
241  // We do not have any root window specific parts in this view.
242  return GetViewBounds();
243}
244
245#if defined(USE_AURA)
246void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent(
247    const TouchEventWithLatencyInfo& touch,
248    InputEventAckState ack_result) {
249}
250#endif  // defined(USE_AURA)
251
252bool RenderWidgetHostViewChildFrame::LockMouse() {
253  return false;
254}
255
256void RenderWidgetHostViewChildFrame::UnlockMouse() {
257}
258
259#if defined(OS_MACOSX)
260void RenderWidgetHostViewChildFrame::SetActive(bool active) {
261}
262
263void RenderWidgetHostViewChildFrame::SetTakesFocusOnlyOnMouseDown(bool flag) {
264}
265
266void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible) {
267}
268
269void RenderWidgetHostViewChildFrame::WindowFrameChanged() {
270}
271
272void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
273}
274
275bool RenderWidgetHostViewChildFrame::SupportsSpeech() const {
276  return false;
277}
278
279void RenderWidgetHostViewChildFrame::SpeakSelection() {
280}
281
282bool RenderWidgetHostViewChildFrame::IsSpeaking() const {
283  return false;
284}
285
286void RenderWidgetHostViewChildFrame::StopSpeaking() {
287}
288
289bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme(
290      const NativeWebKeyboardEvent& event) {
291  return false;
292}
293#endif // defined(OS_MACOSX)
294
295void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface(
296    const gfx::Rect& src_subrect,
297    const gfx::Size& /* dst_size */,
298    CopyFromCompositingSurfaceCallback& callback,
299    const SkColorType color_type) {
300  callback.Run(false, SkBitmap());
301}
302
303void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
304      const gfx::Rect& src_subrect,
305      const scoped_refptr<media::VideoFrame>& target,
306      const base::Callback<void(bool)>& callback) {
307  NOTIMPLEMENTED();
308  callback.Run(false);
309}
310
311bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const {
312  return false;
313}
314
315void RenderWidgetHostViewChildFrame::AcceleratedSurfaceSuspend() {
316  NOTREACHED();
317}
318
319void RenderWidgetHostViewChildFrame::AcceleratedSurfaceRelease() {
320}
321
322bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface(
323      const gfx::Size& desired_size) {
324  return false;
325}
326
327gfx::GLSurfaceHandle RenderWidgetHostViewChildFrame::GetCompositingSurface() {
328  return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT);
329}
330
331#if defined(OS_WIN)
332void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible(
333    gfx::NativeViewAccessible accessible_parent) {
334}
335
336gfx::NativeViewId RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
337    const {
338  return NULL;
339}
340#endif // defined(OS_WIN)
341
342SkColorType RenderWidgetHostViewChildFrame::PreferredReadbackFormat() {
343  return kN32_SkColorType;
344}
345
346BrowserAccessibilityManager*
347RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
348    BrowserAccessibilityDelegate* delegate) {
349  return BrowserAccessibilityManager::Create(
350      BrowserAccessibilityManager::GetEmptyDocument(), delegate);
351}
352
353}  // namespace content
354