summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 05:32:04 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 05:32:04 +0000
commita085aed793ce5577c7a0fca65e68447dd6d6f5ef (patch)
treea0799313b93fe269db084e68b229dddfcc9b5614 /ppapi
parentf2202083f44fb378bc03e784c6a02e863e686b40 (diff)
downloadchromium_src-a085aed793ce5577c7a0fca65e68447dd6d6f5ef.zip
chromium_src-a085aed793ce5577c7a0fca65e68447dd6d6f5ef.tar.gz
chromium_src-a085aed793ce5577c7a0fca65e68447dd6d6f5ef.tar.bz2
Convert the PPB_Flash interface to use the thunk system.
This was a bit tricky since some of the functions had no instance context, so I added global functions on the PpapiGlobals interface for them. It would be nice to add a PP_Instance argument and fix this in the future. I did a new style of doing the thunking. The "function APIs" haven't really worked out since it's almost always easier to add the functions directly on the instance one. Since this is a larger and more separable chunk, I just added a getter on the instance API for the flash API and thunk through that. I'd like to convert the remaining ~3 function APIs to either call directly on the instance or use this method, but that's not addressed by this patch. I moved the flash command line switch to plugin_switches so this could be hooked up properly. It allowed me to delete the delegate API for this. I combined the flash fullscreen functions into the new Flash API which removed a bit of code. Review URL: https://chromiumcodereview.appspot.com/10091003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133636 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/ppapi_shared.gypi6
-rw-r--r--ppapi/proxy/interface_list.cc14
-rw-r--r--ppapi/proxy/plugin_globals.cc9
-rw-r--r--ppapi/proxy/plugin_globals.h11
-rw-r--r--ppapi/proxy/ppapi_messages.h16
-rw-r--r--ppapi/proxy/ppb_flash_proxy.cc384
-rw-r--r--ppapi/proxy/ppb_flash_proxy.h91
-rw-r--r--ppapi/proxy/ppb_instance_proxy.cc46
-rw-r--r--ppapi/proxy/ppb_instance_proxy.h14
-rw-r--r--ppapi/shared_impl/ppapi_globals.h8
-rw-r--r--ppapi/shared_impl/test_globals.cc7
-rw-r--r--ppapi/shared_impl/test_globals.h2
-rw-r--r--ppapi/thunk/interfaces_ppb_private_flash.h25
-rw-r--r--ppapi/thunk/ppb_flash_api.h55
-rw-r--r--ppapi/thunk/ppb_flash_fullscreen_thunk.cc8
-rw-r--r--ppapi/thunk/ppb_flash_thunk.cc231
-rw-r--r--ppapi/thunk/ppb_instance_api.h9
-rw-r--r--ppapi/thunk/thunk.h1
18 files changed, 587 insertions, 350 deletions
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index ce8bc03..51f2383 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -171,8 +171,6 @@
'thunk/ppb_device_ref_thunk.cc',
'thunk/ppb_directory_reader_api.h',
'thunk/ppb_directory_reader_thunk.cc',
- 'thunk/ppb_input_event_api.h',
- 'thunk/ppb_input_event_thunk.cc',
'thunk/ppb_file_chooser_api.h',
'thunk/ppb_file_chooser_thunk.cc',
'thunk/ppb_file_io_api.h',
@@ -183,6 +181,7 @@
'thunk/ppb_file_system_api.h',
'thunk/ppb_file_system_thunk.cc',
'thunk/ppb_find_thunk.cc',
+ 'thunk/ppb_flash_api.h',
'thunk/ppb_flash_clipboard_api.h',
'thunk/ppb_flash_clipboard_thunk.cc',
'thunk/ppb_flash_fullscreen_thunk.cc',
@@ -190,6 +189,7 @@
'thunk/ppb_flash_menu_thunk.cc',
'thunk/ppb_flash_message_loop_api.h',
'thunk/ppb_flash_message_loop_thunk.cc',
+ 'thunk/ppb_flash_thunk.cc',
'thunk/ppb_fullscreen_thunk.cc',
'thunk/ppb_gamepad_thunk.cc',
'thunk/ppb_gles_chromium_texture_mapping_thunk.cc',
@@ -203,6 +203,8 @@
'thunk/ppb_image_data_api.h',
'thunk/ppb_image_data_thunk.cc',
'thunk/ppb_image_data_trusted_thunk.cc',
+ 'thunk/ppb_input_event_api.h',
+ 'thunk/ppb_input_event_thunk.cc',
'thunk/ppb_instance_api.h',
'thunk/ppb_instance_thunk.cc',
'thunk/ppb_layer_compositor_api.h',
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index 8d3fbcb..ed640da 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -176,6 +176,10 @@ InterfaceList::InterfaceList() {
#include "ppapi/thunk/interfaces_ppb_private.h"
#endif
+ #if !defined(OS_NACL)
+ #include "ppapi/thunk/interfaces_ppb_private_flash.h"
+ #endif
+
#undef PROXIED_API
#undef PROXIED_IFACE
@@ -301,16 +305,6 @@ const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const {
#if !defined(OS_NACL)
void InterfaceList::AddFlashInterfaces() {
- AddProxy(API_ID_PPB_FLASH, &ProxyFactory<PPB_Flash_Proxy>);
- AddPPB(PPB_FLASH_INTERFACE_11_0, API_ID_PPB_FLASH,
- PPB_Flash_Proxy::GetInterface11());
- AddPPB(PPB_FLASH_INTERFACE_12_0, API_ID_PPB_FLASH,
- PPB_Flash_Proxy::GetInterface12_0());
- AddPPB(PPB_FLASH_INTERFACE_12_1, API_ID_PPB_FLASH,
- PPB_Flash_Proxy::GetInterface12_1());
- AddPPB(PPB_FLASH_INTERFACE_12_2, API_ID_PPB_FLASH,
- PPB_Flash_Proxy::GetInterface12_2());
-
AddProxy(API_ID_PPB_FLASH_CLIPBOARD,
&ProxyFactory<PPB_Flash_Clipboard_Proxy>);
AddPPB(PPB_FLASH_CLIPBOARD_INTERFACE_4_0, API_ID_PPB_FLASH_CLIPBOARD,
diff --git a/ppapi/proxy/plugin_globals.cc b/ppapi/proxy/plugin_globals.cc
index 5218dc4..95c96ee 100644
--- a/ppapi/proxy/plugin_globals.cc
+++ b/ppapi/proxy/plugin_globals.cc
@@ -5,6 +5,7 @@
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/plugin_dispatcher.h"
+#include "ppapi/proxy/plugin_proxy_delegate.h"
#include "ppapi/thunk/enter.h"
namespace ppapi {
@@ -59,6 +60,14 @@ PP_Module PluginGlobals::GetModuleForInstance(PP_Instance instance) {
return 0;
}
+std::string PluginGlobals::GetCmdLine() {
+ return command_line_;
+}
+
+void PluginGlobals::PreCacheFontForFlash(const void* logfontw) {
+ plugin_proxy_delegate_->PreCacheFont(logfontw);
+}
+
base::Lock* PluginGlobals::GetProxyLock() {
#ifdef ENABLE_PEPPER_THREADING
return &proxy_lock_;
diff --git a/ppapi/proxy/plugin_globals.h b/ppapi/proxy/plugin_globals.h
index 2b0d48c..a349ba1 100644
--- a/ppapi/proxy/plugin_globals.h
+++ b/ppapi/proxy/plugin_globals.h
@@ -42,6 +42,8 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals {
virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
ApiID id) OVERRIDE;
virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
+ virtual std::string GetCmdLine() OVERRIDE;
+ virtual void PreCacheFontForFlash(const void* logfontw) OVERRIDE;
virtual base::Lock* GetProxyLock() OVERRIDE;
virtual void LogWithSource(PP_Instance instance,
PP_LogLevel_Dev level,
@@ -86,6 +88,9 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals {
// is known. This will be used for error logging.
void set_plugin_name(const std::string& name) { plugin_name_ = name; }
+ // The embedder should call this function when the command line is known.
+ void set_command_line(const std::string& c) { command_line_ = c; }
+
private:
// PpapiGlobals overrides.
virtual bool IsPluginGlobals() const OVERRIDE;
@@ -101,9 +106,13 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals {
scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_;
// Name of the plugin used for error logging. This will be empty until
- // SetPluginName is called.
+ // set_plugin_name is called.
std::string plugin_name_;
+ // Command line for the plugin. This will be empty until set_command_line is
+ // called.
+ std::string command_line_;
+
DISALLOW_COPY_AND_ASSIGN(PluginGlobals);
};
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index cf2c2c1..565adf0 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -862,14 +862,6 @@ IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBInstance_GetScreenSize,
PP_Instance /* instance */,
PP_Bool /* result */,
PP_Size /* size */)
-IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBInstance_FlashSetFullscreen,
- PP_Instance /* instance */,
- PP_Bool /* fullscreen */,
- PP_Bool /* result */)
-IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBInstance_FlashGetScreenSize,
- PP_Instance /* instance */,
- PP_Bool /* result */,
- PP_Size /* size */)
IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_RequestInputEvents,
PP_Instance /* instance */,
bool /* is_filtering */,
@@ -1175,6 +1167,14 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_IsRectTopmost,
PP_Instance /* instance */,
PP_Rect /* rect */,
PP_Bool /* result */)
+IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_FlashSetFullscreen,
+ PP_Instance /* instance */,
+ PP_Bool /* fullscreen */,
+ PP_Bool /* result */)
+IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBFlash_FlashGetScreenSize,
+ PP_Instance /* instance */,
+ PP_Bool /* result */,
+ PP_Size /* size */)
IPC_MESSAGE_ROUTED0(PpapiHostMsg_PPBFlash_UpdateActivity)
IPC_SYNC_MESSAGE_ROUTED0_1(PpapiHostMsg_PPBFlash_GetDeviceID,
std::string /* id */)
diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc
index f61d8b3..f176bd0 100644
--- a/ppapi/proxy/ppb_flash_proxy.cc
+++ b/ppapi/proxy/ppb_flash_proxy.cc
@@ -26,35 +26,74 @@
#include "ppapi/shared_impl/scoped_pp_resource.h"
#include "ppapi/shared_impl/var.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/ppb_url_request_info_api.h"
#include "ppapi/thunk/resource_creation_api.h"
namespace ppapi {
namespace proxy {
-namespace {
+PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher)
+ : InterfaceProxy(dispatcher),
+ ppb_flash_impl_(NULL) {
+ if (!dispatcher->IsPlugin())
+ ppb_flash_impl_ = static_cast<const PPB_Flash*>(
+ dispatcher->local_get_interface()(PPB_FLASH_INTERFACE));
+}
-void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) {
- ProxyAutoLock lock;
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance);
- if (dispatcher) {
- dispatcher->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop(
- API_ID_PPB_FLASH, pp_instance, on_top));
- }
+PPB_Flash_Proxy::~PPB_Flash_Proxy() {
}
-PP_Bool DrawGlyphs(PP_Instance instance,
- PP_Resource pp_image_data,
- const PP_FontDescription_Dev* font_desc,
- uint32_t color,
- const PP_Point* position,
- const PP_Rect* clip,
- const float transformation[3][3],
- PP_Bool allow_subpixel_aa,
- uint32_t glyph_count,
- const uint16_t glyph_indices[],
- const PP_Point glyph_advances[]) {
- ProxyAutoLock lock;
+bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) {
+ // Prevent the dispatcher from going away during a call to Navigate.
+ // This must happen OUTSIDE of OnMsgNavigate since the handling code use
+ // the dispatcher upon return of the function (sending the reply message).
+ ScopedModuleReference death_grip(dispatcher());
+
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop,
+ OnHostMsgSetInstanceAlwaysOnTop)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs,
+ OnHostMsgDrawGlyphs)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL,
+ OnHostMsgGetProxyForURL)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnHostMsgNavigate)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RunMessageLoop,
+ OnHostMsgRunMessageLoop)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop,
+ OnHostMsgQuitMessageLoop)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset,
+ OnHostMsgGetLocalTimeZoneOffset)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost,
+ OnHostMsgIsRectTopmost)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen,
+ OnHostMsgFlashSetFullscreen)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize,
+ OnHostMsgFlashGetScreenSize)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ // TODO(brettw) handle bad messages!
+ return handled;
+}
+
+void PPB_Flash_Proxy::SetInstanceAlwaysOnTop(PP_Instance instance,
+ PP_Bool on_top) {
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop(
+ API_ID_PPB_FLASH, instance, on_top));
+}
+
+PP_Bool PPB_Flash_Proxy::DrawGlyphs(PP_Instance instance,
+ PP_Resource pp_image_data,
+ const PP_FontDescription_Dev* font_desc,
+ uint32_t color,
+ const PP_Point* position,
+ const PP_Rect* clip,
+ const float transformation[3][3],
+ PP_Bool allow_subpixel_aa,
+ uint32_t glyph_count,
+ const uint16_t glyph_indices[],
+ const PP_Point glyph_advances[]) {
Resource* image_data =
PpapiGlobals::Get()->GetResourceTracker()->GetResource(pp_image_data);
if (!image_data)
@@ -64,14 +103,9 @@ PP_Bool DrawGlyphs(PP_Instance instance,
if (image_data->pp_instance() != instance)
return PP_FALSE;
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(
- image_data->pp_instance());
- if (!dispatcher)
- return PP_FALSE;
-
PPBFlash_DrawGlyphs_Params params;
params.image_data = image_data->host_resource();
- params.font_desc.SetFromPPFontDescription(dispatcher, *font_desc, true);
+ params.font_desc.SetFromPPFontDescription(dispatcher(), *font_desc, true);
params.color = color;
params.position = *position;
params.clip = *clip;
@@ -89,92 +123,49 @@ PP_Bool DrawGlyphs(PP_Instance instance,
&glyph_advances[glyph_count]);
PP_Bool result = PP_FALSE;
- dispatcher->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs(
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs(
API_ID_PPB_FLASH, params, &result));
return result;
}
-PP_Bool DrawGlyphs11(PP_Instance instance,
- PP_Resource pp_image_data,
- const PP_FontDescription_Dev* font_desc,
- uint32_t color,
- PP_Point position,
- PP_Rect clip,
- const float transformation[3][3],
- uint32_t glyph_count,
- const uint16_t glyph_indices[],
- const PP_Point glyph_advances[]) {
- // Backwards-compatible version. DrawGlyphs locks; no need to lock here.
- return DrawGlyphs(instance, pp_image_data, font_desc, color, &position,
- &clip, transformation, PP_TRUE, glyph_count, glyph_indices,
- glyph_advances);
-}
-
-PP_Var GetProxyForURL(PP_Instance instance, const char* url) {
- ProxyAutoLock lock;
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return PP_MakeUndefined();
-
+PP_Var PPB_Flash_Proxy::GetProxyForURL(PP_Instance instance, const char* url) {
ReceiveSerializedVarReturnValue result;
- dispatcher->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL(
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL(
API_ID_PPB_FLASH, instance, url, &result));
- return result.Return(dispatcher);
+ return result.Return(dispatcher());
}
-int32_t Navigate(PP_Resource request_id,
- const char* target,
- PP_Bool from_user_action) {
- thunk::EnterResource<thunk::PPB_URLRequestInfo_API> enter(request_id, true);
+int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance,
+ PP_Resource request_info,
+ const char* target,
+ PP_Bool from_user_action) {
+ thunk::EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter(
+ request_info, true);
if (enter.failed())
return PP_ERROR_BADRESOURCE;
- PP_Instance instance = enter.resource()->pp_instance();
-
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return PP_ERROR_FAILED;
int32_t result = PP_ERROR_FAILED;
- dispatcher->Send(new PpapiHostMsg_PPBFlash_Navigate(
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_Navigate(
API_ID_PPB_FLASH,
instance, enter.object()->GetData(), target, from_user_action,
&result));
return result;
}
-int32_t Navigate11(PP_Resource request_id,
- const char* target,
- bool from_user_action) {
- // Backwards-compatible version. Navigate locks; no need to lock here.
- return Navigate(request_id, target, PP_FromBool(from_user_action));
-}
-
-void RunMessageLoop(PP_Instance instance) {
- ProxyAutoLock lock;
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return;
+void PPB_Flash_Proxy::RunMessageLoop(PP_Instance instance) {
IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop(
API_ID_PPB_FLASH, instance);
msg->EnableMessagePumping();
- dispatcher->Send(msg);
+ dispatcher()->Send(msg);
}
-void QuitMessageLoop(PP_Instance instance) {
- ProxyAutoLock lock;
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return;
- dispatcher->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop(
+void PPB_Flash_Proxy::QuitMessageLoop(PP_Instance instance) {
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop(
API_ID_PPB_FLASH, instance));
}
-double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) {
- ProxyAutoLock lock;
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return 0.0;
-
+double PPB_Flash_Proxy::GetLocalTimeZoneOffset(PP_Instance instance,
+ PP_Time t) {
// TODO(brettw) on Windows it should be possible to do the time calculation
// in-process since it doesn't need to read files on disk. This will improve
// performance.
@@ -182,178 +173,67 @@ double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) {
// On Linux, it would be better to go directly to the browser process for
// this message rather than proxy it through some instance in a renderer.
double result = 0;
- dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset(
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset(
API_ID_PPB_FLASH, instance, t, &result));
return result;
}
-PP_Var GetCommandLineArgs(PP_Module /*pp_module*/) {
- ProxyAutoLock lock;
- std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs();
- return StringVar::StringToPPVar(args);
-}
-
-void PreLoadFontWin(const void* logfontw) {
- ProxyAutoLock lock;
- PluginGlobals::Get()->plugin_proxy_delegate()->PreCacheFont(logfontw);
-}
-
-PP_Bool IsRectTopmost(PP_Instance instance, const PP_Rect* rect) {
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return PP_FALSE;
+PP_Bool PPB_Flash_Proxy::IsRectTopmost(PP_Instance instance,
+ const PP_Rect* rect) {
PP_Bool result = PP_FALSE;
- dispatcher->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost(
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost(
API_ID_PPB_FLASH, instance, *rect, &result));
return result;
}
-int32_t InvokePrinting(PP_Instance instance) {
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return PP_ERROR_BADARGUMENT;
-
- // TODO(viettrungluu): Implement me.
-
+int32_t PPB_Flash_Proxy::InvokePrinting(PP_Instance instance) {
return PP_ERROR_NOTSUPPORTED;
}
-void UpdateActivity(PP_Instance instance) {
+void PPB_Flash_Proxy::UpdateActivity(PP_Instance instance) {
PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(
new PpapiHostMsg_PPBFlash_UpdateActivity(API_ID_PPB_FLASH));
}
-PP_Var GetDeviceID(PP_Instance instance) {
+PP_Var PPB_Flash_Proxy::GetDeviceID(PP_Instance instance) {
std::string id;
PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(
new PpapiHostMsg_PPBFlash_GetDeviceID(API_ID_PPB_FLASH, &id));
return StringVar::StringToPPVar(id);
}
-const PPB_Flash_11 flash_interface_11 = {
- &SetInstanceAlwaysOnTop,
- &DrawGlyphs11,
- &GetProxyForURL,
- &Navigate11,
- &RunMessageLoop,
- &QuitMessageLoop,
- &GetLocalTimeZoneOffset,
- &GetCommandLineArgs
-};
-
-const PPB_Flash_12_0 flash_interface_12_0 = {
- &SetInstanceAlwaysOnTop,
- &DrawGlyphs,
- &GetProxyForURL,
- &Navigate,
- &RunMessageLoop,
- &QuitMessageLoop,
- &GetLocalTimeZoneOffset,
- &GetCommandLineArgs,
- &PreLoadFontWin
-};
-
-const PPB_Flash_12_1 flash_interface_12_1 = {
- &SetInstanceAlwaysOnTop,
- &DrawGlyphs,
- &GetProxyForURL,
- &Navigate,
- &RunMessageLoop,
- &QuitMessageLoop,
- &GetLocalTimeZoneOffset,
- &GetCommandLineArgs,
- &PreLoadFontWin,
- &IsRectTopmost,
- &InvokePrinting,
- &UpdateActivity
-};
-
-const PPB_Flash_12_2 flash_interface_12_2 = {
- &SetInstanceAlwaysOnTop,
- &DrawGlyphs,
- &GetProxyForURL,
- &Navigate,
- &RunMessageLoop,
- &QuitMessageLoop,
- &GetLocalTimeZoneOffset,
- &GetCommandLineArgs,
- &PreLoadFontWin,
- &IsRectTopmost,
- &InvokePrinting,
- &UpdateActivity,
- &GetDeviceID
-};
-
-} // namespace
-
-PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher)
- : InterfaceProxy(dispatcher),
- ppb_flash_impl_(NULL) {
- if (!dispatcher->IsPlugin())
- ppb_flash_impl_ = static_cast<const PPB_Flash*>(
- dispatcher->local_get_interface()(PPB_FLASH_INTERFACE));
-}
-
-PPB_Flash_Proxy::~PPB_Flash_Proxy() {
-}
-
-// static
-const PPB_Flash_11* PPB_Flash_Proxy::GetInterface11() {
- return &flash_interface_11;
-}
-
-// static
-const PPB_Flash_12_0* PPB_Flash_Proxy::GetInterface12_0() {
- return &flash_interface_12_0;
-}
-
-// static
-const PPB_Flash_12_1* PPB_Flash_Proxy::GetInterface12_1() {
- return &flash_interface_12_1;
+PP_Bool PPB_Flash_Proxy::FlashIsFullscreen(PP_Instance instance) {
+ InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
+ GetInstanceData(instance);
+ if (!data)
+ return PP_FALSE;
+ return data->flash_fullscreen;
}
-// static
-const PPB_Flash_12_2* PPB_Flash_Proxy::GetInterface12_2() {
- return &flash_interface_12_2;
+PP_Bool PPB_Flash_Proxy::FlashSetFullscreen(PP_Instance instance,
+ PP_Bool fullscreen) {
+ PP_Bool result = PP_FALSE;
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashSetFullscreen(
+ API_ID_PPB_FLASH, instance, fullscreen, &result));
+ return result;
}
-bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) {
- // Prevent the dispatcher from going away during a call to Navigate.
- // This must happen OUTSIDE of OnMsgNavigate since the handling code use
- // the dispatcher upon return of the function (sending the reply message).
- ScopedModuleReference death_grip(dispatcher());
-
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop,
- OnMsgSetInstanceAlwaysOnTop)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs,
- OnMsgDrawGlyphs)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL,
- OnMsgGetProxyForURL)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnMsgNavigate)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RunMessageLoop,
- OnMsgRunMessageLoop)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop,
- OnMsgQuitMessageLoop)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset,
- OnMsgGetLocalTimeZoneOffset)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost,
- OnMsgIsRectTopmost)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- // TODO(brettw) handle bad messages!
- return handled;
+PP_Bool PPB_Flash_Proxy::FlashGetScreenSize(PP_Instance instance,
+ PP_Size* size) {
+ PP_Bool result = PP_FALSE;
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashGetScreenSize(
+ API_ID_PPB_FLASH, instance, &result, size));
+ return result;
}
-void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop(
- PP_Instance instance,
- PP_Bool on_top) {
+void PPB_Flash_Proxy::OnHostMsgSetInstanceAlwaysOnTop(PP_Instance instance,
+ PP_Bool on_top) {
ppb_flash_impl_->SetInstanceAlwaysOnTop(instance, on_top);
}
-void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params,
- PP_Bool* result) {
+void PPB_Flash_Proxy::OnHostMsgDrawGlyphs(
+ const PPBFlash_DrawGlyphs_Params& params,
+ PP_Bool* result) {
*result = PP_FALSE;
PP_FontDescription_Dev font_desc;
@@ -374,18 +254,18 @@ void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params,
const_cast<PP_Point*>(&params.glyph_advances[0]));
}
-void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance,
- const std::string& url,
- SerializedVarReturnValue result) {
+void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance,
+ const std::string& url,
+ SerializedVarReturnValue result) {
result.Return(dispatcher(), ppb_flash_impl_->GetProxyForURL(
instance, url.c_str()));
}
-void PPB_Flash_Proxy::OnMsgNavigate(PP_Instance instance,
- const PPB_URLRequestInfo_Data& data,
- const std::string& target,
- PP_Bool from_user_action,
- int32_t* result) {
+void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance,
+ const PPB_URLRequestInfo_Data& data,
+ const std::string& target,
+ PP_Bool from_user_action,
+ int32_t* result) {
DCHECK(!dispatcher()->IsPlugin());
// Validate the PP_Instance since we'll be constructing resources on its
@@ -419,25 +299,47 @@ void PPB_Flash_Proxy::OnMsgNavigate(PP_Instance instance,
from_user_action);
}
-void PPB_Flash_Proxy::OnMsgRunMessageLoop(PP_Instance instance) {
+void PPB_Flash_Proxy::OnHostMsgRunMessageLoop(PP_Instance instance) {
ppb_flash_impl_->RunMessageLoop(instance);
}
-void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) {
+void PPB_Flash_Proxy::OnHostMsgQuitMessageLoop(PP_Instance instance) {
ppb_flash_impl_->QuitMessageLoop(instance);
}
-void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance,
+void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance,
PP_Time t,
double* result) {
*result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t);
}
-void PPB_Flash_Proxy::OnMsgIsRectTopmost(PP_Instance instance,
- PP_Rect rect,
- PP_Bool* result) {
+void PPB_Flash_Proxy::OnHostMsgIsRectTopmost(PP_Instance instance,
+ PP_Rect rect,
+ PP_Bool* result) {
*result = ppb_flash_impl_->IsRectTopmost(instance, &rect);
}
+void PPB_Flash_Proxy::OnHostMsgFlashSetFullscreen(PP_Instance instance,
+ PP_Bool fullscreen,
+ PP_Bool* result) {
+ thunk::EnterFunctionNoLock<thunk::PPB_Instance_FunctionAPI> enter(
+ instance, false);
+ if (enter.failed())
+ return;
+ *result = enter.functions()->GetFlashAPI()->FlashSetFullscreen(
+ instance, fullscreen);
+}
+
+void PPB_Flash_Proxy::OnHostMsgFlashGetScreenSize(PP_Instance instance,
+ PP_Bool* result,
+ PP_Size* size) {
+ thunk::EnterFunctionNoLock<thunk::PPB_Instance_FunctionAPI> enter(
+ instance, false);
+ if (enter.failed())
+ return;
+ *result = enter.functions()->GetFlashAPI()->FlashGetScreenSize(
+ instance, size);
+}
+
} // namespace proxy
} // namespace ppapi
diff --git a/ppapi/proxy/ppb_flash_proxy.h b/ppapi/proxy/ppb_flash_proxy.h
index 00ee011..1c051e5 100644
--- a/ppapi/proxy/ppb_flash_proxy.h
+++ b/ppapi/proxy/ppb_flash_proxy.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/compiler_specific.h"
#include "ipc/ipc_platform_file.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_instance.h"
@@ -16,6 +17,7 @@
#include "ppapi/c/private/ppb_flash.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/shared_impl/host_resource.h"
+#include "ppapi/thunk/ppb_flash_api.h"
namespace ppapi {
@@ -26,41 +28,78 @@ namespace proxy {
struct PPBFlash_DrawGlyphs_Params;
class SerializedVarReturnValue;
-class PPB_Flash_Proxy : public InterfaceProxy {
+class PPB_Flash_Proxy : public InterfaceProxy,
+ public thunk::PPB_Flash_API {
public:
explicit PPB_Flash_Proxy(Dispatcher* dispatcher);
virtual ~PPB_Flash_Proxy();
- // Returns the corresponding version of the Flash interface pointer.
- static const PPB_Flash_11* GetInterface11();
- static const PPB_Flash_12_0* GetInterface12_0();
- static const PPB_Flash_12_1* GetInterface12_1();
- static const PPB_Flash_12_2* GetInterface12_2();
-
// InterfaceProxy implementation.
virtual bool OnMessageReceived(const IPC::Message& msg);
+ // PPB_Flash_API implementation.
+ virtual void SetInstanceAlwaysOnTop(PP_Instance instance,
+ PP_Bool on_top) OVERRIDE;
+ virtual PP_Bool DrawGlyphs(PP_Instance instance,
+ PP_Resource pp_image_data,
+ const PP_FontDescription_Dev* font_desc,
+ uint32_t color,
+ const PP_Point* position,
+ const PP_Rect* clip,
+ const float transformation[3][3],
+ PP_Bool allow_subpixel_aa,
+ uint32_t glyph_count,
+ const uint16_t glyph_indices[],
+ const PP_Point glyph_advances[]) OVERRIDE;
+ virtual PP_Var GetProxyForURL(PP_Instance instance, const char* url) OVERRIDE;
+ virtual int32_t Navigate(PP_Instance instance,
+ PP_Resource request_info,
+ const char* target,
+ PP_Bool from_user_action) OVERRIDE;
+ virtual void RunMessageLoop(PP_Instance instance) OVERRIDE;
+ virtual void QuitMessageLoop(PP_Instance instance) OVERRIDE;
+ virtual double GetLocalTimeZoneOffset(PP_Instance instance,
+ PP_Time t) OVERRIDE;
+ virtual PP_Bool IsRectTopmost(PP_Instance instance,
+ const PP_Rect* rect) OVERRIDE;
+ virtual int32_t InvokePrinting(PP_Instance instance) OVERRIDE;
+ virtual void UpdateActivity(PP_Instance instance) OVERRIDE;
+ virtual PP_Var GetDeviceID(PP_Instance instance) OVERRIDE;
+ virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE;
+ virtual PP_Bool FlashSetFullscreen(PP_Instance instance,
+ PP_Bool fullscreen) OVERRIDE;
+ virtual PP_Bool FlashGetScreenSize(PP_Instance instance,
+ PP_Size* size) OVERRIDE;
+
+ static const ApiID kApiID = API_ID_PPB_FLASH;
+
private:
// Message handlers.
- void OnMsgSetInstanceAlwaysOnTop(PP_Instance instance,
- PP_Bool on_top);
- void OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params,
- PP_Bool* result);
- void OnMsgGetProxyForURL(PP_Instance instance,
- const std::string& url,
- SerializedVarReturnValue result);
- void OnMsgNavigate(PP_Instance instance,
- const PPB_URLRequestInfo_Data& data,
- const std::string& target,
- PP_Bool from_user_action,
- int32_t* result);
- void OnMsgRunMessageLoop(PP_Instance instance);
- void OnMsgQuitMessageLoop(PP_Instance instance);
- void OnMsgGetLocalTimeZoneOffset(PP_Instance instance, PP_Time t,
- double* result);
- void OnMsgIsRectTopmost(PP_Instance instance,
- PP_Rect rect,
- PP_Bool* result);
+ void OnHostMsgSetInstanceAlwaysOnTop(PP_Instance instance,
+ PP_Bool on_top);
+ void OnHostMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params,
+ PP_Bool* result);
+ void OnHostMsgGetProxyForURL(PP_Instance instance,
+ const std::string& url,
+ SerializedVarReturnValue result);
+ void OnHostMsgNavigate(PP_Instance instance,
+ const PPB_URLRequestInfo_Data& data,
+ const std::string& target,
+ PP_Bool from_user_action,
+ int32_t* result);
+ void OnHostMsgRunMessageLoop(PP_Instance instance);
+ void OnHostMsgQuitMessageLoop(PP_Instance instance);
+ void OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance, PP_Time t,
+ double* result);
+ void OnHostMsgIsRectTopmost(PP_Instance instance,
+ PP_Rect rect,
+ PP_Bool* result);
+ void OnHostMsgFlashSetFullscreen(PP_Instance instance,
+ PP_Bool fullscreen,
+ PP_Bool* result);
+ void OnHostMsgFlashGetScreenSize(PP_Instance instance,
+ PP_Bool* result,
+ PP_Size* size);
// When this proxy is in the host side, this value caches the interface
// pointer so we don't have to retrieve it from the dispatcher each time.
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index 77afa30..9873321 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -16,6 +16,7 @@
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_proxy_delegate.h"
#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/ppb_flash_proxy.h"
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/ppb_url_util_shared.h"
@@ -96,10 +97,6 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgGetDefaultCharSet)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage,
OnHostMsgPostMessage)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_FlashSetFullscreen,
- OnHostMsgFlashSetFullscreen)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_FlashGetScreenSize,
- OnHostMsgFlashGetScreenSize)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen,
OnHostMsgSetFullscreen)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetScreenSize,
@@ -239,14 +236,6 @@ void PPB_Instance_Proxy::SelectedFindResultChanged(PP_Instance instance,
NOTIMPLEMENTED(); // Not proxied yet.
}
-PP_Bool PPB_Instance_Proxy::FlashIsFullscreen(PP_Instance instance) {
- InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
- GetInstanceData(instance);
- if (!data)
- return PP_FALSE;
- return data->flash_fullscreen;
-}
-
PP_Var PPB_Instance_Proxy::GetFontFamilies(PP_Instance instance) {
PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
if (!dispatcher)
@@ -270,14 +259,6 @@ PP_Bool PPB_Instance_Proxy::SetFullscreen(PP_Instance instance,
return result;
}
-PP_Bool PPB_Instance_Proxy::FlashSetFullscreen(PP_Instance instance,
- PP_Bool fullscreen) {
- PP_Bool result = PP_FALSE;
- dispatcher()->Send(new PpapiHostMsg_PPBInstance_FlashSetFullscreen(
- API_ID_PPB_INSTANCE, instance, fullscreen, &result));
- return result;
-}
-
PP_Bool PPB_Instance_Proxy::GetScreenSize(PP_Instance instance,
PP_Size* size) {
PP_Bool result = PP_FALSE;
@@ -286,12 +267,9 @@ PP_Bool PPB_Instance_Proxy::GetScreenSize(PP_Instance instance,
return result;
}
-PP_Bool PPB_Instance_Proxy::FlashGetScreenSize(PP_Instance instance,
- PP_Size* size) {
- PP_Bool result = PP_FALSE;
- dispatcher()->Send(new PpapiHostMsg_PPBInstance_FlashGetScreenSize(
- API_ID_PPB_INSTANCE, instance, &result, size));
- return result;
+thunk::PPB_Flash_API* PPB_Instance_Proxy::GetFlashAPI() {
+ InterfaceProxy* ip = dispatcher()->GetInterfaceProxy(API_ID_PPB_FLASH);
+ return static_cast<PPB_Flash_Proxy*>(ip);
}
void PPB_Instance_Proxy::SampleGamepads(PP_Instance instance,
@@ -549,14 +527,6 @@ void PPB_Instance_Proxy::OnHostMsgSetFullscreen(PP_Instance instance,
}
-void PPB_Instance_Proxy::OnHostMsgFlashSetFullscreen(PP_Instance instance,
- PP_Bool fullscreen,
- PP_Bool* result) {
- EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false);
- if (enter.succeeded())
- *result = enter.functions()->FlashSetFullscreen(instance, fullscreen);
-}
-
void PPB_Instance_Proxy::OnHostMsgGetScreenSize(PP_Instance instance,
PP_Bool* result,
PP_Size* size) {
@@ -565,14 +535,6 @@ void PPB_Instance_Proxy::OnHostMsgGetScreenSize(PP_Instance instance,
*result = enter.functions()->GetScreenSize(instance, size);
}
-void PPB_Instance_Proxy::OnHostMsgFlashGetScreenSize(PP_Instance instance,
- PP_Bool* result,
- PP_Size* size) {
- EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false);
- if (enter.succeeded())
- *result = enter.functions()->FlashGetScreenSize(instance, size);
-}
-
void PPB_Instance_Proxy::OnHostMsgRequestInputEvents(PP_Instance instance,
bool is_filtering,
uint32_t event_classes) {
diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h
index aed90ab..d408af7 100644
--- a/ppapi/proxy/ppb_instance_proxy.h
+++ b/ppapi/proxy/ppb_instance_proxy.h
@@ -67,12 +67,8 @@ class PPB_Instance_Proxy : public InterfaceProxy,
virtual PP_Bool SetFullscreen(PP_Instance instance,
PP_Bool fullscreen) OVERRIDE;
virtual PP_Bool GetScreenSize(PP_Instance instance,
- PP_Size* size) OVERRIDE;
- virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE;
- virtual PP_Bool FlashSetFullscreen(PP_Instance instance,
- PP_Bool fullscreen) OVERRIDE;
- virtual PP_Bool FlashGetScreenSize(PP_Instance instance, PP_Size* size)
- OVERRIDE;
+ PP_Size* size) OVERRIDE;
+ virtual thunk::PPB_Flash_API* GetFlashAPI() OVERRIDE;
virtual void SampleGamepads(PP_Instance instance,
PP_GamepadsSampleData* data) OVERRIDE;
virtual int32_t RequestInputEvents(PP_Instance instance,
@@ -139,12 +135,6 @@ class PPB_Instance_Proxy : public InterfaceProxy,
void OnHostMsgGetScreenSize(PP_Instance instance,
PP_Bool* result,
PP_Size* size);
- void OnHostMsgFlashSetFullscreen(PP_Instance instance,
- PP_Bool fullscreen,
- PP_Bool* result);
- void OnHostMsgFlashGetScreenSize(PP_Instance instance,
- PP_Bool* result,
- PP_Size* size);
void OnHostMsgRequestInputEvents(PP_Instance instance,
bool is_filtering,
uint32_t event_classes);
diff --git a/ppapi/shared_impl/ppapi_globals.h b/ppapi/shared_impl/ppapi_globals.h
index d83e9c6..b1c3879 100644
--- a/ppapi/shared_impl/ppapi_globals.h
+++ b/ppapi/shared_impl/ppapi_globals.h
@@ -95,6 +95,14 @@ class PPAPI_SHARED_EXPORT PpapiGlobals {
// failure.
virtual PP_Module GetModuleForInstance(PP_Instance instance) = 0;
+ // Returns the command line for the process.
+ virtual std::string GetCmdLine() = 0;
+
+ // Preloads the font on Windows, does nothing on other platforms.
+ // TODO(brettw) remove this by passing the instance into the API so we don't
+ // have to have it on the globals.
+ virtual void PreCacheFontForFlash(const void* logfontw) = 0;
+
virtual bool IsHostGlobals() const;
virtual bool IsPluginGlobals() const;
diff --git a/ppapi/shared_impl/test_globals.cc b/ppapi/shared_impl/test_globals.cc
index 102dc11..9972d22 100644
--- a/ppapi/shared_impl/test_globals.cc
+++ b/ppapi/shared_impl/test_globals.cc
@@ -40,6 +40,13 @@ PP_Module TestGlobals::GetModuleForInstance(PP_Instance instance) {
return 0;
}
+std::string TestGlobals::GetCmdLine() {
+ return std::string();
+}
+
+void TestGlobals::PreCacheFontForFlash(const void* /* logfontw */) {
+}
+
base::Lock* TestGlobals::GetProxyLock() {
return NULL;
}
diff --git a/ppapi/shared_impl/test_globals.h b/ppapi/shared_impl/test_globals.h
index ae6f4b2..cf1be89 100644
--- a/ppapi/shared_impl/test_globals.h
+++ b/ppapi/shared_impl/test_globals.h
@@ -38,6 +38,8 @@ class TestGlobals : public PpapiGlobals {
virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
ApiID id) OVERRIDE;
virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
+ virtual std::string GetCmdLine() OVERRIDE;
+ virtual void PreCacheFontForFlash(const void* logfontw) OVERRIDE;
virtual base::Lock* GetProxyLock() OVERRIDE;
virtual void LogWithSource(PP_Instance instance,
PP_LogLevel_Dev level,
diff --git a/ppapi/thunk/interfaces_ppb_private_flash.h b/ppapi/thunk/interfaces_ppb_private_flash.h
new file mode 100644
index 0000000..6d9fa82
--- /dev/null
+++ b/ppapi/thunk/interfaces_ppb_private_flash.h
@@ -0,0 +1,25 @@
+// 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.
+
+// Please see inteface_ppb_public_stable for the documentation on the format of
+// this file.
+
+#include "ppapi/thunk/interfaces_preamble.h"
+
+PROXIED_API(PPB_Flash)
+
+PROXIED_IFACE(PPB_Flash,
+ PPB_FLASH_INTERFACE_11_0,
+ PPB_Flash_11)
+PROXIED_IFACE(PPB_Flash,
+ PPB_FLASH_INTERFACE_12_0,
+ PPB_Flash_12_0)
+PROXIED_IFACE(PPB_Flash,
+ PPB_FLASH_INTERFACE_12_1,
+ PPB_Flash_12_1)
+PROXIED_IFACE(PPB_Flash,
+ PPB_FLASH_INTERFACE_12_2,
+ PPB_Flash_12_2)
+
+#include "ppapi/thunk/interfaces_postamble.h"
diff --git a/ppapi/thunk/ppb_flash_api.h b/ppapi/thunk/ppb_flash_api.h
new file mode 100644
index 0000000..eacc9e8
--- /dev/null
+++ b/ppapi/thunk/ppb_flash_api.h
@@ -0,0 +1,55 @@
+// 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_THUNK_PPB_FLASH_API_H_
+#define PPAPI_THUNK_PPB_FLASH_API_H_
+
+#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/thunk/ppapi_thunk_export.h"
+
+namespace ppapi {
+namespace thunk {
+
+// This class collects all of the Flash interface-related APIs into one place.
+class PPAPI_THUNK_EXPORT PPB_Flash_API {
+ public:
+ virtual ~PPB_Flash_API() {}
+
+ // Flash.
+ virtual void SetInstanceAlwaysOnTop(PP_Instance instance, PP_Bool on_top) = 0;
+ virtual PP_Bool DrawGlyphs(PP_Instance instance,
+ PP_Resource pp_image_data,
+ const PP_FontDescription_Dev* font_desc,
+ uint32_t color,
+ const PP_Point* position,
+ const PP_Rect* clip,
+ const float transformation[3][3],
+ PP_Bool allow_subpixel_aa,
+ uint32_t glyph_count,
+ const uint16_t glyph_indices[],
+ const PP_Point glyph_advances[]) = 0;
+ virtual PP_Var GetProxyForURL(PP_Instance instance, const char* url) = 0;
+ virtual int32_t Navigate(PP_Instance instance,
+ PP_Resource request_info,
+ const char* target,
+ PP_Bool from_user_action) = 0;
+ virtual void RunMessageLoop(PP_Instance instance) = 0;
+ virtual void QuitMessageLoop(PP_Instance instance) = 0;
+ virtual double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) = 0;
+ virtual PP_Bool IsRectTopmost(PP_Instance instance, const PP_Rect* rect) = 0;
+ virtual int32_t InvokePrinting(PP_Instance instance) = 0;
+ virtual void UpdateActivity(PP_Instance instance) = 0;
+ virtual PP_Var GetDeviceID(PP_Instance instance) = 0;
+
+ // FlashFullscreen.
+ virtual PP_Bool FlashIsFullscreen(PP_Instance instance) = 0;
+ virtual PP_Bool FlashSetFullscreen(PP_Instance instance,
+ PP_Bool fullscreen) = 0;
+ virtual PP_Bool FlashGetScreenSize(PP_Instance instance, PP_Size* size) = 0;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_PPB_FLASH_API_H_
diff --git a/ppapi/thunk/ppb_flash_fullscreen_thunk.cc b/ppapi/thunk/ppb_flash_fullscreen_thunk.cc
index ecaea96..aa9e224 100644
--- a/ppapi/thunk/ppb_flash_fullscreen_thunk.cc
+++ b/ppapi/thunk/ppb_flash_fullscreen_thunk.cc
@@ -7,6 +7,7 @@
#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_instance_api.h"
+#include "ppapi/thunk/ppb_flash_api.h"
#include "ppapi/thunk/resource_creation_api.h"
namespace ppapi {
@@ -18,21 +19,22 @@ PP_Bool IsFullscreen(PP_Instance instance) {
EnterInstance enter(instance);
if (enter.failed())
return PP_FALSE;
- return enter.functions()->FlashIsFullscreen(instance);
+ return enter.functions()->GetFlashAPI()->FlashIsFullscreen(instance);
}
PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) {
EnterInstance enter(instance);
if (enter.failed())
return PP_FALSE;
- return enter.functions()->FlashSetFullscreen(instance, fullscreen);
+ return enter.functions()->GetFlashAPI()->FlashSetFullscreen(instance,
+ fullscreen);
}
PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) {
EnterInstance enter(instance);
if (enter.failed())
return PP_FALSE;
- return enter.functions()->FlashGetScreenSize(instance, size);
+ return enter.functions()->GetFlashAPI()->FlashGetScreenSize(instance, size);
}
const PPB_FlashFullscreen g_ppb_flash_fullscreen_thunk = {
diff --git a/ppapi/thunk/ppb_flash_thunk.cc b/ppapi/thunk/ppb_flash_thunk.cc
new file mode 100644
index 0000000..970cbac
--- /dev/null
+++ b/ppapi/thunk/ppb_flash_thunk.cc
@@ -0,0 +1,231 @@
+// 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/pp_errors.h"
+#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/proxy_lock.h"
+#include "ppapi/shared_impl/var.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_flash_api.h"
+#include "ppapi/thunk/ppb_instance_api.h"
+#include "ppapi/thunk/thunk.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+void SetInstanceAlwaysOnTop(PP_Instance instance, PP_Bool on_top) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return;
+ enter.functions()->GetFlashAPI()->SetInstanceAlwaysOnTop(instance, on_top);
+}
+
+PP_Bool DrawGlyphs(PP_Instance instance,
+ PP_Resource pp_image_data,
+ const PP_FontDescription_Dev* font_desc,
+ uint32_t color,
+ const PP_Point* position,
+ const PP_Rect* clip,
+ const float transformation[3][3],
+ PP_Bool allow_subpixel_aa,
+ uint32_t glyph_count,
+ const uint16_t glyph_indices[],
+ const PP_Point glyph_advances[]) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.functions()->GetFlashAPI()->DrawGlyphs(
+ instance, pp_image_data, font_desc, color, position, clip, transformation,
+ allow_subpixel_aa, glyph_count, glyph_indices, glyph_advances);
+}
+
+PP_Bool DrawGlyphs11(PP_Instance instance,
+ PP_Resource pp_image_data,
+ const PP_FontDescription_Dev* font_desc,
+ uint32_t color,
+ PP_Point position,
+ PP_Rect clip,
+ const float transformation[3][3],
+ uint32_t glyph_count,
+ const uint16_t glyph_indices[],
+ const PP_Point glyph_advances[]) {
+ // Backwards-compatible version. DrawGlyphs locks; no need to lock here.
+ return DrawGlyphs(instance, pp_image_data, font_desc, color, &position,
+ &clip, transformation, PP_TRUE, glyph_count, glyph_indices,
+ glyph_advances);
+}
+
+PP_Var GetProxyForURL(PP_Instance instance, const char* url) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_MakeUndefined();
+ return enter.functions()->GetFlashAPI()->GetProxyForURL(instance, url);
+}
+
+int32_t Navigate(PP_Resource request_id,
+ const char* target,
+ PP_Bool from_user_action) {
+ // TODO(brettw): this function should take an instance.
+ // To work around this, use the PP_Instance from the resource.
+ PP_Instance instance;
+ {
+ thunk::EnterResource<thunk::PPB_URLRequestInfo_API> enter(request_id, true);
+ if (enter.failed())
+ return PP_ERROR_BADRESOURCE;
+ instance = enter.resource()->pp_instance();
+ }
+
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_ERROR_BADARGUMENT;
+ return enter.functions()->GetFlashAPI()->Navigate(instance, request_id,
+ target, from_user_action);
+}
+
+int32_t Navigate11(PP_Resource request_id,
+ const char* target,
+ bool from_user_action) {
+ // Backwards-compatible version. Navigate locks; no need to lock here.
+ return Navigate(request_id, target, PP_FromBool(from_user_action));
+}
+
+void RunMessageLoop(PP_Instance instance) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return;
+ enter.functions()->GetFlashAPI()->RunMessageLoop(instance);
+}
+
+void QuitMessageLoop(PP_Instance instance) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return;
+ enter.functions()->GetFlashAPI()->QuitMessageLoop(instance);
+}
+
+double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return 0.0;
+ return enter.functions()->GetFlashAPI()->GetLocalTimeZoneOffset(instance, t);
+}
+
+PP_Var GetCommandLineArgs(PP_Module /* pp_module */) {
+ // There's no instance so we have to reach into the globals without thunking.
+ ProxyAutoLock lock;
+ return StringVar::StringToPPVar(PpapiGlobals::Get()->GetCmdLine());
+}
+
+void PreLoadFontWin(const void* logfontw) {
+ // There's no instance so we have to reach into the delegate without
+ // thunking.
+ ProxyAutoLock lock;
+ PpapiGlobals::Get()->PreCacheFontForFlash(logfontw);
+}
+
+PP_Bool IsRectTopmost(PP_Instance instance, const PP_Rect* rect) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.functions()->GetFlashAPI()->IsRectTopmost(instance, rect);
+}
+
+int32_t InvokePrinting(PP_Instance instance) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_ERROR_BADARGUMENT;
+ return enter.functions()->GetFlashAPI()->InvokePrinting(instance);
+}
+
+void UpdateActivity(PP_Instance instance) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return;
+ enter.functions()->GetFlashAPI()->UpdateActivity(instance);
+}
+
+PP_Var GetDeviceID(PP_Instance instance) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_MakeUndefined();
+ return enter.functions()->GetFlashAPI()->GetDeviceID(instance);
+}
+
+const PPB_Flash_11 g_ppb_flash_11_thunk = {
+ &SetInstanceAlwaysOnTop,
+ &DrawGlyphs11,
+ &GetProxyForURL,
+ &Navigate11,
+ &RunMessageLoop,
+ &QuitMessageLoop,
+ &GetLocalTimeZoneOffset,
+ &GetCommandLineArgs
+};
+
+const PPB_Flash_12_0 g_ppb_flash_12_0_thunk = {
+ &SetInstanceAlwaysOnTop,
+ &DrawGlyphs,
+ &GetProxyForURL,
+ &Navigate,
+ &RunMessageLoop,
+ &QuitMessageLoop,
+ &GetLocalTimeZoneOffset,
+ &GetCommandLineArgs,
+ &PreLoadFontWin
+};
+
+const PPB_Flash_12_1 g_ppb_flash_12_1_thunk = {
+ &SetInstanceAlwaysOnTop,
+ &DrawGlyphs,
+ &GetProxyForURL,
+ &Navigate,
+ &RunMessageLoop,
+ &QuitMessageLoop,
+ &GetLocalTimeZoneOffset,
+ &GetCommandLineArgs,
+ &PreLoadFontWin,
+ &IsRectTopmost,
+ &InvokePrinting,
+ &UpdateActivity
+};
+
+const PPB_Flash_12_2 g_ppb_flash_12_2_thunk = {
+ &SetInstanceAlwaysOnTop,
+ &DrawGlyphs,
+ &GetProxyForURL,
+ &Navigate,
+ &RunMessageLoop,
+ &QuitMessageLoop,
+ &GetLocalTimeZoneOffset,
+ &GetCommandLineArgs,
+ &PreLoadFontWin,
+ &IsRectTopmost,
+ &InvokePrinting,
+ &UpdateActivity,
+ &GetDeviceID
+};
+
+} // namespace
+
+const PPB_Flash_11* GetPPB_Flash_11_Thunk() {
+ return &g_ppb_flash_11_thunk;
+}
+
+const PPB_Flash_12_0* GetPPB_Flash_12_0_Thunk() {
+ return &g_ppb_flash_12_0_thunk;
+}
+
+const PPB_Flash_12_1* GetPPB_Flash_12_1_Thunk() {
+ return &g_ppb_flash_12_1_thunk;
+}
+
+const PPB_Flash_12_2* GetPPB_Flash_12_2_Thunk() {
+ return &g_ppb_flash_12_2_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h
index 0993702..05ebe8b 100644
--- a/ppapi/thunk/ppb_instance_api.h
+++ b/ppapi/thunk/ppb_instance_api.h
@@ -29,6 +29,8 @@ struct ViewData;
namespace thunk {
+class PPB_Flash_API;
+
class PPB_Instance_FunctionAPI {
public:
virtual ~PPB_Instance_FunctionAPI() {}
@@ -77,11 +79,8 @@ class PPB_Instance_FunctionAPI {
PP_Bool fullscreen) = 0;
virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) = 0;
- // FlashFullscreen.
- virtual PP_Bool FlashIsFullscreen(PP_Instance instance) = 0;
- virtual PP_Bool FlashSetFullscreen(PP_Instance instance,
- PP_Bool fullscreen) = 0;
- virtual PP_Bool FlashGetScreenSize(PP_Instance instance, PP_Size* size) = 0;
+ // Flash.
+ virtual PPB_Flash_API* GetFlashAPI() = 0;
// Gamepad.
virtual void SampleGamepads(PP_Instance instance,
diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h
index e98e71b..09a7e5f 100644
--- a/ppapi/thunk/thunk.h
+++ b/ppapi/thunk/thunk.h
@@ -38,6 +38,7 @@
#define UNPROXIED_IFACE IFACE
#include "ppapi/thunk/interfaces_ppb_private.h"
+#include "ppapi/thunk/interfaces_ppb_private_flash.h"
#include "ppapi/thunk/interfaces_ppb_public_stable.h"
#include "ppapi/thunk/interfaces_ppb_public_dev.h"