summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_fullscreen/ppapi_ppb_fullscreen.cc13
-rw-r--r--ppapi/tests/test_fullscreen.cc19
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc17
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h6
4 files changed, 41 insertions, 14 deletions
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_fullscreen/ppapi_ppb_fullscreen.cc b/ppapi/native_client/tests/ppapi_browser/ppb_fullscreen/ppapi_ppb_fullscreen.cc
index 90eb935..959b7bb 100644
--- a/ppapi/native_client/tests/ppapi_browser/ppb_fullscreen/ppapi_ppb_fullscreen.cc
+++ b/ppapi/native_client/tests/ppapi_browser/ppb_fullscreen/ppapi_ppb_fullscreen.cc
@@ -99,12 +99,13 @@ void TestSetFullscreenTrue() {
// Transition to fullscreen.
// This can only be done when processing a user gesture -
// see HandleInputEvent().
+ EXPECT(ppb->SetFullscreen(pp_instance(), PP_TRUE) == PP_FALSE);
EXPECT(PPBInputEvent()->
RequestInputEvents(pp_instance(),
PP_INPUTEVENT_CLASS_MOUSE) == PP_OK);
} else {
// No change.
- EXPECT(ppb->SetFullscreen(pp_instance(), PP_TRUE) == PP_TRUE);
+ EXPECT(ppb->SetFullscreen(pp_instance(), PP_TRUE) == PP_FALSE);
EXPECT(ppb->IsFullscreen(pp_instance()) == PP_TRUE);
TEST_PASSED;
}
@@ -117,8 +118,10 @@ void TestSetFullscreenFalse() {
// Transition out of fullscreen.
EXPECT(CreateGraphics2D(&g_graphics2d));
// The transition is asynchronous and ends at the next DidChangeView().
- g_normal_pending = true;
EXPECT(ppb->SetFullscreen(pp_instance(), PP_FALSE) == PP_TRUE);
+ g_normal_pending = true;
+ // Transition is pending, so repeated requests fail.
+ EXPECT(ppb->SetFullscreen(pp_instance(), PP_FALSE) == PP_FALSE);
EXPECT(ppb->IsFullscreen(pp_instance()) == PP_TRUE);
// No 2D or 3D device can be bound during transition.
EXPECT(PPBGraphics2D()->IsGraphics2D(g_graphics2d) == PP_TRUE);
@@ -127,7 +130,7 @@ void TestSetFullscreenFalse() {
// The transition ends at the next DidChangeView().
} else {
// No change.
- EXPECT(ppb->SetFullscreen(pp_instance(), PP_FALSE) == PP_TRUE);
+ EXPECT(ppb->SetFullscreen(pp_instance(), PP_FALSE) == PP_FALSE);
EXPECT(ppb->IsFullscreen(pp_instance()) == PP_FALSE);
TEST_PASSED;
}
@@ -177,8 +180,10 @@ PP_Bool HandleInputEvent(PP_Instance instance, PP_Resource event) {
PP_INPUTEVENT_CLASS_MOUSE);
EXPECT(PPBFullscreenDev()->IsFullscreen(pp_instance()) == PP_FALSE);
EXPECT(CreateGraphics2D(&g_graphics2d));
- g_fullscreen_pending = true;
EXPECT(PPBFullscreenDev()->SetFullscreen(pp_instance(), PP_TRUE) == PP_TRUE);
+ g_fullscreen_pending = true;
+ // Transition is pending, so repeated requests fail.
+ EXPECT(PPBFullscreenDev()->SetFullscreen(pp_instance(), PP_TRUE) == PP_FALSE);
EXPECT(PPBFullscreenDev()->IsFullscreen(pp_instance()) == PP_FALSE);
// No 2D or 3D device can be bound during transition.
EXPECT(PPBGraphics2D()->IsGraphics2D(g_graphics2d) == PP_TRUE);
diff --git a/ppapi/tests/test_fullscreen.cc b/ppapi/tests/test_fullscreen.cc
index bcac8f3..226d03d 100644
--- a/ppapi/tests/test_fullscreen.cc
+++ b/ppapi/tests/test_fullscreen.cc
@@ -80,6 +80,8 @@ std::string TestFullscreen::TestNormalToFullscreenToNormal() {
// 1. Switch to fullscreen.
// This is only allowed within a context of a user gesture (e.g. mouse click).
+ if (screen_mode_.SetFullscreen(true))
+ return ReportError("SetFullscreen(true) outside of user gesture", true);
// The transition is asynchronous and ends at the next DidChangeView().
// No graphics devices can be bound while in transition.
instance_->RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
@@ -96,8 +98,8 @@ std::string TestFullscreen::TestNormalToFullscreenToNormal() {
return ReportError("BindGraphics() in fullscreen", false);
// 2. Stay in fullscreen. No change.
- if (!screen_mode_.SetFullscreen(true))
- return ReportError("SetFullscreen(true) in fullscreen", false);
+ if (screen_mode_.SetFullscreen(true))
+ return ReportError("SetFullscreen(true) in fullscreen", true);
if (!screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in fullscreen^2", false);
@@ -107,6 +109,9 @@ std::string TestFullscreen::TestNormalToFullscreenToNormal() {
normal_pending_ = true;
if (!screen_mode_.SetFullscreen(false))
return ReportError("SetFullscreen(false) in fullscreen", false);
+ // Normal is now pending, so repeated requests should fail.
+ if (screen_mode_.SetFullscreen(false))
+ return ReportError("SetFullscreen(false) in normal pending", true);
if (instance_->BindGraphics(graphics2d_normal_))
return ReportError("BindGraphics() in normal transition", true);
if (!screen_mode_.IsFullscreen())
@@ -121,8 +126,8 @@ std::string TestFullscreen::TestNormalToFullscreenToNormal() {
return ReportError("BindGraphics() in normal", false);
// 4. Stay in normal. No change.
- if (!screen_mode_.SetFullscreen(false))
- return ReportError("SetFullscreen(false) in normal", false);
+ if (screen_mode_.SetFullscreen(false))
+ return ReportError("SetFullscreen(false) in normal", true);
if (screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in normal^2", true);
@@ -149,6 +154,12 @@ bool TestFullscreen::HandleInputEvent(const pp::InputEvent& event) {
FailFullscreenTest(ReportError("SetFullscreen(true) in normal", false));
return false;
}
+ // Fullscreen is now pending, so repeated requests should fail.
+ if (screen_mode_.SetFullscreen(true)) {
+ FailFullscreenTest(
+ ReportError("SetFullscreen(true) in fullscreen pending", true));
+ return false;
+ }
// No graphics devices can be bound while in transition.
if (instance_->BindGraphics(graphics2d_fullscreen_)) {
FailFullscreenTest(
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index cee7108..435cafb 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -931,7 +931,7 @@ bool PluginInstance::IsFullscreenOrPending() {
return desired_fullscreen_state_;
}
-void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
+bool PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
// Keep a reference on the stack. See NOTE above.
scoped_refptr<PluginInstance> ref(this);
@@ -939,7 +939,16 @@ void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
// 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 == IsFullscreenOrPending())
- return;
+ return false;
+
+ // The browser will allow us to go into fullscreen mode only when processing
+ // a user gesture. This is guaranteed to work with in-process plugins and
+ // out-of-process syncronous proxies, but might be an issue with Flash when
+ // it switches over from PPB_FlashFullscreen.
+ // TODO(polina, bbudge): make this work with asynchronous proxies.
+ WebFrame* frame = container_->element().document().frame();
+ if (fullscreen && !frame->isProcessingUserGesture())
+ return false;
// Unbind current 2D or 3D graphics context.
BindGraphics(pp_instance(), 0);
@@ -956,6 +965,7 @@ void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
MessageLoop::current()->PostTask(
FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry));
}
+ return true;
}
void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) {
@@ -1560,8 +1570,7 @@ PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) {
PP_Bool PluginInstance::SetFullscreen(PP_Instance instance,
PP_Bool fullscreen) {
- SetFullscreen(PP_ToBool(fullscreen), true);
- return PP_TRUE;
+ return PP_FromBool(SetFullscreen(PP_ToBool(fullscreen), true));
}
PP_Bool PluginInstance::FlashSetFullscreen(PP_Instance instance,
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index fdb3dce..6109278 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -256,8 +256,10 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
// 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 SetFullscreen(bool fullscreen, bool delay_report);
+ // true to avoid re-entrancy. Returns true on success, false on failure
+ // (e.g. trying to enter fullscreen when not processing a user gesture or
+ // trying to set fullscreen when already in fullscreen mode).
+ bool SetFullscreen(bool fullscreen, bool delay_report);
// Implementation of PPB_Flash.
int32_t Navigate(PPB_URLRequestInfo_Impl* request,