0

[Flash] Remove PPB_Flash_Fullscreen API

- Removes the Flash API, but leaves the resource and proxy which is
  used by PPB_Fullscreen.

Bug: chromium:1064652
Change-Id: I6e1e9ce5f30f3f3ee90fb758e8c1b7e4d4158846
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2464208
Reviewed-by: Raymes Khoury <raymes@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816717}
This commit is contained in:
Bill Budge
2020-10-13 19:43:22 +00:00
committed by Commit Bot
parent 7ac473d51d
commit a05aa28f51
22 changed files with 6 additions and 804 deletions

@ -75,7 +75,6 @@
#include "ppapi/c/private/ppb_file_ref_private.h"
#include "ppapi/c/private/ppb_find_private.h"
#include "ppapi/c/private/ppb_flash_font_file.h"
#include "ppapi/c/private/ppb_flash_fullscreen.h"
#include "ppapi/c/private/ppb_host_resolver_private.h"
#include "ppapi/c/private/ppb_isolated_file_system_private.h"
#include "ppapi/c/private/ppb_pdf.h"

@ -2142,20 +2142,6 @@ TEST_PPAPI_NACL(MAYBE_MessageHandler)
TEST_PPAPI_NACL(MessageLoop_Basics)
TEST_PPAPI_NACL(MessageLoop_Post)
// Mac/Aura reach NOTIMPLEMENTED/time out.
// mac: http://crbug.com/96767
// aura: http://crbug.com/104384
// cros: http://crbug.com/396502
// windows: http://crbug.com/899893
// linux: http://crbug.com/899893
#if defined(OS_MAC) || defined(OS_CHROMEOS) || defined(OS_WIN) || \
defined(OS_LINUX)
#define MAYBE_FlashFullscreen DISABLED_FlashFullscreen
#else
#define MAYBE_FlashFullscreen FlashFullscreen
#endif
TEST_PPAPI_OUT_OF_PROCESS(MAYBE_FlashFullscreen)
TEST_PPAPI_OUT_OF_PROCESS(PDF)
#if BUILDFLAG(ENABLE_NACL)

@ -107,7 +107,6 @@
#include "ppapi/c/private/ppb_file_ref_private.h"
#include "ppapi/c/private/ppb_find_private.h"
#include "ppapi/c/private/ppb_flash_font_file.h"
#include "ppapi/c/private/ppb_flash_fullscreen.h"
#include "ppapi/c/private/ppb_host_resolver_private.h"
#include "ppapi/c/private/ppb_instance_private.h"
#include "ppapi/c/private/ppb_isolated_file_system_private.h"

