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. 4 5#ifndef CONTENT_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_ 6#define CONTENT_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_ 7 8#include "base/memory/scoped_ptr.h" 9#include "content/renderer/mouse_lock_dispatcher.h" 10#include "content/renderer/pepper/fullscreen_container.h" 11#include "content/renderer/render_widget_fullscreen.h" 12#include "third_party/WebKit/public/web/WebWidget.h" 13 14namespace WebKit { 15class WebLayer; 16} 17 18namespace content { 19class PepperPluginInstanceImpl; 20 21// A RenderWidget that hosts a fullscreen pepper plugin. This provides a 22// FullscreenContainer that the plugin instance can callback into to e.g. 23// invalidate rects. 24class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen, 25 public FullscreenContainer { 26 public: 27 static RenderWidgetFullscreenPepper* Create( 28 int32 opener_id, 29 PepperPluginInstanceImpl* plugin, 30 const GURL& active_url, 31 const WebKit::WebScreenInfo& screen_info); 32 33 // pepper::FullscreenContainer API. 34 virtual void Invalidate() OVERRIDE; 35 virtual void InvalidateRect(const WebKit::WebRect& rect) OVERRIDE; 36 virtual void ScrollRect(int dx, int dy, const WebKit::WebRect& rect) OVERRIDE; 37 virtual void Destroy() OVERRIDE; 38 virtual void DidChangeCursor(const WebKit::WebCursorInfo& cursor) OVERRIDE; 39 virtual void SetLayer(WebKit::WebLayer* layer) OVERRIDE; 40 41 // IPC::Listener implementation. This overrides the implementation 42 // in RenderWidgetFullscreen. 43 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 44 45 // Could be NULL when this widget is closing. 46 PepperPluginInstanceImpl* plugin() const { return plugin_; } 47 48 MouseLockDispatcher* mouse_lock_dispatcher() const { 49 return mouse_lock_dispatcher_.get(); 50 } 51 52 bool is_compositing() const { return !!layer_; } 53 54 protected: 55 RenderWidgetFullscreenPepper(PepperPluginInstanceImpl* plugin, 56 const GURL& active_url, 57 const WebKit::WebScreenInfo& screen_info); 58 virtual ~RenderWidgetFullscreenPepper(); 59 60 // RenderWidget API. 61 virtual void WillInitiatePaint() OVERRIDE; 62 virtual void DidInitiatePaint() OVERRIDE; 63 virtual void DidFlushPaint() OVERRIDE; 64 virtual void Close() OVERRIDE; 65 virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint( 66 const gfx::Rect& paint_bounds, 67 TransportDIB** dib, 68 gfx::Rect* location, 69 gfx::Rect* clip, 70 float* scale_factor) OVERRIDE; 71 virtual void OnResize(const ViewMsg_Resize_Params& params) OVERRIDE; 72 73 // RenderWidgetFullscreen API. 74 virtual WebKit::WebWidget* CreateWebWidget() OVERRIDE; 75 76 // RenderWidget overrides. 77 virtual GURL GetURLForGraphicsContext3D() OVERRIDE; 78 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE; 79 80 private: 81 // URL that is responsible for this widget, passed to ggl::CreateViewContext. 82 GURL active_url_; 83 84 // The plugin instance this widget wraps. 85 PepperPluginInstanceImpl* plugin_; 86 87 WebKit::WebLayer* layer_; 88 89 scoped_ptr<MouseLockDispatcher> mouse_lock_dispatcher_; 90 91 DISALLOW_COPY_AND_ASSIGN(RenderWidgetFullscreenPepper); 92}; 93 94} // namespace content 95 96#endif // CONTENT_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_ 97