diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-14 22:28:39 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-14 22:28:39 +0000 |
commit | 79c7bedcd3d2e7808fc4dd9745ac2bf5fbca460b (patch) | |
tree | f29089b8f66f79b4ab1e0c7af8432a1ba372cdd9 /chrome/renderer | |
parent | 5b84fe3a0f6b9319e18f31db4d3c943616a91090 (diff) | |
download | chromium_src-79c7bedcd3d2e7808fc4dd9745ac2bf5fbca460b.zip chromium_src-79c7bedcd3d2e7808fc4dd9745ac2bf5fbca460b.tar.gz chromium_src-79c7bedcd3d2e7808fc4dd9745ac2bf5fbca460b.tar.bz2 |
Add fullscreen support to Pepper.
This needs http://codereview.chromium.org/3320019/show first for the Pepper interfaces to be there.
BUG=none
TEST=run a pepper test application, trigger fullscreen on and off.
Review URL: http://codereview.chromium.org/3352019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59440 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/pepper_plugin_delegate_impl.cc | 6 | ||||
-rw-r--r-- | chrome/renderer/pepper_plugin_delegate_impl.h | 2 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 9 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 9 | ||||
-rw-r--r-- | chrome/renderer/render_widget_fullscreen.cc | 8 | ||||
-rw-r--r-- | chrome/renderer/render_widget_fullscreen.h | 4 | ||||
-rw-r--r-- | chrome/renderer/render_widget_fullscreen_pepper.cc | 212 | ||||
-rw-r--r-- | chrome/renderer/render_widget_fullscreen_pepper.h | 58 |
8 files changed, 300 insertions, 8 deletions
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc index a3f2735..511b284 100644 --- a/chrome/renderer/pepper_plugin_delegate_impl.cc +++ b/chrome/renderer/pepper_plugin_delegate_impl.cc @@ -641,3 +641,9 @@ scoped_refptr<base::MessageLoopProxy> PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() { return RenderThread::current()->GetFileThreadMessageLoopProxy(); } + +pepper::FullscreenContainer* +PepperPluginDelegateImpl::CreateFullscreenContainer( + pepper::PluginInstance* instance) { + return render_view_->CreatePepperFullscreenContainer(instance); +} diff --git a/chrome/renderer/pepper_plugin_delegate_impl.h b/chrome/renderer/pepper_plugin_delegate_impl.h index ebc19ee..180ce43 100644 --- a/chrome/renderer/pepper_plugin_delegate_impl.h +++ b/chrome/renderer/pepper_plugin_delegate_impl.h @@ -67,6 +67,8 @@ class PepperPluginDelegateImpl int flags, AsyncOpenFileCallback* callback); virtual scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy(); + virtual pepper::FullscreenContainer* CreateFullscreenContainer( + pepper::PluginInstance* instance); private: // Pointer to the RenderView that owns us. diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 39a65e8..486bfbe 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -70,6 +70,7 @@ #include "chrome/renderer/render_thread.h" #include "chrome/renderer/render_view_visitor.h" #include "chrome/renderer/render_widget_fullscreen.h" +#include "chrome/renderer/render_widget_fullscreen_pepper.h" #include "chrome/renderer/renderer_webapplicationcachehost_impl.h" #include "chrome/renderer/renderer_webstoragenamespace_impl.h" #include "chrome/renderer/speech_input_dispatcher.h" @@ -1763,6 +1764,14 @@ WebWidget* RenderView::createFullscreenWindow(WebKit::WebPopupType popup_type) { return widget->webwidget(); } +pepper::FullscreenContainer* RenderView::CreatePepperFullscreenContainer( + pepper::PluginInstance* plugin) { + RenderWidgetFullscreenPepper* widget = + RenderWidgetFullscreenPepper::Create(routing_id_, render_thread_, plugin); + widget->show(WebKit::WebNavigationPolicyIgnore); + return widget->container(); +} + WebStorageNamespace* RenderView::createSessionStorageNamespace(unsigned quota) { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) return WebStorageNamespace::createSessionStorageNamespace(quota); diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 97ee04a..4a181c2 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -90,6 +90,11 @@ class Point; class Rect; } +namespace pepper { +class PluginInstance; +class FullscreenContainer; +} + namespace webkit_glue { class ImageResourceFetcher; struct FileUploadData; @@ -282,6 +287,10 @@ class RenderView : public RenderWidget, // the plugin. void OnPepperPluginDestroy(WebPluginDelegatePepper* pepper_plugin); + // Creates a fullscreen container for a pepper plugin instance. + pepper::FullscreenContainer* CreatePepperFullscreenContainer( + pepper::PluginInstance* plugin); + // Create a new plugin without checking the content settings. WebKit::WebPlugin* CreatePluginNoCheck(WebKit::WebFrame* frame, const WebKit::WebPluginParams& params); diff --git a/chrome/renderer/render_widget_fullscreen.cc b/chrome/renderer/render_widget_fullscreen.cc index e822b49..ce6f367 100644 --- a/chrome/renderer/render_widget_fullscreen.cc +++ b/chrome/renderer/render_widget_fullscreen.cc @@ -21,11 +21,9 @@ RenderWidgetFullscreen* RenderWidgetFullscreen::Create( return widget.release(); } -// static -WebWidget* RenderWidgetFullscreen::CreateWebWidget( - RenderWidgetFullscreen* render_widget) { +WebWidget* RenderWidgetFullscreen::CreateWebWidget() { // TODO(boliu): Handle full screen render widgets here. - return RenderWidget::CreateWebWidget(render_widget); + return RenderWidget::CreateWebWidget(this); } void RenderWidgetFullscreen::Init(int32 opener_id) { @@ -33,7 +31,7 @@ void RenderWidgetFullscreen::Init(int32 opener_id) { RenderWidget::DoInit( opener_id, - RenderWidgetFullscreen::CreateWebWidget(this), + CreateWebWidget(), new ViewHostMsg_CreateFullscreenWidget( opener_id, popup_type_, &routing_id_)); } diff --git a/chrome/renderer/render_widget_fullscreen.h b/chrome/renderer/render_widget_fullscreen.h index 2573819..b0d7cb7 100644 --- a/chrome/renderer/render_widget_fullscreen.h +++ b/chrome/renderer/render_widget_fullscreen.h @@ -19,12 +19,10 @@ class RenderWidgetFullscreen : public RenderWidget { RenderThreadBase* render_thread, WebKit::WebPopupType popup_type); - static WebKit::WebWidget* CreateWebWidget( - RenderWidgetFullscreen* render_widget); - virtual void show(WebKit::WebNavigationPolicy); protected: + virtual WebKit::WebWidget* CreateWebWidget(); RenderWidgetFullscreen(RenderThreadBase* render_thread, WebKit::WebPopupType popup_type); diff --git a/chrome/renderer/render_widget_fullscreen_pepper.cc b/chrome/renderer/render_widget_fullscreen_pepper.cc new file mode 100644 index 0000000..5b1b1f3 --- /dev/null +++ b/chrome/renderer/render_widget_fullscreen_pepper.cc @@ -0,0 +1,212 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/renderer/render_widget_fullscreen_pepper.h" + +#include "chrome/common/render_messages.h" +#include "chrome/renderer/render_thread.h" +#include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" +#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" +#include "third_party/WebKit/WebKit/chromium/public/WebWidget.h" +#include "webkit/glue/plugins/pepper_fullscreen_container.h" +#include "webkit/glue/plugins/pepper_plugin_instance.h" + +using WebKit::WebCanvas; +using WebKit::WebCompositionUnderline; +using WebKit::WebCursorInfo; +using WebKit::WebInputEvent; +using WebKit::WebRect; +using WebKit::WebSize; +using WebKit::WebString; +using WebKit::WebTextDirection; +using WebKit::WebTextInputType; +using WebKit::WebVector; +using WebKit::WebWidget; + +namespace { + +// WebWidget that simply wraps the pepper plugin. +class PepperWidget : public WebWidget { + public: + PepperWidget(pepper::PluginInstance* plugin, + RenderWidgetFullscreenPepper* widget) + : plugin_(plugin), + widget_(widget), + cursor_(WebCursorInfo::TypePointer) { + } + + // WebWidget API + virtual void close() { + delete this; + } + + virtual WebSize size() { + return size_; + } + + virtual void resize(const WebSize& size) { + size_ = size; + WebRect plugin_rect(0, 0, size_.width, size_.height); + // TODO(piman): transparently scale the plugin instead of resizing it. + plugin_->ViewChanged(plugin_rect, plugin_rect); + widget_->GenerateFullRepaint(); + } + + virtual void layout() { + } + + virtual void paint(WebCanvas* canvas, const WebRect& rect) { + if (!plugin_) + return; + WebRect plugin_rect(0, 0, size_.width, size_.height); + plugin_->Paint(canvas, plugin_rect, rect); + } + + virtual void composite(bool finish) { + NOTIMPLEMENTED(); + } + + virtual void themeChanged() { + NOTIMPLEMENTED(); + } + + virtual bool handleInputEvent(const WebInputEvent& event) { + if (!plugin_) + return false; + return plugin_->HandleInputEvent(event, &cursor_); + } + + virtual void mouseCaptureLost() { + NOTIMPLEMENTED(); + } + + virtual void setFocus(bool focus) { + NOTIMPLEMENTED(); + } + + virtual bool setComposition( + const WebString& text, + const WebVector<WebCompositionUnderline>& underlines, + int selectionStart, + int selectionEnd) { + NOTIMPLEMENTED(); + return false; + } + + virtual bool confirmComposition() { + NOTIMPLEMENTED(); + return false; + } + + virtual WebTextInputType textInputType() { + NOTIMPLEMENTED(); + return WebKit::WebTextInputTypeNone; + } + + virtual WebRect caretOrSelectionBounds() { + NOTIMPLEMENTED(); + return WebRect(); + } + + virtual void setTextDirection(WebTextDirection) { + NOTIMPLEMENTED(); + } + + virtual bool isAcceleratedCompositingActive() const { + // TODO(piman): see if supporting accelerated compositing makes sense. + return false; + } + + private: + pepper::PluginInstance* plugin_; + RenderWidgetFullscreenPepper* widget_; + WebSize size_; + WebCursorInfo cursor_; + + DISALLOW_COPY_AND_ASSIGN(PepperWidget); +}; + + +// A FullscreenContainer that forwards the API calls to the +// RenderWidgetFullscreenPepper. +class WidgetFullscreenContainer : public pepper::FullscreenContainer { + public: + explicit WidgetFullscreenContainer(RenderWidgetFullscreenPepper* widget) + : widget_(widget) { + } + virtual ~WidgetFullscreenContainer() { } + + virtual void Invalidate() { + widget_->GenerateFullRepaint(); + } + + virtual void InvalidateRect(const WebKit::WebRect& rect) { + widget_->didInvalidateRect(rect); + } + + virtual void Destroy() { + widget_->SendClose(); + } + + private: + RenderWidgetFullscreenPepper* widget_; + + DISALLOW_COPY_AND_ASSIGN(WidgetFullscreenContainer); +}; + +} // anonymous namespace + +// static +RenderWidgetFullscreenPepper* RenderWidgetFullscreenPepper::Create( + int32 opener_id, RenderThreadBase* render_thread, + pepper::PluginInstance* plugin) { + DCHECK_NE(MSG_ROUTING_NONE, opener_id); + scoped_refptr<RenderWidgetFullscreenPepper> widget = + new RenderWidgetFullscreenPepper(render_thread, plugin); + widget->Init(opener_id); + return widget.release(); +} + +RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( + RenderThreadBase* render_thread, pepper::PluginInstance* plugin) + : RenderWidgetFullscreen(render_thread, WebKit::WebPopupTypeSelect), + plugin_(plugin), + ALLOW_THIS_IN_INITIALIZER_LIST( + container_(new WidgetFullscreenContainer(this))) { +} + +RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() { +} + +WebWidget* RenderWidgetFullscreenPepper::CreateWebWidget() { + return new PepperWidget(plugin_, this); +} + +void RenderWidgetFullscreenPepper::Close() { + // If the fullscreen window is closed (e.g. user pressed escape), reset to + // normal mode. + if (plugin_) + plugin_->SetFullscreen(false); +} + +void RenderWidgetFullscreenPepper::DidInitiatePaint() { + if (plugin_) + plugin_->ViewInitiatedPaint(); +} + +void RenderWidgetFullscreenPepper::DidFlushPaint() { + if (plugin_) + plugin_->ViewFlushedPaint(); +} + +void RenderWidgetFullscreenPepper::SendClose() { + // This function is called by the plugin instance as it's going away, so reset + // plugin_ to NULL to avoid calling into a dangling pointer e.g. on Close(). + plugin_ = NULL; + Send(new ViewHostMsg_Close(routing_id_)); +} + +void RenderWidgetFullscreenPepper::GenerateFullRepaint() { + didInvalidateRect(gfx::Rect(size_.width(), size_.height())); +} diff --git a/chrome/renderer/render_widget_fullscreen_pepper.h b/chrome/renderer/render_widget_fullscreen_pepper.h new file mode 100644 index 0000000..437e75d --- /dev/null +++ b/chrome/renderer/render_widget_fullscreen_pepper.h @@ -0,0 +1,58 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_ +#define CHROME_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_ + +#include "chrome/renderer/render_widget_fullscreen.h" +#include "third_party/WebKit/WebKit/chromium/public/WebWidget.h" + +namespace pepper { +class PluginInstance; +class FullscreenContainer; +} + +// A RenderWidget that hosts a fullscreen pepper plugin. This provides a +// FullscreenContainer that the plugin instance can callback into to e.g. +// invalidate rects. +class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen { + public: + static RenderWidgetFullscreenPepper* Create( + int32 opener_id, + RenderThreadBase* render_thread, + pepper::PluginInstance* plugin); + + // Asks the browser to close this view, which will tear off the window and + // close this widget. + void SendClose(); + + // Invalidate the whole widget to force a redraw. + void GenerateFullRepaint(); + + pepper::FullscreenContainer* container() const { return container_.get(); } + + protected: + RenderWidgetFullscreenPepper(RenderThreadBase* render_thread, + pepper::PluginInstance* plugin); + virtual ~RenderWidgetFullscreenPepper(); + + // RenderWidget API. + virtual void DidInitiatePaint(); + virtual void DidFlushPaint(); + virtual void Close(); + + // RenderWidgetFullscreen API. + virtual WebKit::WebWidget* CreateWebWidget(); + + private: + // The plugin instance this widget wraps. + pepper::PluginInstance* plugin_; + + // The FullscreenContainer that the plugin instance can callback into. + scoped_ptr<pepper::FullscreenContainer> container_; + + DISALLOW_COPY_AND_ASSIGN(RenderWidgetFullscreenPepper); +}; + +#endif // CHROME_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_ |