summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc2
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc84
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h71
-rw-r--r--webkit/plugins/ppapi/ppapi_webplugin_impl.cc6
4 files changed, 133 insertions, 30 deletions
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 27d725f..a1f0c8c 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -273,6 +273,8 @@ const void* GetInterface(const char* name) {
return ::ppapi::thunk::GetPPB_Flash_TCPSocket_Thunk();
if (strcmp(name, PPB_FLASH_UDPSOCKET_INTERFACE) == 0)
return ::ppapi::thunk::GetPPB_Flash_UDPSocket_Thunk();
+ if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE_0_4) == 0)
+ return ::ppapi::thunk::GetPPB_FlashFullscreen_Thunk();
if (strcmp(name, PPB_GPU_BLACKLIST_INTERFACE) == 0)
return PPB_GpuBlacklist_Private_Impl::GetInterface();
if (strcmp(name, PPB_GRAPHICS_3D_TRUSTED_INTERFACE) == 0)
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 5f413f0..4ec22da 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -239,6 +239,8 @@ PluginInstance::PluginInstance(
plugin_graphics_3d_interface_(NULL),
always_on_top_(false),
fullscreen_container_(NULL),
+ flash_fullscreen_(false),
+ desired_fullscreen_state_(false),
fullscreen_(false),
message_channel_(NULL),
sad_plugin_(NULL),
@@ -361,6 +363,7 @@ void PluginInstance::InstanceCrashed() {
// Free any associated graphics.
SetFullscreen(false, false);
+ FlashSetFullscreen(false, false);
bound_graphics_ = NULL;
InvalidateRect(gfx::Rect());
@@ -533,7 +536,8 @@ void PluginInstance::ViewChanged(const gfx::Rect& position,
sent_did_change_view_ = true;
position_ = position;
clip_ = new_clip;
- fullscreen_ = (fullscreen_container_ != NULL);
+ fullscreen_ = desired_fullscreen_state_;
+ flash_fullscreen_ = (fullscreen_container_ != NULL);
PP_Rect pp_position, pp_clip;
RectToPPRect(position_, &pp_position);
@@ -796,7 +800,7 @@ void PluginInstance::ReportGeometry() {
// If this call was delayed, we may have transitioned back to fullscreen in
// the mean time, so only report the geometry if we are actually in normal
// mode.
- if (container_ && !fullscreen_container_)
+ if (container_ && !fullscreen_container_ && !flash_fullscreen_)
container_->reportGeometry();
}
@@ -914,10 +918,14 @@ void PluginInstance::PrintEnd() {
#endif // defined(OS_MACOSX)
}
-bool PluginInstance::IsFullscreenOrPending() {
+bool PluginInstance::FlashIsFullscreenOrPending() {
return fullscreen_container_ != NULL;
}
+bool PluginInstance::IsFullscreenOrPending() {
+ return desired_fullscreen_state_;
+}
+
void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
// Keep a reference on the stack. See NOTE above.
scoped_refptr<PluginInstance> ref(this);
@@ -928,6 +936,34 @@ void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
if (fullscreen == IsFullscreenOrPending())
return;
+ // Unbind current 2D or 3D graphics context.
+ BindGraphics(pp_instance(), 0);
+
+ VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off");
+ desired_fullscreen_state_ = fullscreen;
+ if (fullscreen)
+ container_->element().requestFullScreen();
+ else
+ container_->element().document().cancelFullScreen();
+ if (!delay_report) {
+ ReportGeometry();
+ } else {
+ MessageLoop::current()->PostTask(
+ FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry));
+ }
+}
+
+void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) {
+ // Keep a reference on the stack. See NOTE above.
+ scoped_refptr<PluginInstance> ref(this);
+
+ // We check whether we are trying to switch to the state we're already going
+ // to (i.e. if we're already switching to fullscreen but the fullscreen
+ // container isn't ready yet, don't do anything more).
+ if (fullscreen == FlashIsFullscreenOrPending())
+ return;
+
+ // Unbind current 2D or 3D graphics context.
BindGraphics(pp_instance(), 0);
VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off");
if (fullscreen) {
@@ -937,7 +973,7 @@ void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
DCHECK(fullscreen_container_);
fullscreen_container_->Destroy();
fullscreen_container_ = NULL;
- fullscreen_ = false;
+ flash_fullscreen_ = false;
if (!delay_report) {
ReportGeometry();
} else {
@@ -1263,14 +1299,16 @@ PPB_Surface3D_Impl* PluginInstance::GetBoundSurface3D() const {
}
void PluginInstance::setBackingTextureId(unsigned int id) {
- // If we have a full-screen container_ then the plugin is fullscreen,
- // and the parent context is not the one for the browser page, but for the
- // full-screen window, and so the parent texture ID doesn't correspond to
- // anything in the page's context.
+ // If we have a fullscreen_container_ (under PPB_FlashFullscreen)
+ // or desired_fullscreen_state is true (under PPB_Fullscreen_Dev),
+ // then the plugin is fullscreen or transitioning to fullscreen
+ // and the parent context is not the one for the browser page,
+ // but for the fullscreen window, and so the parent texture ID
+ // doesn't correspond to anything in the page's context.
//
// TODO(alokp): It would be better at some point to have the equivalent
// in the FullscreenContainer so that we don't need to poll
- if (fullscreen_container_)
+ if (fullscreen_container_ || desired_fullscreen_state_)
return;
if (container_)
@@ -1332,8 +1370,10 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance,
return PP_TRUE;
}
- // Refuse to bind if we're transitioning to fullscreen.
- if (fullscreen_container_ && !fullscreen_)
+ // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or
+ // to/from fullscreen with PPB_Fullscreen_Dev.
+ if ((fullscreen_container_ && !flash_fullscreen_) ||
+ desired_fullscreen_state_ != fullscreen_)
return PP_FALSE;
EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
@@ -1505,23 +1545,37 @@ void PluginInstance::SelectedFindResultChanged(PP_Instance instance,
delegate_->SelectedFindResultChanged(find_identifier_, index);
}
-PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) {
+PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) {
return PP_FromBool(fullscreen_);
}
+PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) {
+ return PP_FromBool(flash_fullscreen_);
+}
+
+PP_Bool PluginInstance::SetFullscreen(PP_Instance instance,
+ PP_Bool fullscreen) {
+ SetFullscreen(PP_ToBool(fullscreen), true);
+ return PP_TRUE;
+}
+
PP_Bool PluginInstance::FlashSetFullscreen(PP_Instance instance,
PP_Bool fullscreen) {
- SetFullscreen(PP_ToBool(fullscreen), true);
+ FlashSetFullscreen(PP_ToBool(fullscreen), true);
return PP_TRUE;
}
-PP_Bool PluginInstance::FlashGetScreenSize(PP_Instance instance,
- PP_Size* size) {
+PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) {
gfx::Size screen_size = delegate()->GetScreenSize();
*size = PP_MakeSize(screen_size.width(), screen_size.height());
return PP_TRUE;
}
+PP_Bool PluginInstance::FlashGetScreenSize(PP_Instance instance,
+ PP_Size* size) {
+ return GetScreenSize(instance, size);
+}
+
int32_t PluginInstance::RequestInputEvents(PP_Instance instance,
uint32_t event_classes) {
input_event_mask_ |= event_classes;
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 346e157..f46301b 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -207,19 +207,50 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
void Graphics3DContextLost();
- // Implementation of PPB_Fullscreen_Dev.
+ // There are 2 implementations of the fullscreen interface
+ // PPB_FlashFullscreen_Dev is used by Pepper Flash.
+ // PPB_Fullscreen_Dev is intended for other applications including NaCl.
+ // The two interface are mutually exclusive.
+
+ // Implementation of PPB_FlashFullscreen.
// Because going to fullscreen is asynchronous (but going out is not), there
// are 3 states:
- // - normal (fullscreen_container_ == NULL)
- // - fullscreen pending (fullscreen_container_ != NULL, fullscreen_ == false)
- // - fullscreen (fullscreen_container_ != NULL, fullscreen_ = true)
+ // - normal : fullscreen_container_ == NULL
+ // flash_fullscreen_ == false
+ // - fullscreen pending: fullscreen_container_ != NULL
+ // flash_fullscreen_ == false
+ // - fullscreen : fullscreen_container_ != NULL
+ // flash_fullscreen_ == true
//
// In normal state, events come from webkit and painting goes back to it.
// In fullscreen state, events come from the fullscreen container, and
- // painting goes back to it
+ // painting goes back to it.
// In pending state, events from webkit are ignored, and as soon as we receive
// events from the fullscreen container, we go to the fullscreen state.
+ bool FlashIsFullscreenOrPending();
+
+ // Switches between fullscreen and normal mode. If |delay_report| is set to
+ // false, it may report the new state through DidChangeView immediately. If
+ // true, it will delay it. When called from the plugin, delay_report should be
+ // true to avoid re-entrancy.
+ void FlashSetFullscreen(bool fullscreen, bool delay_report);
+
+ FullscreenContainer* fullscreen_container() const {
+ return fullscreen_container_;
+ }
+
+ // Implementation of PPB_Fullscreen_Dev.
+
+ // Because going to/from fullscreen is asynchronous, there are 4 states:
+ // - normal : desired_fullscreen_state_ == false
+ // fullscreen_ == false
+ // - fullscreen pending: desired_fullscreen_state_ == true
+ // fullscreen_ == false
+ // - fullscreen : desired_fullscreen_state_ == true
+ // fullscreen_ == true
+ // - normal pending : desired_fullscreen_state_ = false
+ // fullscreen_ = true
bool IsFullscreenOrPending();
// Switches between fullscreen and normal mode. If |delay_report| is set to
@@ -242,10 +273,6 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
// embedded in a page).
bool IsFullPagePlugin() const;
- FullscreenContainer* fullscreen_container() const {
- return fullscreen_container_;
- }
-
void OnLockMouseACK(int32_t result);
void OnMouseLockLost();
@@ -253,7 +280,7 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI()
OVERRIDE;
- // PPB_Instance_API implementation.
+ // PPB_Instance_FunctionAPI implementation.
virtual PP_Bool BindGraphics(PP_Instance instance,
PP_Resource device) OVERRIDE;
virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE;
@@ -279,6 +306,11 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
PP_Bool fullscreen) OVERRIDE;
virtual PP_Bool FlashGetScreenSize(PP_Instance instance,
PP_Size* size) OVERRIDE;
+ virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE;
+ virtual PP_Bool SetFullscreen(PP_Instance instance,
+ PP_Bool fullscreen) OVERRIDE;
+ virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size)
+ OVERRIDE;
virtual int32_t RequestInputEvents(PP_Instance instance,
uint32_t event_classes) OVERRIDE;
virtual int32_t RequestFilteringInputEvents(PP_Instance instance,
@@ -462,12 +494,27 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
// to use a more optimized painting path in some cases.
bool always_on_top_;
+ // Implementation of PPB_FlashFullscreen.
+
// Plugin container for fullscreen mode. NULL if not in fullscreen mode. Note:
// there is a transition state where fullscreen_container_ is non-NULL but
- // fullscreen_ is false (see above).
+ // flash_fullscreen_ is false (see above).
FullscreenContainer* fullscreen_container_;
- // True if we are in fullscreen mode. Note: it is false during the transition.
+ // True if we are in fullscreen mode. False if we are in normal mode or
+ // in transition to fullscreen.
+ bool flash_fullscreen_;
+
+ // Implementation of PPB_Fullscreen_Dev.
+
+ // Since entering fullscreen mode is an asynchronous operation, we set this
+ // variable to the desired state at the time we issue the fullscreen change
+ // request. The plugin will receive a DidChangeView event when it goes
+ // fullscreen.
+ bool desired_fullscreen_state_;
+
+ // True if we are in fullscreen mode. False if we are in normal mode.
+ // It reflects the previous state when in transition.
bool fullscreen_;
// The MessageChannel used to implement bidirectional postMessage for the
diff --git a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
index 613f2d3..b2b5b21 100644
--- a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
+++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
@@ -122,7 +122,7 @@ bool WebPluginImpl::getFormValue(WebString* value) {
}
void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) {
- if (!instance_->IsFullscreenOrPending())
+ if (!instance_->FlashIsFullscreenOrPending())
instance_->Paint(canvas, plugin_rect_, rect);
}
@@ -132,7 +132,7 @@ void WebPluginImpl::updateGeometry(
const WebVector<WebRect>& cut_outs_rects,
bool is_visible) {
plugin_rect_ = window_rect;
- if (!instance_->IsFullscreenOrPending())
+ if (!instance_->FlashIsFullscreenOrPending())
instance_->ViewChanged(plugin_rect_, clip_rect);
}
@@ -149,7 +149,7 @@ bool WebPluginImpl::acceptsInputEvents() {
bool WebPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event,
WebKit::WebCursorInfo& cursor_info) {
- if (instance_->IsFullscreenOrPending())
+ if (instance_->FlashIsFullscreenOrPending())
return false;
return instance_->HandleInputEvent(event, &cursor_info);
}