Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: chrome/renderer/render_widget_fullscreen_pepper.cc

Issue 3352019: Add fullscreen support to Pepper. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: git cl tree Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 "chrome/renderer/render_widget_fullscreen_pepper.h"
6
7 #include "chrome/common/render_messages.h"
8 #include "chrome/renderer/render_thread.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebWidget.h"
12 #include "webkit/glue/plugins/pepper_fullscreen_container.h"
13 #include "webkit/glue/plugins/pepper_plugin_instance.h"
14
15 using WebKit::WebCanvas;
16 using WebKit::WebCompositionUnderline;
17 using WebKit::WebCursorInfo;
18 using WebKit::WebInputEvent;
19 using WebKit::WebRect;
20 using WebKit::WebSize;
21 using WebKit::WebString;
22 using WebKit::WebTextDirection;
23 using WebKit::WebTextInputType;
24 using WebKit::WebVector;
25 using WebKit::WebWidget;
26
27 namespace {
28
29 // WebWidget that simply wraps the pepper plugin.
30 class PepperWidget : public WebWidget {
31 public:
32 PepperWidget(pepper::PluginInstance* plugin,
33 RenderWidgetFullscreenPepper* widget)
34 : plugin_(plugin),
35 widget_(widget),
36 cursor_(WebCursorInfo::TypePointer) {
37 }
38
39 // WebWidget API
40 virtual void close() {
41 delete this;
42 }
43
44 virtual WebSize size() {
45 return size_;
46 }
47
48 virtual void resize(const WebSize& size) {
49 size_ = size;
50 WebRect plugin_rect(0, 0, size_.width, size_.height);
51 // TODO(piman): transparently scale the plugin instead of resizing it.
52 plugin_->ViewChanged(plugin_rect, plugin_rect);
53 widget_->GenerateFullRepaint();
54 }
55
56 virtual void layout() {
57 }
58
59 virtual void paint(WebCanvas* canvas, const WebRect& rect) {
60 if (!plugin_)
61 return;
62 WebRect plugin_rect(0, 0, size_.width, size_.height);
63 plugin_->Paint(canvas, plugin_rect, rect);
64 }
65
66 virtual void composite(bool finish) {
67 NOTIMPLEMENTED();
68 }
69
70 virtual void themeChanged() {
71 NOTIMPLEMENTED();
72 }
73
74 virtual bool handleInputEvent(const WebInputEvent& event) {
75 if (!plugin_)
76 return false;
77 return plugin_->HandleInputEvent(event, &cursor_);
78 }
79
80 virtual void mouseCaptureLost() {
81 NOTIMPLEMENTED();
82 }
83
84 virtual void setFocus(bool focus) {
85 NOTIMPLEMENTED();
86 }
87
88 virtual bool setComposition(
89 const WebString& text,
90 const WebVector<WebCompositionUnderline>& underlines,
91 int selectionStart,
92 int selectionEnd) {
93 NOTIMPLEMENTED();
94 return false;
95 }
96
97 virtual bool confirmComposition() {
98 NOTIMPLEMENTED();
99 return false;
100 }
101
102 virtual WebTextInputType textInputType() {
103 NOTIMPLEMENTED();
104 return WebKit::WebTextInputTypeNone;
105 }
106
107 virtual WebRect caretOrSelectionBounds() {
108 NOTIMPLEMENTED();
109 return WebRect();
110 }
111
112 virtual void setTextDirection(WebTextDirection) {
113 NOTIMPLEMENTED();
114 }
115
116 virtual bool isAcceleratedCompositingActive() const {
117 // TODO(piman): see if supporting accelerated compositing makes sense.
118 return false;
119 }
120
121 private:
122 pepper::PluginInstance* plugin_;
123 RenderWidgetFullscreenPepper* widget_;
124 WebSize size_;
125 WebCursorInfo cursor_;
126
127 DISALLOW_COPY_AND_ASSIGN(PepperWidget);
128 };
129
130
131 // A FullscreenContainer that forwards the API calls to the
132 // RenderWidgetFullscreenPepper.
133 class WidgetFullscreenContainer : public pepper::FullscreenContainer {
134 public:
135 explicit WidgetFullscreenContainer(RenderWidgetFullscreenPepper* widget)
136 : widget_(widget) {
137 }
138 virtual ~WidgetFullscreenContainer() { }
139
140 virtual void Invalidate() {
141 widget_->GenerateFullRepaint();
142 }
143
144 virtual void InvalidateRect(const WebKit::WebRect& rect) {
145 widget_->didInvalidateRect(rect);
146 }
147
148 virtual void Destroy() {
149 widget_->SendClose();
150 }
151
152 private:
153 RenderWidgetFullscreenPepper* widget_;
154
155 DISALLOW_COPY_AND_ASSIGN(WidgetFullscreenContainer);
156 };
157
158 } // anonymous namespace
159
160 // static
161 RenderWidgetFullscreenPepper* RenderWidgetFullscreenPepper::Create(
162 int32 opener_id, RenderThreadBase* render_thread,
163 pepper::PluginInstance* plugin) {
164 DCHECK_NE(MSG_ROUTING_NONE, opener_id);
165 scoped_refptr<RenderWidgetFullscreenPepper> widget =
166 new RenderWidgetFullscreenPepper(render_thread, plugin);
167 widget->Init(opener_id);
168 return widget.release();
169 }
170
171 RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper(
172 RenderThreadBase* render_thread, pepper::PluginInstance* plugin)
173 : RenderWidgetFullscreen(render_thread, WebKit::WebPopupTypeSelect),
174 plugin_(plugin),
175 container_(new WidgetFullscreenContainer(this)) {
176 }
177
178 RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() {
179 }
180
181 WebWidget* RenderWidgetFullscreenPepper::CreateWebWidget() {
182 return new PepperWidget(plugin_, this);
183 }
184
185 void RenderWidgetFullscreenPepper::Close() {
186 // If the fullscreen window is closed (e.g. user pressed escape), reset to
187 // normal mode.
188 if (plugin_)
189 plugin_->SetFullscreen(false);
190 }
191
192 void RenderWidgetFullscreenPepper::DidInitiatePaint() {
193 if (plugin_)
194 plugin_->ViewInitiatedPaint();
195 }
196
197 void RenderWidgetFullscreenPepper::DidFlushPaint() {
198 if (plugin_)
199 plugin_->ViewFlushedPaint();
200 }
201
202 void RenderWidgetFullscreenPepper::SendClose() {
203 // This function is called by the plugin instance as it's going away, so reset
204 // plugin_ to NULL to avoid calling into a dangling pointer e.g. on Close().
205 plugin_ = NULL;
206 Send(new ViewHostMsg_Close(routing_id_));
207 }
208
209 void RenderWidgetFullscreenPepper::GenerateFullRepaint() {
210 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
211 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_widget_fullscreen_pepper.h ('k') | webkit/glue/plugins/pepper_fullscreen_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698