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"
20 RenderWidgetHostViewGuest::RenderWidgetHostViewGuest(
21 RenderWidgetHost
* widget_host
,
22 BrowserPluginGuest
* guest
)
23 : host_(RenderWidgetHostImpl::From(widget_host
)),
29 RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() {
32 RenderWidgetHost
* RenderWidgetHostViewGuest::GetRenderWidgetHost() const {
36 void RenderWidgetHostViewGuest::WasShown() {
44 void RenderWidgetHostViewGuest::WasHidden() {
52 void RenderWidgetHostViewGuest::SetSize(const gfx::Size
& size
) {
57 gfx::Rect
RenderWidgetHostViewGuest::GetBoundsInRootWindow() {
58 return GetViewBounds();
61 gfx::GLSurfaceHandle
RenderWidgetHostViewGuest::GetCompositingSurface() {
62 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow
, true);
65 void RenderWidgetHostViewGuest::Show() {
69 void RenderWidgetHostViewGuest::Hide() {
73 bool RenderWidgetHostViewGuest::IsShowing() {
77 gfx::Rect
RenderWidgetHostViewGuest::GetViewBounds() const {
78 return gfx::Rect(0, 0, size_
.width(), size_
.height());
81 void RenderWidgetHostViewGuest::RenderViewGone(base::TerminationStatus status
,
86 void RenderWidgetHostViewGuest::Destroy() {
87 // The RenderWidgetHost's destruction led here, so don't call it.
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
,
98 guest_
->SendMessageToEmbedder(
99 new BrowserPluginMsg_BuffersSwapped(
100 guest_
->embedder_routing_id(),
101 guest_
->instance_id(),
103 params
.surface_handle
,
108 void RenderWidgetHostViewGuest::AcceleratedSurfacePostSubBuffer(
109 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params
& params
,
111 guest_
->SendMessageToEmbedder(
112 new BrowserPluginMsg_BuffersSwapped(
113 guest_
->embedder_routing_id(),
114 guest_
->instance_id(),
116 params
.surface_handle
,
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(),
136 void RenderWidgetHostViewGuest::InitAsChild(
137 gfx::NativeView parent_view
) {
141 void RenderWidgetHostViewGuest::InitAsPopup(
142 RenderWidgetHostView
* parent_host_view
, const gfx::Rect
& pos
) {
146 void RenderWidgetHostViewGuest::InitAsFullscreen(
147 RenderWidgetHostView
* reference_host_view
) {
151 gfx::NativeView
RenderWidgetHostViewGuest::GetNativeView() const {
156 gfx::NativeViewId
RenderWidgetHostViewGuest::GetNativeViewId() const {
158 return static_cast<gfx::NativeViewId
>(NULL
);
161 gfx::NativeViewAccessible
RenderWidgetHostViewGuest::GetNativeViewAccessible() {
166 void RenderWidgetHostViewGuest::MovePluginWindows(
167 const gfx::Vector2d
& scroll_offset
,
168 const std::vector
<webkit::npapi::WebPluginGeometry
>& moves
) {
172 void RenderWidgetHostViewGuest::Focus() {
176 void RenderWidgetHostViewGuest::Blur() {
180 bool RenderWidgetHostViewGuest::HasFocus() const {
185 bool RenderWidgetHostViewGuest::IsSurfaceAvailableForCopy() const {
190 void RenderWidgetHostViewGuest::UpdateCursor(const WebCursor
& cursor
) {
194 void RenderWidgetHostViewGuest::SetIsLoading(bool is_loading
) {
198 void RenderWidgetHostViewGuest::TextInputStateChanged(
199 const ViewHostMsg_TextInputState_Params
& params
) {
203 void RenderWidgetHostViewGuest::ImeCancelComposition() {
207 void RenderWidgetHostViewGuest::DidUpdateBackingStore(
208 const gfx::Rect
& scroll_rect
,
209 const gfx::Vector2d
& scroll_delta
,
210 const std::vector
<gfx::Rect
>& copy_rects
) {
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
) {
222 BackingStore
* RenderWidgetHostViewGuest::AllocBackingStore(
223 const gfx::Size
& size
) {
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
) {
236 void RenderWidgetHostViewGuest::AcceleratedSurfaceSuspend() {
240 bool RenderWidgetHostViewGuest::HasAcceleratedSurface(
241 const gfx::Size
& desired_size
) {
246 void RenderWidgetHostViewGuest::SetBackground(const SkBitmap
& background
) {
250 void RenderWidgetHostViewGuest::SetHasHorizontalScrollbar(
251 bool has_horizontal_scrollbar
) {
255 void RenderWidgetHostViewGuest::SetScrollOffsetPinning(
256 bool is_pinned_to_left
, bool is_pinned_to_right
) {
260 void RenderWidgetHostViewGuest::OnAcceleratedCompositingStateChange() {
264 bool RenderWidgetHostViewGuest::LockMouse() {
269 void RenderWidgetHostViewGuest::UnlockMouse() {
273 #if defined(OS_MACOSX)
274 void RenderWidgetHostViewGuest::SetActive(bool active
) {
278 void RenderWidgetHostViewGuest::SetTakesFocusOnlyOnMouseDown(bool flag
) {
282 void RenderWidgetHostViewGuest::SetWindowVisibility(bool visible
) {
286 void RenderWidgetHostViewGuest::WindowFrameChanged() {
290 void RenderWidgetHostViewGuest::ShowDefinitionForSelection() {
294 bool RenderWidgetHostViewGuest::SupportsSpeech() const {
299 void RenderWidgetHostViewGuest::SpeakSelection() {
303 bool RenderWidgetHostViewGuest::IsSpeaking() const {
308 void RenderWidgetHostViewGuest::StopSpeaking() {
312 void RenderWidgetHostViewGuest::AboutToWaitForBackingStoreMsg() {
316 void RenderWidgetHostViewGuest::PluginFocusChanged(bool focused
,
321 void RenderWidgetHostViewGuest::StartPluginIme() {
325 bool RenderWidgetHostViewGuest::PostProcessEventForPluginIme(
326 const NativeWebKeyboardEvent
& event
) {
331 gfx::PluginWindowHandle
332 RenderWidgetHostViewGuest::AllocateFakePluginWindowHandle(
333 bool opaque
, bool root
) {
338 void RenderWidgetHostViewGuest::DestroyFakePluginWindowHandle(
339 gfx::PluginWindowHandle window
) {
343 void RenderWidgetHostViewGuest::AcceleratedSurfaceSetIOSurface(
344 gfx::PluginWindowHandle window
,
347 uint64 io_surface_identifier
) {
351 void RenderWidgetHostViewGuest::AcceleratedSurfaceSetTransportDIB(
352 gfx::PluginWindowHandle window
,
355 TransportDIB::Handle transport_dib
) {
358 #endif // defined(OS_MACOSX)
360 #if defined(OS_ANDROID)
361 void RenderWidgetHostViewGuest::StartContentIntent(const GURL
& content_url
) {
365 void RenderWidgetHostViewGuest::SetCachedBackgroundColor(SkColor color
) {
369 void RenderWidgetHostViewGuest::ShowDisambiguationPopup(
370 const gfx::Rect
& target_rect
,
371 const SkBitmap
& zoomed_bitmap
) {
375 void RenderWidgetHostViewGuest::SetCachedPageScaleFactorLimits(
377 float maximum_scale
) {
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
) {
390 void RenderWidgetHostViewGuest::HasTouchEventHandlers(bool need_touch_events
) {
393 #endif // defined(OS_ANDROID)
395 #if defined(TOOLKIT_GTK)
396 GdkEventButton
* RenderWidgetHostViewGuest::GetLastMouseDown() {
401 gfx::NativeView
RenderWidgetHostViewGuest::BuildInputMethodsGtkMenu() {
403 return gfx::NativeView();
406 void RenderWidgetHostViewGuest::CreatePluginContainer(
407 gfx::PluginWindowHandle id
) {
411 void RenderWidgetHostViewGuest::DestroyPluginContainer(
412 gfx::PluginWindowHandle id
) {
415 #endif // defined(TOOLKIT_GTK)
417 #if defined(OS_WIN) && !defined(USE_AURA)
418 void RenderWidgetHostViewGuest::WillWmDestroy() {
423 #if defined(OS_POSIX) || defined(USE_AURA)
424 void RenderWidgetHostViewGuest::GetScreenInfo(WebKit::WebScreenInfo
* results
) {
427 #endif // defined(OS_POSIX) || defined(USE_AURA)
429 } // namespace content