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

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

Issue 10458008: Support mouse lock in Flash fullscreen mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_widget_fullscreen_pepper.h" 5 #include "content/renderer/render_widget_fullscreen_pepper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "content/common/gpu/client/gpu_channel_host.h" 9 #include "content/common/gpu/client/gpu_channel_host.h"
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 18 matching lines...) Expand all
29 using WebKit::WebSize; 29 using WebKit::WebSize;
30 using WebKit::WebString; 30 using WebKit::WebString;
31 using WebKit::WebTextDirection; 31 using WebKit::WebTextDirection;
32 using WebKit::WebTextInputType; 32 using WebKit::WebTextInputType;
33 using WebKit::WebVector; 33 using WebKit::WebVector;
34 using WebKit::WebWidget; 34 using WebKit::WebWidget;
35 using WebKit::WGC3Dintptr; 35 using WebKit::WGC3Dintptr;
36 36
37 namespace { 37 namespace {
38 38
39 class FullscreenMouseLockDispatcher : public MouseLockDispatcher {
40 public:
41 explicit FullscreenMouseLockDispatcher(RenderWidgetFullscreenPepper* widget);
42 virtual ~FullscreenMouseLockDispatcher();
43
44 private:
45 // MouseLockDispatcher implementation.
46 virtual void SendLockMouseRequest() OVERRIDE;
47 virtual void SendUnlockMouseRequest() OVERRIDE;
48
49 RenderWidgetFullscreenPepper* widget_;
50
51 DISALLOW_COPY_AND_ASSIGN(FullscreenMouseLockDispatcher);
52 };
53
54 FullscreenMouseLockDispatcher::FullscreenMouseLockDispatcher(
55 RenderWidgetFullscreenPepper* widget) : widget_(widget) {
56 }
57
58 FullscreenMouseLockDispatcher::~FullscreenMouseLockDispatcher() {
59 }
60
61 void FullscreenMouseLockDispatcher::SendLockMouseRequest() {
62 widget_->Send(new ViewHostMsg_LockMouse(widget_->routing_id(), false, true));
63 }
64
65 void FullscreenMouseLockDispatcher::SendUnlockMouseRequest() {
66 widget_->Send(new ViewHostMsg_UnlockMouse(widget_->routing_id()));
67 }
68
39 // WebWidget that simply wraps the pepper plugin. 69 // WebWidget that simply wraps the pepper plugin.
40 class PepperWidget : public WebWidget { 70 class PepperWidget : public WebWidget {
41 public: 71 public:
42 explicit PepperWidget(RenderWidgetFullscreenPepper* widget) 72 explicit PepperWidget(RenderWidgetFullscreenPepper* widget)
43 : widget_(widget) { 73 : widget_(widget) {
44 } 74 }
45 75
46 virtual ~PepperWidget() {} 76 virtual ~PepperWidget() {}
47 77
48 // WebWidget API 78 // WebWidget API
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 263
234 RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( 264 RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper(
235 webkit::ppapi::PluginInstance* plugin, 265 webkit::ppapi::PluginInstance* plugin,
236 const GURL& active_url) 266 const GURL& active_url)
237 : RenderWidgetFullscreen(), 267 : RenderWidgetFullscreen(),
238 active_url_(active_url), 268 active_url_(active_url),
239 plugin_(plugin), 269 plugin_(plugin),
240 context_(NULL), 270 context_(NULL),
241 buffer_(0), 271 buffer_(0),
242 program_(0), 272 program_(0),
243 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 273 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
274 mouse_lock_dispatcher_(new FullscreenMouseLockDispatcher(
275 ALLOW_THIS_IN_INITIALIZER_LIST(this))) {
244 } 276 }
245 277
246 RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() { 278 RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() {
247 if (context_) 279 if (context_)
248 DestroyContext(context_, program_, buffer_); 280 DestroyContext(context_, program_, buffer_);
249 } 281 }
250 282
251 void RenderWidgetFullscreenPepper::OnViewContextSwapBuffersPosted() { 283 void RenderWidgetFullscreenPepper::OnViewContextSwapBuffersPosted() {
252 OnSwapBuffersPosted(); 284 OnSwapBuffersPosted();
253 } 285 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 341
310 webkit::ppapi::PluginDelegate::PlatformContext3D* 342 webkit::ppapi::PluginDelegate::PlatformContext3D*
311 RenderWidgetFullscreenPepper::CreateContext3D() { 343 RenderWidgetFullscreenPepper::CreateContext3D() {
312 #ifdef ENABLE_GPU 344 #ifdef ENABLE_GPU
313 return new content::PlatformContext3DImpl(this); 345 return new content::PlatformContext3DImpl(this);
314 #else 346 #else
315 return NULL; 347 return NULL;
316 #endif 348 #endif
317 } 349 }
318 350
351 MouseLockDispatcher* RenderWidgetFullscreenPepper::GetMouseLockDispatcher() {
352 return mouse_lock_dispatcher_.get();
353 }
354
355 bool RenderWidgetFullscreenPepper::OnMessageReceived(const IPC::Message& msg) {
356 bool handled = true;
357 IPC_BEGIN_MESSAGE_MAP(RenderWidgetFullscreenPepper, msg)
358 IPC_MESSAGE_FORWARD(ViewMsg_LockMouse_ACK,
359 mouse_lock_dispatcher_.get(),
360 MouseLockDispatcher::OnLockMouseACK)
361 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost,
362 mouse_lock_dispatcher_.get(),
363 MouseLockDispatcher::OnMouseLockLost)
364 IPC_MESSAGE_UNHANDLED(handled = false)
365 IPC_END_MESSAGE_MAP()
366 if (handled)
367 return true;
368
369 return RenderWidgetFullscreen::OnMessageReceived(msg);
370 }
371
319 void RenderWidgetFullscreenPepper::WillInitiatePaint() { 372 void RenderWidgetFullscreenPepper::WillInitiatePaint() {
320 if (plugin_) 373 if (plugin_)
321 plugin_->ViewWillInitiatePaint(); 374 plugin_->ViewWillInitiatePaint();
322 } 375 }
323 376
324 void RenderWidgetFullscreenPepper::DidInitiatePaint() { 377 void RenderWidgetFullscreenPepper::DidInitiatePaint() {
325 if (plugin_) 378 if (plugin_)
326 plugin_->ViewInitiatedPaint(); 379 plugin_->ViewInitiatedPaint();
327 } 380 }
328 381
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 569
517 WebGraphicsContext3DCommandBufferImpl* 570 WebGraphicsContext3DCommandBufferImpl*
518 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() { 571 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() {
519 if (!context_) { 572 if (!context_) {
520 CreateContext(); 573 CreateContext();
521 } 574 }
522 if (!context_) 575 if (!context_)
523 return NULL; 576 return NULL;
524 return context_; 577 return context_;
525 } 578 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698