Message forwarding code for for webview compositing.
[chromium-blink-merge.git] / content / browser / renderer_host / render_widget_host_view_guest.cc
blobf216fc85c4411c52ef7c8ba3e90eec27aaee5c42
1 // Copyright (c) 2012 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 "base/bind_helpers.h"
6 #include "base/logging.h"
7 #include "base/message_loop.h"
8 #include "content/browser/browser_plugin/browser_plugin_guest.h"
9 #include "content/browser/renderer_host/render_view_host_impl.h"
10 #include "content/browser/renderer_host/render_widget_host_view_guest.h"
11 #include "content/common/browser_plugin_messages.h"
12 #include "content/common/gpu/gpu_messages.h"
13 #include "content/common/view_messages.h"
14 #include "skia/ext/platform_canvas.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
16 #include "webkit/plugins/npapi/webplugin.h"
18 namespace content {
20 RenderWidgetHostViewGuest::RenderWidgetHostViewGuest(
21 RenderWidgetHost* widget_host,
22 BrowserPluginGuest* guest)
23 : host_(RenderWidgetHostImpl::From(widget_host)),
24 is_hidden_(false),
25 guest_(guest) {
26 host_->SetView(this);
29 RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() {
32 RenderWidgetHost* RenderWidgetHostViewGuest::GetRenderWidgetHost() const {
33 return host_;
36 void RenderWidgetHostViewGuest::WasShown() {
37 if (!is_hidden_)
38 return;
40 is_hidden_ = false;
41 host_->WasShown();
44 void RenderWidgetHostViewGuest::WasHidden() {
45 if (is_hidden_)
46 return;
48 is_hidden_ = true;
49 host_->WasHidden();
52 void RenderWidgetHostViewGuest::SetSize(const gfx::Size& size) {
53 size_ = size;
54 host_->WasResized();
57 gfx::Rect RenderWidgetHostViewGuest::GetBoundsInRootWindow() {
58 return GetViewBounds();
61 gfx::GLSurfaceHandle RenderWidgetHostViewGuest::GetCompositingSurface() {
62 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true);
65 void RenderWidgetHostViewGuest::Show() {
66 WasShown();
69 void RenderWidgetHostViewGuest::Hide() {
70 WasHidden();
73 bool RenderWidgetHostViewGuest::IsShowing() {
74 return !is_hidden_;
77 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const {
78 return gfx::Rect(0, 0, size_.width(), size_.height());
81 void RenderWidgetHostViewGuest::RenderViewGone(base::TerminationStatus status,
82 int error_code) {
83 Destroy();
86 void RenderWidgetHostViewGuest::Destroy() {
87 // The RenderWidgetHost's destruction led here, so don't call it.
88 host_ = NULL;
89 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
92 void RenderWidgetHostViewGuest::SetTooltipText(const string16& tooltip_text) {
95 void RenderWidgetHostViewGuest::AcceleratedSurfaceBuffersSwapped(
96 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
97 int gpu_host_id) {
98 guest_->SendMessageToEmbedder(
99 new BrowserPluginMsg_BuffersSwapped(
100 guest_->embedder_routing_id(),
101 guest_->instance_id(),
102 params.size,
103 params.surface_handle,
104 params.route_id,
105 gpu_host_id));
108 void RenderWidgetHostViewGuest::AcceleratedSurfacePostSubBuffer(
109 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
110 int gpu_host_id) {
111 guest_->SendMessageToEmbedder(
112 new BrowserPluginMsg_BuffersSwapped(
113 guest_->embedder_routing_id(),
114 guest_->instance_id(),
115 params.surface_size,
116 params.surface_handle,
117 params.route_id,
118 gpu_host_id));
121 void RenderWidgetHostViewGuest::SetBounds(const gfx::Rect& rect) {
122 SetSize(rect.size());
125 void RenderWidgetHostViewGuest::AcceleratedSurfaceNew(
126 uint64 surface_handle,
127 const std::string& mailbox_name) {
128 guest_->SendMessageToEmbedder(
129 new BrowserPluginMsg_AcceleratedSurfaceNew(
130 guest_->embedder_routing_id(),
131 guest_->instance_id(),
132 surface_handle,
133 mailbox_name));
136 void RenderWidgetHostViewGuest::InitAsChild(
137 gfx::NativeView parent_view) {
138 NOTIMPLEMENTED();
141 void RenderWidgetHostViewGuest::InitAsPopup(
142 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) {
143 NOTIMPLEMENTED();
146 void RenderWidgetHostViewGuest::InitAsFullscreen(
147 RenderWidgetHostView* reference_host_view) {
148 NOTIMPLEMENTED();
151 gfx::NativeView RenderWidgetHostViewGuest::GetNativeView() const {
152 NOTIMPLEMENTED();
153 return NULL;
156 gfx::NativeViewId RenderWidgetHostViewGuest::GetNativeViewId() const {
157 NOTIMPLEMENTED();
158 return static_cast<gfx::NativeViewId>(NULL);
161 gfx::NativeViewAccessible RenderWidgetHostViewGuest::GetNativeViewAccessible() {
162 NOTIMPLEMENTED();
163 return NULL;
166 void RenderWidgetHostViewGuest::MovePluginWindows(
167 const gfx::Vector2d& scroll_offset,
168 const std::vector<webkit::npapi::WebPluginGeometry>& moves) {
169 NOTIMPLEMENTED();
172 void RenderWidgetHostViewGuest::Focus() {
173 NOTIMPLEMENTED();
176 void RenderWidgetHostViewGuest::Blur() {
177 NOTIMPLEMENTED();
180 bool RenderWidgetHostViewGuest::HasFocus() const {
181 NOTIMPLEMENTED();
182 return false;
185 bool RenderWidgetHostViewGuest::IsSurfaceAvailableForCopy() const {
186 NOTIMPLEMENTED();
187 return true;
190 void RenderWidgetHostViewGuest::UpdateCursor(const WebCursor& cursor) {
191 NOTIMPLEMENTED();
194 void RenderWidgetHostViewGuest::SetIsLoading(bool is_loading) {
195 NOTIMPLEMENTED();
198 void RenderWidgetHostViewGuest::TextInputStateChanged(
199 const ViewHostMsg_TextInputState_Params& params) {
200 NOTIMPLEMENTED();
203 void RenderWidgetHostViewGuest::ImeCancelComposition() {
204 NOTIMPLEMENTED();
207 void RenderWidgetHostViewGuest::DidUpdateBackingStore(
208 const gfx::Rect& scroll_rect,
209 const gfx::Vector2d& scroll_delta,
210 const std::vector<gfx::Rect>& copy_rects) {
211 NOTIMPLEMENTED();
214 void RenderWidgetHostViewGuest::SelectionBoundsChanged(
215 const gfx::Rect& start_rect,
216 WebKit::WebTextDirection start_direction,
217 const gfx::Rect& end_rect,
218 WebKit::WebTextDirection end_direction) {
219 NOTIMPLEMENTED();
222 BackingStore* RenderWidgetHostViewGuest::AllocBackingStore(
223 const gfx::Size& size) {
224 NOTIMPLEMENTED();
225 return NULL;
228 void RenderWidgetHostViewGuest::CopyFromCompositingSurface(
229 const gfx::Rect& src_subrect,
230 const gfx::Size& /* dst_size */,
231 const base::Callback<void(bool)>& callback,
232 skia::PlatformBitmap* output) {
233 NOTIMPLEMENTED();
236 void RenderWidgetHostViewGuest::AcceleratedSurfaceSuspend() {
237 NOTIMPLEMENTED();
240 bool RenderWidgetHostViewGuest::HasAcceleratedSurface(
241 const gfx::Size& desired_size) {
242 NOTIMPLEMENTED();
243 return false;
246 void RenderWidgetHostViewGuest::SetBackground(const SkBitmap& background) {
247 NOTIMPLEMENTED();
250 void RenderWidgetHostViewGuest::SetHasHorizontalScrollbar(
251 bool has_horizontal_scrollbar) {
252 NOTIMPLEMENTED();
255 void RenderWidgetHostViewGuest::SetScrollOffsetPinning(
256 bool is_pinned_to_left, bool is_pinned_to_right) {
257 NOTIMPLEMENTED();
260 void RenderWidgetHostViewGuest::OnAcceleratedCompositingStateChange() {
261 NOTIMPLEMENTED();
264 bool RenderWidgetHostViewGuest::LockMouse() {
265 NOTIMPLEMENTED();
266 return false;
269 void RenderWidgetHostViewGuest::UnlockMouse() {
270 NOTIMPLEMENTED();
273 #if defined(OS_MACOSX)
274 void RenderWidgetHostViewGuest::SetActive(bool active) {
275 NOTIMPLEMENTED();
278 void RenderWidgetHostViewGuest::SetTakesFocusOnlyOnMouseDown(bool flag) {
279 NOTIMPLEMENTED();
282 void RenderWidgetHostViewGuest::SetWindowVisibility(bool visible) {
283 NOTIMPLEMENTED();
286 void RenderWidgetHostViewGuest::WindowFrameChanged() {
287 NOTIMPLEMENTED();
290 void RenderWidgetHostViewGuest::ShowDefinitionForSelection() {
291 NOTIMPLEMENTED();
294 bool RenderWidgetHostViewGuest::SupportsSpeech() const {
295 NOTIMPLEMENTED();
296 return false;
299 void RenderWidgetHostViewGuest::SpeakSelection() {
300 NOTIMPLEMENTED();
303 bool RenderWidgetHostViewGuest::IsSpeaking() const {
304 NOTIMPLEMENTED();
305 return false;
308 void RenderWidgetHostViewGuest::StopSpeaking() {
309 NOTIMPLEMENTED();
312 void RenderWidgetHostViewGuest::AboutToWaitForBackingStoreMsg() {
313 NOTIMPLEMENTED();
316 void RenderWidgetHostViewGuest::PluginFocusChanged(bool focused,
317 int plugin_id) {
318 NOTIMPLEMENTED();
321 void RenderWidgetHostViewGuest::StartPluginIme() {
322 NOTIMPLEMENTED();
325 bool RenderWidgetHostViewGuest::PostProcessEventForPluginIme(
326 const NativeWebKeyboardEvent& event) {
327 NOTIMPLEMENTED();
328 return false;
331 gfx::PluginWindowHandle
332 RenderWidgetHostViewGuest::AllocateFakePluginWindowHandle(
333 bool opaque, bool root) {
334 NOTIMPLEMENTED();
335 return 0;
338 void RenderWidgetHostViewGuest::DestroyFakePluginWindowHandle(
339 gfx::PluginWindowHandle window) {
340 NOTIMPLEMENTED();
343 void RenderWidgetHostViewGuest::AcceleratedSurfaceSetIOSurface(
344 gfx::PluginWindowHandle window,
345 int32 width,
346 int32 height,
347 uint64 io_surface_identifier) {
348 NOTIMPLEMENTED();
351 void RenderWidgetHostViewGuest::AcceleratedSurfaceSetTransportDIB(
352 gfx::PluginWindowHandle window,
353 int32 width,
354 int32 height,
355 TransportDIB::Handle transport_dib) {
356 NOTIMPLEMENTED();
358 #endif // defined(OS_MACOSX)
360 #if defined(OS_ANDROID)
361 void RenderWidgetHostViewGuest::StartContentIntent(const GURL& content_url) {
362 NOTIMPLEMENTED();
365 void RenderWidgetHostViewGuest::SetCachedBackgroundColor(SkColor color) {
366 NOTIMPLEMENTED();
369 void RenderWidgetHostViewGuest::ShowDisambiguationPopup(
370 const gfx::Rect& target_rect,
371 const SkBitmap& zoomed_bitmap) {
372 NOTIMPLEMENTED();
375 void RenderWidgetHostViewGuest::SetCachedPageScaleFactorLimits(
376 float minimum_scale,
377 float maximum_scale) {
378 NOTIMPLEMENTED();
381 void RenderWidgetHostViewGuest::UpdateFrameInfo(
382 const gfx::Vector2d& scroll_offset,
383 float page_scale_factor,
384 float min_page_scale_factor,
385 float max_page_scale_factor,
386 const gfx::Size& content_size) {
387 NOTIMPLEMENTED();
390 void RenderWidgetHostViewGuest::HasTouchEventHandlers(bool need_touch_events) {
391 NOTIMPLEMENTED();
393 #endif // defined(OS_ANDROID)
395 #if defined(TOOLKIT_GTK)
396 GdkEventButton* RenderWidgetHostViewGuest::GetLastMouseDown() {
397 NOTIMPLEMENTED();
398 return NULL;
401 gfx::NativeView RenderWidgetHostViewGuest::BuildInputMethodsGtkMenu() {
402 NOTIMPLEMENTED();
403 return gfx::NativeView();
406 void RenderWidgetHostViewGuest::CreatePluginContainer(
407 gfx::PluginWindowHandle id) {
408 NOTIMPLEMENTED();
411 void RenderWidgetHostViewGuest::DestroyPluginContainer(
412 gfx::PluginWindowHandle id) {
413 NOTIMPLEMENTED();
415 #endif // defined(TOOLKIT_GTK)
417 #if defined(OS_WIN) && !defined(USE_AURA)
418 void RenderWidgetHostViewGuest::WillWmDestroy() {
419 NOTIMPLEMENTED();
421 #endif
423 #if defined(OS_POSIX) || defined(USE_AURA)
424 void RenderWidgetHostViewGuest::GetScreenInfo(WebKit::WebScreenInfo* results) {
425 NOTIMPLEMENTED();
427 #endif // defined(OS_POSIX) || defined(USE_AURA)
429 } // namespace content