@ -175,10 +175,6 @@ source_set("ppapi_tests_sources") {
"tests/test_crypto.h",
"tests/test_file_chooser.cc",
"tests/test_file_chooser.h",
"tests/test_flash_fullscreen.cc",
"tests/test_flash_fullscreen.h",
"tests/test_flash_fullscreen_for_browser_ui.cc",
"tests/test_flash_fullscreen_for_browser_ui.h",
"tests/test_net_address_private.cc",
"tests/test_net_address_private.h",
"tests/test_pdf.cc",

@ -1,45 +0,0 @@
/* Copyright (c) 2012 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.
*/
/**
* This file defines the <code>PPB_FlashFullscreen</code> interface.
*/
label Chrome {
M23 = 1.0
};
interface PPB_FlashFullscreen {
/**
* Checks whether the plugin instance is currently in fullscreen mode.
*/
PP_Bool IsFullscreen(
[in] PP_Instance instance);
/**
* Switches the plugin instance to/from fullscreen mode. Returns PP_TRUE on
* success, PP_FALSE on failure.
*
* This does not unbind the current Graphics2D or Graphics3D. Pending flushes
* and swapbuffers will execute as if the resource was off-screen. The
* transition is asynchronous. During the transition, IsFullscreen will
* return PP_FALSE, and no Graphics2D or Graphics3D can be bound. The
* transition ends at the next DidChangeView when going into fullscreen mode.
* The transition out of fullscreen mode is synchronous.
*/
PP_Bool SetFullscreen(
[in] PP_Instance instance,
[in] PP_Bool fullscreen);
/**
* Gets the size of the screen in pixels. When going fullscreen, the instance
* will be resized to that size.
*/
PP_Bool GetScreenSize(
[in] PP_Instance instance,
[out] PP_Size size);
};

@ -120,7 +120,6 @@ source_set("c") {
"private/ppb_file_ref_private.h",
"private/ppb_find_private.h",
"private/ppb_flash_font_file.h",
"private/ppb_flash_fullscreen.h",
"private/ppb_host_resolver_private.h",
"private/ppb_instance_private.h",
"private/ppb_isolated_file_system_private.h",

@ -1,60 +0,0 @@
/* Copyright (c) 2012 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.
*/
/* From private/ppb_flash_fullscreen.idl modified Thu Jul 26 06:15:01 2018. */
#ifndef PPAPI_C_PRIVATE_PPB_FLASH_FULLSCREEN_H_
#define PPAPI_C_PRIVATE_PPB_FLASH_FULLSCREEN_H_
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_macros.h"
#include "ppapi/c/pp_size.h"
#include "ppapi/c/pp_stdint.h"
#define PPB_FLASHFULLSCREEN_INTERFACE_1_0 "PPB_FlashFullscreen;1.0"
#define PPB_FLASHFULLSCREEN_INTERFACE PPB_FLASHFULLSCREEN_INTERFACE_1_0
/**
* @file
* This file defines the <code>PPB_FlashFullscreen</code> interface.
*/
/**
* @addtogroup Interfaces
* @{
*/
struct PPB_FlashFullscreen_1_0 {
/**
* Checks whether the plugin instance is currently in fullscreen mode.
*/
PP_Bool (*IsFullscreen)(PP_Instance instance);
/**
* Switches the plugin instance to/from fullscreen mode. Returns PP_TRUE on
* success, PP_FALSE on failure.
*
* This does not unbind the current Graphics2D or Graphics3D. Pending flushes
* and swapbuffers will execute as if the resource was off-screen. The
* transition is asynchronous. During the transition, IsFullscreen will
* return PP_FALSE, and no Graphics2D or Graphics3D can be bound. The
* transition ends at the next DidChangeView when going into fullscreen mode.
* The transition out of fullscreen mode is synchronous.
*/
PP_Bool (*SetFullscreen)(PP_Instance instance, PP_Bool fullscreen);
/**
* Gets the size of the screen in pixels. When going fullscreen, the instance
* will be resized to that size.
*/
PP_Bool (*GetScreenSize)(PP_Instance instance, struct PP_Size* size);
};
typedef struct PPB_FlashFullscreen_1_0 PPB_FlashFullscreen;
/**
* @}
*/
#endif /* PPAPI_C_PRIVATE_PPB_FLASH_FULLSCREEN_H_ */

@ -207,8 +207,6 @@ source_set("objects") {
"private/find_private.h",
"private/flash_font_file.cc",
"private/flash_font_file.h",
"private/flash_fullscreen.cc",
"private/flash_fullscreen.h",
"private/host_resolver_private.cc",
"private/host_resolver_private.h",
"private/instance_private.cc",

@ -1,58 +0,0 @@
// Copyright (c) 2011 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 "ppapi/cpp/private/flash_fullscreen.h"
#include "ppapi/c/private/ppb_flash_fullscreen.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
#include "ppapi/cpp/size.h"
namespace pp {
namespace {
template <> const char* interface_name<PPB_FlashFullscreen_1_0>() {
return PPB_FLASHFULLSCREEN_INTERFACE_1_0;
}
} // namespace
FlashFullscreen::FlashFullscreen(const InstanceHandle& instance)
: instance_(instance) {
}
FlashFullscreen::~FlashFullscreen() {
}
bool FlashFullscreen::IsFullscreen() {
if (has_interface<PPB_FlashFullscreen_1_0>()) {
return PP_ToBool(get_interface<PPB_FlashFullscreen_1_0>()->IsFullscreen(
instance_.pp_instance()));
}
return false;
}
bool FlashFullscreen::SetFullscreen(bool fullscreen) {
if (has_interface<PPB_FlashFullscreen_1_0>()) {
return PP_ToBool(get_interface<PPB_FlashFullscreen_1_0>()->SetFullscreen(
instance_.pp_instance(), PP_FromBool(fullscreen)));
}
return false;
}
bool FlashFullscreen::GetScreenSize(Size* size) {
if (has_interface<PPB_FlashFullscreen_1_0>()) {
return PP_ToBool(get_interface<PPB_FlashFullscreen_1_0>()->GetScreenSize(
instance_.pp_instance(), &size->pp_size()));
}
return false;
}
bool FlashFullscreen::MustRecreateContexts() {
return !get_interface<PPB_FlashFullscreen_1_0>();
}
} // namespace pp

@ -1,32 +0,0 @@
// 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 PPAPI_CPP_PRIVATE_FLASH_FULLSCREEN_H_
#define PPAPI_CPP_PRIVATE_FLASH_FULLSCREEN_H_
#include "ppapi/cpp/instance_handle.h"
namespace pp {
class Size;
class FlashFullscreen {
public:
FlashFullscreen(const InstanceHandle& instance);
virtual ~FlashFullscreen();
// PPB_FlashFullscreen methods.
bool IsFullscreen();
bool SetFullscreen(bool fullscreen);
bool GetScreenSize(Size* size);
bool MustRecreateContexts();
private:
InstanceHandle instance_;
};
} // namespace pp
#endif // PPAPI_CPP_PRIVATE_FLASH_FULLSCREEN_H_

@ -16,7 +16,7 @@
#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/mouse_lock.h"
#include "ppapi/cpp/private/flash_fullscreen.h"
#include "ppapi/cpp/fullscreen.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/var.h"
#include "ppapi/utility/completion_callback_factory.h"
@ -33,7 +33,7 @@ class MyInstance : public pp::Instance, public pp::MouseLock {
waiting_for_flush_completion_(false),
callback_factory_(this),
console_(NULL),
flash_fullscreen_(this) {
fullscreen_(this) {
}
virtual ~MyInstance() {}
@ -78,8 +78,8 @@ class MyInstance : public pp::Instance, public pp::MouseLock {
return true;
} else if (key_event.GetKeyCode() == 70) {
// Enter Flash fullscreen mode when the 'f' key is pressed.
if (!flash_fullscreen_.IsFullscreen())
flash_fullscreen_.SetFullscreen(true);
if (!fullscreen_.IsFullscreen())
fullscreen_.SetFullscreen(true);
return true;
}
return false;
@ -252,7 +252,7 @@ class MyInstance : public pp::Instance, public pp::MouseLock {
const PPB_Console* console_;
pp::FlashFullscreen flash_fullscreen_;
pp::Fullscreen fullscreen_;
pp::Graphics2D device_context_;
};

@ -3067,8 +3067,6 @@ static void Pnacl_M15_PPB_FileRefPrivate_GetAbsolutePath(struct PP_Var* _struct_
/* Not generating wrapper methods for PPB_Flash_FontFile_0_2 */
/* Not generating wrapper methods for PPB_FlashFullscreen_1_0 */
/* Begin wrapper methods for PPB_HostResolver_Private_0_1 */
static PP_Resource Pnacl_M19_PPB_HostResolver_Private_Create(PP_Instance instance) {
@ -4605,8 +4603,6 @@ static const struct PPB_FileRefPrivate_0_1 Pnacl_Wrappers_PPB_FileRefPrivate_0_1
/* Not generating wrapper interface for PPB_Flash_FontFile_0_2 */
/* Not generating wrapper interface for PPB_FlashFullscreen_1_0 */
static const struct PPB_HostResolver_Private_0_1 Pnacl_Wrappers_PPB_HostResolver_Private_0_1 = {
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M19_PPB_HostResolver_Private_Create,
.IsHostResolver = (PP_Bool (*)(PP_Resource resource))&Pnacl_M19_PPB_HostResolver_Private_IsHostResolver,

@ -77,7 +77,6 @@
#include "ppapi/c/private/ppb_file_ref_private.h"
#include "ppapi/c/private/ppb_find_private.h"
#include "ppapi/c/private/ppb_flash_font_file.h"
#include "ppapi/c/private/ppb_flash_fullscreen.h"
#include "ppapi/c/private/ppb_host_resolver_private.h"
#include "ppapi/c/private/ppb_isolated_file_system_private.h"
#include "ppapi/c/private/ppb_net_address_private.h"

@ -12,7 +12,6 @@
#include "ppapi/c/ppb_fullscreen.h"
#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/c/ppp_instance.h"
#include "ppapi/c/private/ppb_flash_fullscreen.h"
#include "ppapi/proxy/locking_resource_releaser.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/ppapi_proxy_test.h"
@ -99,13 +98,12 @@ PPP_Instance_1_0 ppp_instance_1_0 = {
&HandleDocumentLoad
};
// PPP_Instance_Proxy::DidChangeView relies on PPB_(Flash)Fullscreen being
// PPP_Instance_Proxy::DidChangeView relies on PPB_Fullscreen being
// available with a valid implementation of IsFullScreen, so we mock it.
PP_Bool IsFullscreen(PP_Instance instance) {
return PP_FALSE;
}
PPB_Fullscreen ppb_fullscreen = { &IsFullscreen };
PPB_FlashFullscreen ppb_flash_fullscreen = { &IsFullscreen };
} // namespace
@ -118,8 +116,6 @@ class PPP_Instance_ProxyTest : public TwoWayTest {
TEST_F(PPP_Instance_ProxyTest, PPPInstance1_0) {
plugin().RegisterTestInterface(PPP_INSTANCE_INTERFACE_1_0, &ppp_instance_1_0);
host().RegisterTestInterface(PPB_FLASHFULLSCREEN_INTERFACE,
&ppb_flash_fullscreen);
host().RegisterTestInterface(PPB_FULLSCREEN_INTERFACE,
&ppb_fullscreen);

@ -48,7 +48,6 @@
#include "ppapi/cpp/private/camera_device_private.h"
#include "ppapi/cpp/private/find_private.h"
#include "ppapi/cpp/private/flash_font_file.h"
#include "ppapi/cpp/private/flash_fullscreen.h"
#include "ppapi/cpp/private/instance_private.h"
#include "ppapi/cpp/private/net_address_private.h"
#include "ppapi/cpp/private/tcp_socket_private.h"

@ -1,204 +0,0 @@
// Copyright (c) 2012 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 "ppapi/tests/test_flash_fullscreen.h"
#include <stdio.h>
#include <string.h>
#include <string>
#include "ppapi/c/private/ppb_flash_fullscreen.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/point.h"
#include "ppapi/cpp/private/flash_fullscreen.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/size.h"
#include "ppapi/tests/test_utils.h"
#include "ppapi/tests/testing_instance.h"
REGISTER_TEST_CASE(FlashFullscreen);
namespace {
bool IsFullscreenView(const pp::Rect& position,
const pp::Rect& clip,
const pp::Size& screen_size) {
return (position.point() == pp::Point(0, 0) &&
position.size() == screen_size &&
clip.point() == pp::Point(0, 0) &&
clip.size() == screen_size);
}
} // namespace
TestFlashFullscreen::TestFlashFullscreen(TestingInstance* instance)
: TestCase(instance),
screen_mode_(instance),
fullscreen_pending_(false),
normal_pending_(false),
fullscreen_event_(instance->pp_instance()),
normal_event_(instance->pp_instance()) {
screen_mode_.GetScreenSize(&screen_size_);
}
bool TestFlashFullscreen::Init() {
return CheckTestingInterface();
}
void TestFlashFullscreen::RunTests(const std::string& filter) {
RUN_TEST(GetScreenSize, filter);
RUN_TEST(NormalToFullscreenToNormal, filter);
}
std::string TestFlashFullscreen::TestGetScreenSize() {
if (screen_size_.width() < 320 || screen_size_.width() > 2560)
return ReportError("screen_size.width()", screen_size_.width());
if (screen_size_.height() < 200 || screen_size_.height() > 2048)
return ReportError("screen_size.height()", screen_size_.height());
PASS();
}
std::string TestFlashFullscreen::TestNormalToFullscreenToNormal() {
// 0. Start in normal mode.
if (screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() at start", true);
// This is only allowed within a contet of a user gesture (e.g. mouse click).
if (screen_mode_.SetFullscreen(true))
return ReportError("SetFullscreen(true) outside of user gesture", true);
// 1. Switch to fullscreen.
// The transition is asynchronous and ends at the next DidChangeView().
// No graphics devices can be bound while in transition.
fullscreen_pending_ = true;
instance_->RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
SimulateUserGesture();
// DidChangeView() will call the callback once in fullscreen mode.
fullscreen_event_.Wait();
if (GotError())
return Error();
if (fullscreen_pending_)
return "fullscreen_pending_ has not been reset";
if (!screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in fullscreen", false);
pp::Graphics2D graphics2d_fullscreen(instance_, pp::Size(10, 10), false);
if (graphics2d_fullscreen.is_null())
return "Failed to create graphics2d_fullscreen";
if (!instance_->BindGraphics(graphics2d_fullscreen))
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_.IsFullscreen())
return ReportError("IsFullscreen() in fullscreen^2", false);
// 3. Switch to normal.
// The transition is synchronous in-process and asynchornous out-of-process
// because proxied IsFullscreen saves a roundtrip by relying on information
// communicated via a previous call to DidChangeView.
// Graphics devices can be bound right away.
normal_pending_ = true;
if (!screen_mode_.SetFullscreen(false))
return ReportError("SetFullscreen(false) in fullscreen", false);
pp::Graphics2D graphics2d_normal(instance_, pp::Size(15, 15), false);
if (graphics2d_normal.is_null())
return "Failed to create graphics2d_normal";
if (!instance_->BindGraphics(graphics2d_normal))
return ReportError("BindGraphics() in normal transition", false);
if (testing_interface_->IsOutOfProcess()) {
if (!screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in normal transition", false);
normal_event_.Wait();
if (normal_pending_)
return "normal_pending_ has not been reset";
}
if (screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in normal", true);
// 4. Stay in normal. No change.
if (!screen_mode_.SetFullscreen(false))
return ReportError("SetFullscreen(false) in normal", false);
if (screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in normal^2", true);
PASS();
}
// Transition to fullscreen is asynchornous ending at DidChangeView.
// Transition to normal is synchronous in-process and asynchronous
// out-of-process ending at DidChangeView.
void TestFlashFullscreen::DidChangeView(const pp::View& view) {
pp::Rect position = view.GetRect();
pp::Rect clip = view.GetClipRect();
if (normal_position_.IsEmpty())
normal_position_ = view.GetRect();
if (fullscreen_pending_ && IsFullscreenView(position, clip, screen_size_)) {
fullscreen_pending_ = false;
fullscreen_event_.Signal();
} else if (normal_pending_ &&
!IsFullscreenView(position, clip, screen_size_)) {
normal_pending_ = false;
if (testing_interface_->IsOutOfProcess())
normal_event_.Signal();
}
}
void TestFlashFullscreen::SimulateUserGesture() {
pp::Point plugin_center(
normal_position_.x() + normal_position_.width() / 2,
normal_position_.y() + normal_position_.height() / 2);
pp::Point mouse_movement;
pp::MouseInputEvent input_event(
instance_,
PP_INPUTEVENT_TYPE_MOUSEDOWN,
NowInTimeTicks(), // time_stamp
0, // modifiers
PP_INPUTEVENT_MOUSEBUTTON_LEFT,
plugin_center,
1, // click_count
mouse_movement);
testing_interface_->SimulateInputEvent(instance_->pp_instance(),
input_event.pp_resource());
}
bool TestFlashFullscreen::GotError() {
return !error_.empty();
}
std::string TestFlashFullscreen::Error() {
std::string last_error = error_;
error_.clear();
return last_error;
}
void TestFlashFullscreen::FailFullscreenTest(const std::string& error) {
error_ = error;
fullscreen_event_.Signal();
}
bool TestFlashFullscreen::HandleInputEvent(const pp::InputEvent& event) {
if (event.GetType() != PP_INPUTEVENT_TYPE_MOUSEDOWN &&
event.GetType() != PP_INPUTEVENT_TYPE_MOUSEUP) {
return false;
}
instance_->ClearInputEventRequest(PP_INPUTEVENT_CLASS_MOUSE);
if (screen_mode_.IsFullscreen()) {
FailFullscreenTest(
ReportError("IsFullscreen() before fullscreen transition", true));
return false;
}
if (!screen_mode_.SetFullscreen(true)) {
FailFullscreenTest(
ReportError("SetFullscreen(true) in normal", false));
return false;
}
// DidChangeView() will complete the transition to fullscreen.
return false;
}

@ -1,49 +0,0 @@
// Copyright (c) 2012 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 PPAPI_TESTS_TEST_FLASH_FULLSCREEN_H_
#define PPAPI_TESTS_TEST_FLASH_FULLSCREEN_H_
#include <string>
#include "ppapi/cpp/private/flash_fullscreen.h"
#include "ppapi/cpp/size.h"
#include "ppapi/tests/test_case.h"
#include "ppapi/tests/test_utils.h"
namespace pp {
class Rect;
} // namespace pp
class TestFlashFullscreen : public TestCase {
public:
explicit TestFlashFullscreen(TestingInstance* instance);
// TestCase implementation.
bool Init() override;
void RunTests(const std::string& filter) override;
void DidChangeView(const pp::View& view) override;
bool HandleInputEvent(const pp::InputEvent& event) override;
private:
std::string TestGetScreenSize();
std::string TestNormalToFullscreenToNormal();
void SimulateUserGesture();
bool GotError();
std::string Error();
void FailFullscreenTest(const std::string& error);
std::string error_;
pp::FlashFullscreen screen_mode_;
pp::Size screen_size_;
pp::Rect normal_position_;
bool fullscreen_pending_;
bool normal_pending_;
NestedEvent fullscreen_event_;
NestedEvent normal_event_;
};
#endif // PPAPI_TESTS_TEST_FLASH_FULLSCREEN_H_

@ -1,190 +0,0 @@
// Copyright 2014 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 "ppapi/tests/test_flash_fullscreen_for_browser_ui.h"
#include <GLES2/gl2.h>
#include "ppapi/c/ppb_opengles2.h"
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/tests/testing_instance.h"
REGISTER_TEST_CASE(FlashFullscreenForBrowserUI);
TestFlashFullscreenForBrowserUI::
TestFlashFullscreenForBrowserUI(TestingInstance* instance)
: TestCase(instance),
screen_mode_(instance),
view_change_event_(instance->pp_instance()),
callback_factory_(this) {
// This plugin should not be removed after this TestCase passes because
// browser UI testing requires it to remain and to be interactive.
instance_->set_remove_plugin(false);
}
TestFlashFullscreenForBrowserUI::~TestFlashFullscreenForBrowserUI() {
}
bool TestFlashFullscreenForBrowserUI::Init() {
opengl_es2_ = static_cast<const PPB_OpenGLES2*>(
pp::Module::Get()->GetBrowserInterface(PPB_OPENGLES2_INTERFACE));
return opengl_es2_ && CheckTestingInterface();
}
void TestFlashFullscreenForBrowserUI::RunTests(const std::string& filter) {
RUN_TEST(EnterFullscreen, filter);
}
std::string TestFlashFullscreenForBrowserUI::TestEnterFullscreen() {
if (screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() at start", true);
// This is only allowed within a contet of a user gesture (e.g. mouse click).
if (screen_mode_.SetFullscreen(true))
return ReportError("SetFullscreen(true) outside of user gesture", true);
int32_t attribs[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 8,
PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8,
PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8,
PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 0,
PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0,
PP_GRAPHICS3DATTRIB_WIDTH, layer_size_.width(),
PP_GRAPHICS3DATTRIB_HEIGHT, layer_size_.height(),
PP_GRAPHICS3DATTRIB_NONE};
graphics_3d_ = pp::Graphics3D(instance_, attribs);
instance_->BindGraphics(graphics_3d_);
// Trigger another call to SetFullscreen(true) from HandleInputEvent().
// The transition is asynchronous and ends at the next DidChangeView().
view_change_event_.Reset();
request_fullscreen_ = true;
instance_->RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
SimulateUserGesture();
// DidChangeView() will call the callback once in fullscreen mode.
view_change_event_.Wait();
if (GotError())
return Error();
if (!screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in fullscreen", false);
const int32_t result =
instance_->RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_MOUSE |
PP_INPUTEVENT_CLASS_KEYBOARD);
if (result != PP_OK)
return ReportError("RequestFilteringInputEvents() failed", result);
PASS();
}
void TestFlashFullscreenForBrowserUI::DidChangeView(const pp::View& view) {
layer_size_ = view.GetRect().size();
if (normal_position_.IsEmpty())
normal_position_ = view.GetRect();
if (!graphics_3d_.is_null()) {
graphics_3d_.ResizeBuffers(layer_size_.width(), layer_size_.height());
RequestPaint();
}
view_change_event_.Signal();
}
void TestFlashFullscreenForBrowserUI::SimulateUserGesture() {
pp::Point plugin_center(
normal_position_.x() + normal_position_.width() / 2,
normal_position_.y() + normal_position_.height() / 2);
pp::Point mouse_movement;
pp::MouseInputEvent input_event(
instance_,
PP_INPUTEVENT_TYPE_MOUSEDOWN,
NowInTimeTicks(), // time_stamp
0, // modifiers
PP_INPUTEVENT_MOUSEBUTTON_LEFT,
plugin_center,
1, // click_count
mouse_movement);
testing_interface_->SimulateInputEvent(instance_->pp_instance(),
input_event.pp_resource());
}
bool TestFlashFullscreenForBrowserUI::GotError() {
return !error_.empty();
}
std::string TestFlashFullscreenForBrowserUI::Error() {
std::string last_error = error_;
error_.clear();
return last_error;
}
void TestFlashFullscreenForBrowserUI::FailFullscreenTest(
const std::string& error) {
error_ = error;
view_change_event_.Signal();
}
bool TestFlashFullscreenForBrowserUI::HandleInputEvent(
const pp::InputEvent& event) {
if (event.GetType() != PP_INPUTEVENT_TYPE_MOUSEDOWN &&
event.GetType() != PP_INPUTEVENT_TYPE_MOUSEUP &&
event.GetType() != PP_INPUTEVENT_TYPE_CHAR) {
return false;
}
if (request_fullscreen_) {
instance_->ClearInputEventRequest(PP_INPUTEVENT_CLASS_MOUSE);
if (screen_mode_.IsFullscreen()) {
FailFullscreenTest(
ReportError("IsFullscreen() before fullscreen transition", true));
return false;
}
request_fullscreen_ = false;
if (!screen_mode_.SetFullscreen(true)) {
FailFullscreenTest(
ReportError("SetFullscreen(true) in normal", false));
return false;
}
// DidChangeView() will complete the transition to fullscreen.
return false;
}
++num_trigger_events_;
RequestPaint();
return true;
}
void TestFlashFullscreenForBrowserUI::RequestPaint() {
if (swap_pending_)
needs_paint_ = true;
else
DoPaint();
}
void TestFlashFullscreenForBrowserUI::DoPaint() {
if (num_trigger_events_ == 0)
opengl_es2_->ClearColor(graphics_3d_.pp_resource(), 0.0f, 1.0f, 0.0f, 1.0f);
else if (num_trigger_events_ % 2)
opengl_es2_->ClearColor(graphics_3d_.pp_resource(), 1.0f, 0.0f, 0.0f, 1.0f);
else
opengl_es2_->ClearColor(graphics_3d_.pp_resource(), 0.0f, 0.0f, 1.0f, 1.0f);
opengl_es2_->Clear(graphics_3d_.pp_resource(), GL_COLOR_BUFFER_BIT);
swap_pending_ = true;
graphics_3d_.SwapBuffers(
callback_factory_.NewCallback(&TestFlashFullscreenForBrowserUI::DidSwap));
}
void TestFlashFullscreenForBrowserUI::DidSwap(int32_t last_compositor_result) {
swap_pending_ = false;
if (needs_paint_) {
needs_paint_ = false;
DoPaint();
}
}

@ -1,74 +0,0 @@
// Copyright 2014 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 PPAPI_TESTS_TEST_FLASH_FULLSCREEN_FOR_BROWSER_UI_H_
#define PPAPI_TESTS_TEST_FLASH_FULLSCREEN_FOR_BROWSER_UI_H_
#include <stdint.h>
#include <string>
#include "ppapi/cpp/graphics_3d.h"
#include "ppapi/cpp/private/flash_fullscreen.h"
#include "ppapi/cpp/size.h"
#include "ppapi/tests/test_case.h"
#include "ppapi/tests/test_utils.h"
#include "ppapi/utility/completion_callback_factory.h"
struct PPB_OpenGLES2;
// This is a special TestCase whose purpose is *not* to test the correctness of
// the Pepper APIs. Instead, this is a simulated Flash plugin, used to place
// the browser window and other UI elements into Flash Fullscreen mode for
// layout, event, focus, etc. testing. See
// chrome/browser/ui/exclusive_access/
// flash_fullscreen_interactive_browsertest.cc.
//
// At start, this simulated Flash plugin will enter fullscreen and paint a green
// color fill. From there, it will respond to mouse clicks or key presses by
// toggling its fill color between red and blue. The browser test reads these
// color changes to detect the desired behavior.
class TestFlashFullscreenForBrowserUI : public TestCase {
public:
explicit TestFlashFullscreenForBrowserUI(TestingInstance* instance);
~TestFlashFullscreenForBrowserUI() override;
// TestCase implementation.
bool Init() override;
void RunTests(const std::string& filter) override;
void DidChangeView(const pp::View& view) override;
bool HandleInputEvent(const pp::InputEvent& event) override;
private:
std::string TestEnterFullscreen();
void RequestPaint();
void DoPaint();
void DidSwap(int32_t last_compositor_result);
void SimulateUserGesture();
bool GotError();
std::string Error();
void FailFullscreenTest(const std::string& error);
// OpenGL ES2 interface.
const PPB_OpenGLES2* opengl_es2_ = nullptr;
std::string error_;
pp::FlashFullscreen screen_mode_;
NestedEvent view_change_event_;
pp::Graphics3D graphics_3d_;
pp::Size layer_size_;
pp::Rect normal_position_;
int num_trigger_events_ = 0;
bool request_fullscreen_ = false;
bool swap_pending_ = false;
bool needs_paint_ = false;
pp::CompletionCallbackFactory<TestFlashFullscreenForBrowserUI>
callback_factory_;
};
#endif // PPAPI_TESTS_TEST_FLASH_FULLSCREEN_FOR_BROWSER_UI_H_

@ -148,7 +148,6 @@ source_set("thunk") {
"ppb_buffer_thunk.cc",
"ppb_char_set_thunk.cc",
"ppb_flash_font_file_thunk.cc",
"ppb_flash_fullscreen_thunk.cc",
"ppb_gles_chromium_texture_mapping_thunk.cc",
"ppb_pdf_thunk.cc",
"ppb_url_util_thunk.cc",

@ -33,7 +33,6 @@ PROXIED_IFACE(PPB_FILECHOOSER_TRUSTED_INTERFACE_0_6,
PPB_FileChooserTrusted_0_6)
PROXIED_IFACE(PPB_FILEREFPRIVATE_INTERFACE_0_1,
PPB_FileRefPrivate_0_1)
PROXIED_IFACE(PPB_FLASHFULLSCREEN_INTERFACE_1_0, PPB_FlashFullscreen_1_0)
#endif // !defined(OS_NACL)
#include "ppapi/thunk/interfaces_postamble.h"

@ -1,51 +0,0 @@
// Copyright (c) 2012 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 "ppapi/c/ppb_fullscreen.h"
#include "ppapi/c/private/ppb_flash_fullscreen.h"
#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_flash_fullscreen_api.h"
#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/resource_creation_api.h"
namespace ppapi {
namespace thunk {
namespace {
PP_Bool IsFullscreen(PP_Instance instance) {
EnterInstanceAPI<PPB_Flash_Fullscreen_API> enter(instance);
if (enter.failed())
return PP_FALSE;
return enter.functions()->IsFullscreen(instance);
}
PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) {
EnterInstanceAPI<PPB_Flash_Fullscreen_API> enter(instance);
if (enter.failed())
return PP_FALSE;
return enter.functions()->SetFullscreen(instance, fullscreen);
}
// TODO(raymes): The codepaths for GetScreenSize in PPB_Fullscreen and
// PPB_Flash_Fullscreen are the same. Consider deprecating the flash version.
PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) {
EnterInstance enter(instance);
if (enter.failed())
return PP_FALSE;
return enter.functions()->GetScreenSize(instance, size);
}
const PPB_FlashFullscreen_1_0 g_ppb_flash_fullscreen_thunk = {
&IsFullscreen, &SetFullscreen, &GetScreenSize};
} // namespace
const PPB_FlashFullscreen_1_0* GetPPB_FlashFullscreen_1_0_Thunk() {
return &g_ppb_flash_fullscreen_thunk;
}
} // namespace thunk
} // namespace ppapi