summaryrefslogtreecommitdiffstats
path: root/webkit/plugins
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-29 18:26:36 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-29 18:26:36 +0000
commit912f3d6c2193584bc9376ed17f3dd2b90e78a40e (patch)
tree98729e7a810cc29cdc414ea8e0e75e9967a0ac4c /webkit/plugins
parent0daefc769a7578184c1c57ef2b59970a41d8cf79 (diff)
downloadchromium_src-912f3d6c2193584bc9376ed17f3dd2b90e78a40e.zip
chromium_src-912f3d6c2193584bc9376ed17f3dd2b90e78a40e.tar.gz
chromium_src-912f3d6c2193584bc9376ed17f3dd2b90e78a40e.tar.bz2
Make o.o.p. proxy handle PPP_Instance versions 0.4 and 0.5.
Move & tweak PPP_Instance_Combined to ppapi_shared so the proxy can use it. Use versioned PPP_Instance types only. BUG=82606 TEST=run tests o.o.p. Review URL: http://codereview.chromium.org/7189045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90984 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc30
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc48
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h46
-rw-r--r--webkit/plugins/ppapi/ppapi_unittest.cc10
-rw-r--r--webkit/plugins/ppapi/resource_tracker_unittest.cc10
5 files changed, 70 insertions, 74 deletions
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index b9df850..340d0e44 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -213,21 +213,12 @@ const PPB_Testing_Dev testing_interface = {
&GetLiveObjectsForInstance
};
-// Return the part of the interface name before the ';' separator.
-// If there is no ';', just returns the whole string.
-std::string GetInterfacePrefix(const std::string& interface_string) {
- size_t separator_pos = interface_string.find_first_of(';');
- return interface_string.substr(0, separator_pos);
-}
-
// GetInterface ----------------------------------------------------------------
const void* GetInterface(const char* name) {
// All interfaces should be used on the main thread.
DCHECK(IsMainThread());
- std::string name_prefix(GetInterfacePrefix(name));
-
// Allow custom interface factories first stab at the GetInterface call.
const void* custom_interface =
PpapiInterfaceFactoryManager::GetInstance()->GetInterface(name);
@@ -490,21 +481,14 @@ PluginModule::GetInterfaceFunc PluginModule::GetLocalGetInterfaceFunc() {
PluginInstance* PluginModule::CreateInstance(PluginDelegate* delegate) {
PluginInstance* instance(NULL);
- const void* plugin_instance_if =
- GetPluginInterface(PPP_INSTANCE_INTERFACE_0_5);
- if (plugin_instance_if) {
- instance = new PluginInstance(delegate, this,
- PluginInstance::new_instance_interface<PPP_Instance_0_5>(
- plugin_instance_if));
+ const void* ppp_instance = GetPluginInterface(PPP_INSTANCE_INTERFACE_0_5);
+ if (ppp_instance) {
+ instance = PluginInstance::Create0_5(delegate, this, ppp_instance);
} else {
- // If the current interface is not supported, try retrieving older versions.
- const void* instance_if_0_4 =
- GetPluginInterface(PPP_INSTANCE_INTERFACE_0_4);
- if (instance_if_0_4) {
- instance = new PluginInstance(delegate, this,
- PluginInstance::new_instance_interface<PPP_Instance_0_4>(
- instance_if_0_4));
- }
+ // If the 0.5 interface is not supported, try retrieving 0.4.
+ ppp_instance = GetPluginInterface(PPP_INSTANCE_INTERFACE_0_4);
+ if (ppp_instance)
+ instance = PluginInstance::Create0_4(delegate, this, ppp_instance);
}
if (!instance) {
LOG(WARNING) << "Plugin doesn't support instance interface, failing.";
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index dac78fc..0e809c4 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -238,9 +238,34 @@ const PPB_Zoom_Dev ppb_zoom = {
} // namespace
-PluginInstance::PluginInstance(PluginDelegate* delegate,
- PluginModule* module,
- PPP_Instance_Combined* instance_interface)
+// static
+PluginInstance* PluginInstance::Create0_5(PluginDelegate* delegate,
+ PluginModule* module,
+ const void* ppp_instance_if_0_5) {
+ const PPP_Instance_0_5* interface =
+ static_cast<const PPP_Instance_0_5*>(ppp_instance_if_0_5);
+ return new PluginInstance(
+ delegate,
+ module,
+ new ::ppapi::PPP_Instance_Combined(*interface));
+}
+
+// static
+PluginInstance* PluginInstance::Create0_4(PluginDelegate* delegate,
+ PluginModule* module,
+ const void* ppp_instance_if_0_4) {
+ const PPP_Instance_0_4* interface =
+ static_cast<const PPP_Instance_0_4*>(ppp_instance_if_0_4);
+ return new PluginInstance(
+ delegate,
+ module,
+ new ::ppapi::PPP_Instance_Combined(*interface));
+}
+
+PluginInstance::PluginInstance(
+ PluginDelegate* delegate,
+ PluginModule* module,
+ ::ppapi::PPP_Instance_Combined* instance_interface)
: delegate_(delegate),
module_(module),
instance_interface_(instance_interface),
@@ -691,23 +716,6 @@ bool PluginInstance::LoadFindInterface() {
return !!plugin_find_interface_;
}
-PluginInstance::PPP_Instance_Combined::PPP_Instance_Combined(
- const PPP_Instance_0_5& instance_if)
- : PPP_Instance_0_5(instance_if),
- GetInstanceObject_0_4(NULL) {}
-
-PluginInstance::PPP_Instance_Combined::PPP_Instance_Combined(
- const PPP_Instance_0_4& instance_if)
- : PPP_Instance_0_5(), // Zero-initialize.
- GetInstanceObject_0_4(instance_if.GetInstanceObject) {
- DidCreate = instance_if.DidCreate;
- DidDestroy = instance_if.DidDestroy;
- DidChangeView = instance_if.DidChangeView;
- DidChangeFocus = instance_if.DidChangeFocus;
- HandleInputEvent = instance_if.HandleInputEvent;
- HandleDocumentLoad = instance_if.HandleDocumentLoad;
-}
-
bool PluginInstance::LoadMessagingInterface() {
if (!checked_for_plugin_messaging_interface_) {
checked_for_plugin_messaging_interface_ = true;
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 2ef4710..8cbcaa2 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -24,6 +24,7 @@
#include "ppapi/c/pp_var.h"
#include "ppapi/c/ppp_instance.h"
#include "ppapi/shared_impl/function_group_base.h"
+#include "ppapi/shared_impl/ppp_instance_combined.h"
#include "ppapi/thunk/ppb_instance_api.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkRefCnt.h"
@@ -55,6 +56,10 @@ class WebInputEvent;
class WebPluginContainer;
}
+namespace ppapi {
+struct PPP_Instance_Combined;
+}
+
namespace webkit {
namespace ppapi {
@@ -79,11 +84,17 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
public ::ppapi::FunctionGroupBase,
public ::ppapi::thunk::PPB_Instance_FunctionAPI {
public:
- struct PPP_Instance_Combined;
-
- PluginInstance(PluginDelegate* delegate,
- PluginModule* module,
- PPP_Instance_Combined* instance_interface);
+ // Create and return a PluginInstance object which supports the
+ // PPP_Instance_0_5 interface.
+ static PluginInstance* Create0_5(PluginDelegate* delegate,
+ PluginModule* module,
+ const void* ppp_instance_if_0_5);
+
+ // Create and return a PluginInstance object which supports the
+ // PPP_Instance_0_4 interface.
+ static PluginInstance* Create0_4(PluginDelegate* delegate,
+ PluginModule* module,
+ const void* ppp_instance_if_0_4);
// Delete should be called by the WebPlugin before this destructor.
virtual ~PluginInstance();
@@ -256,21 +267,6 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
return fullscreen_container_;
}
- // TODO(dmichael): Remove this when all plugins are ported to use scripting
- // from private interfaces.
- struct PPP_Instance_Combined : public PPP_Instance_0_5 {
- PPP_Instance_Combined(const PPP_Instance_0_5& instance_if);
- PPP_Instance_Combined(const PPP_Instance_0_4& instance_if);
-
- struct PP_Var (*const GetInstanceObject_0_4)(PP_Instance instance);
- };
- template <class InterfaceType>
- static PPP_Instance_Combined* new_instance_interface(
- const void* interface_object) {
- return new PPP_Instance_Combined(
- *static_cast<const InterfaceType*>(interface_object));
- }
-
// FunctionGroupBase overrides.
virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI()
OVERRIDE;
@@ -290,6 +286,14 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) OVERRIDE;
private:
+ // See the static Create functions above for creating PluginInstance objects.
+ // This constructor is private so that we can hide the PPP_Instance_Combined
+ // details while still having 1 constructor to maintain for member
+ // initialization.
+ PluginInstance(PluginDelegate* delegate,
+ PluginModule* module,
+ ::ppapi::PPP_Instance_Combined* instance_interface);
+
bool LoadFindInterface();
bool LoadMessagingInterface();
bool LoadPdfInterface();
@@ -343,7 +347,7 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
PluginDelegate* delegate_;
scoped_refptr<PluginModule> module_;
- scoped_ptr<PPP_Instance_Combined> instance_interface_;
+ scoped_ptr< ::ppapi::PPP_Instance_Combined> instance_interface_;
PP_Instance pp_instance_;
diff --git a/webkit/plugins/ppapi/ppapi_unittest.cc b/webkit/plugins/ppapi/ppapi_unittest.cc
index 3a276cc..03a9793 100644
--- a/webkit/plugins/ppapi/ppapi_unittest.cc
+++ b/webkit/plugins/ppapi/ppapi_unittest.cc
@@ -90,9 +90,11 @@ void PpapiUnittest::SetUp() {
ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points));
// Initialize the mock instance.
- instance_ = new PluginInstance(delegate_.get(), module(),
- PluginInstance::new_instance_interface<PPP_Instance>(
- GetMockInterface(PPP_INSTANCE_INTERFACE)));
+ instance_ = PluginInstance::Create0_5(
+ delegate_.get(),
+ module(),
+ GetMockInterface(PPP_INSTANCE_INTERFACE_0_5));
+
}
void PpapiUnittest::TearDown() {
@@ -101,7 +103,7 @@ void PpapiUnittest::TearDown() {
}
const void* PpapiUnittest::GetMockInterface(const char* interface_name) const {
- if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0)
+ if (strcmp(interface_name, PPP_INSTANCE_INTERFACE_0_5) == 0)
return &mock_instance_interface;
return NULL;
}
diff --git a/webkit/plugins/ppapi/resource_tracker_unittest.cc b/webkit/plugins/ppapi/resource_tracker_unittest.cc
index cde0444..e73b243 100644
--- a/webkit/plugins/ppapi/resource_tracker_unittest.cc
+++ b/webkit/plugins/ppapi/resource_tracker_unittest.cc
@@ -141,9 +141,8 @@ TEST_F(ResourceTrackerTest, Ref) {
TEST_F(ResourceTrackerTest, DeleteResourceWithInstance) {
// Make a second instance (the test harness already creates & manages one).
scoped_refptr<PluginInstance> instance2(
- new PluginInstance(delegate(), module(),
- PluginInstance::new_instance_interface<PPP_Instance>(
- GetMockInterface(PPP_INSTANCE_INTERFACE))));
+ PluginInstance::Create0_5(delegate(), module(),
+ GetMockInterface(PPP_INSTANCE_INTERFACE_0_5)));
PP_Instance pp_instance2 = instance2->pp_instance();
// Make two resources and take refs on behalf of the "plugin" for each.
@@ -176,9 +175,8 @@ TEST_F(ResourceTrackerTest, DeleteResourceWithInstance) {
TEST_F(ResourceTrackerTest, DeleteObjectVarWithInstance) {
// Make a second instance (the test harness already creates & manages one).
scoped_refptr<PluginInstance> instance2(
- new PluginInstance(delegate(), module(),
- PluginInstance::new_instance_interface<PPP_Instance>(
- GetMockInterface(PPP_INSTANCE_INTERFACE))));
+ PluginInstance::Create0_5(delegate(), module(),
+ GetMockInterface(PPP_INSTANCE_INTERFACE_0_5)));
PP_Instance pp_instance2 = instance2->pp_instance();
// Make an object var.