summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 04:42:57 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 04:42:57 +0000
commit870b2878217f1b48579b7e0baf1b2fc5e8e6d086 (patch)
tree58e68d023049740d4a116609115d62d4e176e8a3
parent99ddfd29900cc4caa1f1ffd979cc09be3f104336 (diff)
downloadchromium_src-870b2878217f1b48579b7e0baf1b2fc5e8e6d086.zip
chromium_src-870b2878217f1b48579b7e0baf1b2fc5e8e6d086.tar.gz
chromium_src-870b2878217f1b48579b7e0baf1b2fc5e8e6d086.tar.bz2
Remove all direct calls to NPN_ functions in WebCore. The replacement for these is the WebKit::WebBindings API.
This will be a 2 sided commit with https://bugs.webkit.org/show_bug.cgi?id=28089 TEST=none BUG=none Review URL: http://codereview.chromium.org/164214 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23012 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--DEPS2
-rw-r--r--chrome/plugin/npobject_util.cc7
-rw-r--r--webkit/api/public/WebBindings.h3
-rw-r--r--webkit/api/src/WebBindings.cpp48
-rw-r--r--webkit/glue/cpp_variant_unittest.cc52
-rw-r--r--webkit/glue/plugins/plugin_host.cc54
6 files changed, 90 insertions, 76 deletions
diff --git a/DEPS b/DEPS
index f4543e5..69c2663 100644
--- a/DEPS
+++ b/DEPS
@@ -1,7 +1,7 @@
vars = {
"webkit_trunk":
"http://svn.webkit.org/repository/webkit/trunk",
- "webkit_revision": "47020",
+ "webkit_revision": "47021",
}
diff --git a/chrome/plugin/npobject_util.cc b/chrome/plugin/npobject_util.cc
index ecf5606..3625992 100644
--- a/chrome/plugin/npobject_util.cc
+++ b/chrome/plugin/npobject_util.cc
@@ -8,10 +8,13 @@
#include "chrome/common/plugin_messages.h"
#include "chrome/plugin/npobject_proxy.h"
#include "chrome/plugin/plugin_channel_base.h"
+#include "webkit/api/public/WebBindings.h"
#include "webkit/glue/plugins/nphostapi.h"
#include "webkit/glue/plugins/plugin_host.h"
#include "webkit/glue/webkit_glue.h"
+using WebKit::WebBindings;
+
// true if the current process is a plugin process, false if it's a renderer
// process.
static bool g_plugin_process;
@@ -200,7 +203,7 @@ void CreateNPVariantParam(const NPVariant& variant,
}
if (release)
- NPN_ReleaseVariantValue(const_cast<NPVariant*>(&variant));
+ WebBindings::releaseVariantValue(const_cast<NPVariant*>(&variant));
}
void CreateNPVariant(const NPVariant_Param& param,
@@ -247,7 +250,7 @@ void CreateNPVariant(const NPVariant_Param& param,
result->type = NPVariantType_Object;
result->value.objectValue =
reinterpret_cast<NPObject*>(param.npobject_pointer);
- NPN_RetainObject(result->value.objectValue);
+ WebBindings::retainObject(result->value.objectValue);
break;
default:
NOTREACHED();
diff --git a/webkit/api/public/WebBindings.h b/webkit/api/public/WebBindings.h
index 17af60f..76e0f13 100644
--- a/webkit/api/public/WebBindings.h
+++ b/webkit/api/public/WebBindings.h
@@ -53,6 +53,9 @@ namespace WebKit {
// NPN_Enumerate
WEBKIT_API static bool enumerate(NPP id, NPObject* obj, NPIdentifier** identifier, uint32_t* val);
+ // NPN_Evaluate
+ WEBKIT_API static bool evaluate(NPP npp, NPObject* npObject, NPString* npScript, NPVariant* result);
+
// NPN_EvaluateHelper
WEBKIT_API static bool evaluateHelper(NPP npp, bool popups_allowed, NPObject* npobj, NPString* npscript, NPVariant* result);
diff --git a/webkit/api/src/WebBindings.cpp b/webkit/api/src/WebBindings.cpp
index 0aee60e..f4567d4 100644
--- a/webkit/api/src/WebBindings.cpp
+++ b/webkit/api/src/WebBindings.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "WebBindings.h"
+#include "npruntime_impl.h"
#include "npruntime_priv.h"
#include "webkit/api/public/WebDragData.h"
@@ -56,62 +57,67 @@ namespace WebKit {
bool WebBindings::construct(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant* result)
{
- return NPN_Construct(npp, npobj, args, argCount, result);
+ return _NPN_Construct(npp, npobj, args, argCount, result);
}
NPObject* WebBindings::createObject(NPP npp, NPClass* npClass)
{
- return NPN_CreateObject(npp, npClass);
+ return _NPN_CreateObject(npp, npClass);
}
bool WebBindings::enumerate(NPP id, NPObject* obj, NPIdentifier** identifier, uint32_t* val)
{
- return NPN_Enumerate(id, obj, identifier, val);
+ return _NPN_Enumerate(id, obj, identifier, val);
+}
+
+bool WebBindings::evaluate(NPP npp, NPObject* npObject, NPString* npScript, NPVariant* result)
+{
+ return _NPN_Evaluate(npp, npObject, npScript, result);
}
bool WebBindings::evaluateHelper(NPP npp, bool popups_allowed, NPObject* npobj, NPString* npscript, NPVariant* result)
{
- return NPN_EvaluateHelper(npp, popups_allowed, npobj, npscript, result);
+ return _NPN_EvaluateHelper(npp, popups_allowed, npobj, npscript, result);
}
NPIdentifier WebBindings::getIntIdentifier(int32_t number)
{
- return NPN_GetIntIdentifier(number);
+ return _NPN_GetIntIdentifier(number);
}
bool WebBindings::getProperty(NPP npp, NPObject* obj, NPIdentifier propertyName, NPVariant *result)
{
- return NPN_GetProperty(npp, obj, propertyName, result);
+ return _NPN_GetProperty(npp, obj, propertyName, result);
}
NPIdentifier WebBindings::getStringIdentifier(const NPUTF8* string)
{
- return NPN_GetStringIdentifier(string);
+ return _NPN_GetStringIdentifier(string);
}
void WebBindings::getStringIdentifiers(const NPUTF8** names, int32_t nameCount, NPIdentifier* identifiers)
{
- NPN_GetStringIdentifiers(names, nameCount, identifiers);
+ _NPN_GetStringIdentifiers(names, nameCount, identifiers);
}
bool WebBindings::hasMethod(NPP npp, NPObject* npObject, NPIdentifier methodName)
{
- return NPN_HasMethod(npp, npObject, methodName);
+ return _NPN_HasMethod(npp, npObject, methodName);
}
bool WebBindings::hasProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName)
{
- return NPN_HasProperty(npp, npObject, propertyName);
+ return _NPN_HasProperty(npp, npObject, propertyName);
}
bool WebBindings::identifierIsString(NPIdentifier identifier)
{
- return NPN_IdentifierIsString(identifier);
+ return _NPN_IdentifierIsString(identifier);
}
int32_t WebBindings::intFromIdentifier(NPIdentifier identifier)
{
- return NPN_IntFromIdentifier(identifier);
+ return _NPN_IntFromIdentifier(identifier);
}
void WebBindings::initializeVariantWithStringCopy(NPVariant* variant, const NPString* value)
@@ -125,42 +131,42 @@ void WebBindings::initializeVariantWithStringCopy(NPVariant* variant, const NPSt
bool WebBindings::invoke(NPP npp, NPObject* npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
- return NPN_Invoke(npp, npObject, methodName, arguments, argumentCount, result);
+ return _NPN_Invoke(npp, npObject, methodName, arguments, argumentCount, result);
}
bool WebBindings::invokeDefault(NPP id, NPObject* obj, const NPVariant* args, uint32_t count, NPVariant* result)
{
- return NPN_InvokeDefault(id, obj, args, count, result);
+ return _NPN_InvokeDefault(id, obj, args, count, result);
}
void WebBindings::releaseObject(NPObject* npObject)
{
- return NPN_ReleaseObject(npObject);
+ return _NPN_ReleaseObject(npObject);
}
void WebBindings::releaseVariantValue(NPVariant* variant)
{
- NPN_ReleaseVariantValue(variant);
+ _NPN_ReleaseVariantValue(variant);
}
bool WebBindings::removeProperty(NPP id, NPObject* object, NPIdentifier identifier)
{
- return NPN_RemoveProperty(id, object, identifier);
+ return _NPN_RemoveProperty(id, object, identifier);
}
NPObject* WebBindings::retainObject(NPObject* npObject)
{
- return NPN_RetainObject(npObject);
+ return _NPN_RetainObject(npObject);
}
void WebBindings::setException(NPObject* obj, const NPUTF8* message)
{
- NPN_SetException(obj, message);
+ _NPN_SetException(obj, message);
}
bool WebBindings::setProperty(NPP id, NPObject* obj, NPIdentifier identifier, const NPVariant* variant)
{
- return NPN_SetProperty(id, obj, identifier, variant);
+ return _NPN_SetProperty(id, obj, identifier, variant);
}
void WebBindings::unregisterObject(NPObject* npObject)
@@ -172,7 +178,7 @@ void WebBindings::unregisterObject(NPObject* npObject)
NPUTF8* WebBindings::utf8FromIdentifier(NPIdentifier identifier)
{
- return NPN_UTF8FromIdentifier(identifier);
+ return _NPN_UTF8FromIdentifier(identifier);
}
void WebBindings::extractIdentifierData(const NPIdentifier& identifier, const NPUTF8*& string, int32_t& number, bool& isString)
diff --git a/webkit/glue/cpp_variant_unittest.cc b/webkit/glue/cpp_variant_unittest.cc
index 46747a2..a2d9f3d 100644
--- a/webkit/glue/cpp_variant_unittest.cc
+++ b/webkit/glue/cpp_variant_unittest.cc
@@ -6,6 +6,7 @@
#include "base/compiler_specific.h"
+#include "webkit/api/public/WebBindings.h"
#include "webkit/glue/cpp_variant.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -13,9 +14,7 @@ MSVC_PUSH_WARNING_LEVEL(0);
#include "npruntime_priv.h" // for NPN_InitializeVariantWithStringCopy
MSVC_POP_WARNING();
-#if USE(JSC)
-#define _NPN_InitializeVariantWithStringCopy NPN_InitializeVariantWithStringCopy
-#endif
+using WebKit::WebBindings;
// Creates a std::string from an NPVariant of string type. If the NPVariant
// is not a string, empties the std::string.
@@ -60,7 +59,7 @@ void CheckObject(const NPVariant& actual) {
NPObject* MockNPAllocate(NPP npp, NPClass* aClass) {
// This is a mock allocate method that mimics the behavior
- // of NPN_CreateObject when allocate() is NULL
+ // of WebBindings::createObject when allocate() is NULL
++g_allocate_call_count;
// Ignore npp and NPClass
@@ -83,7 +82,7 @@ static NPClass void_class = { NP_CLASS_STRUCT_VERSION,
NPObject* MakeVoidObject() {
g_allocate_call_count = 0;
g_deallocate_call_count = 0;
- return NPN_CreateObject(NULL, &void_class);
+ return WebBindings::createObject(NULL, &void_class);
}
TEST(CppVariantTest, NewVariantHasNullType) {
@@ -122,7 +121,7 @@ TEST(CppVariantTest, CopyConstructorIncrementsRefCount) {
CppVariant dest = source;
EXPECT_EQ(3U, dest.value.objectValue->referenceCount);
EXPECT_EQ(1, g_allocate_call_count);
- NPN_ReleaseObject(object);
+ WebBindings::releaseObject(object);
source.SetNull();
CheckObject(dest);
}
@@ -154,7 +153,7 @@ TEST(CppVariantTest, AssignmentIncrementsRefCount) {
EXPECT_EQ(3U, dest.value.objectValue->referenceCount);
EXPECT_EQ(1, g_allocate_call_count);
- NPN_ReleaseObject(object);
+ WebBindings::releaseObject(object);
source.SetNull();
CheckObject(dest);
}
@@ -174,7 +173,7 @@ TEST(CppVariantTest, DestroyingCopyDoesNotCorruptSource) {
{
CppVariant dest2 = source;
}
- NPN_ReleaseObject(object);
+ WebBindings::releaseObject(object);
CheckObject(source);
}
@@ -186,37 +185,37 @@ TEST(CppVariantTest, CopiesTypeAndValueToNPVariant) {
cpp.CopyToNPVariant(&np);
EXPECT_EQ(cpp.type, np.type);
EXPECT_EQ(cpp.value.boolValue, np.value.boolValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
cpp.Set(17);
cpp.CopyToNPVariant(&np);
EXPECT_EQ(cpp.type, np.type);
EXPECT_EQ(cpp.value.intValue, np.value.intValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
cpp.Set(3.1415);
cpp.CopyToNPVariant(&np);
EXPECT_EQ(cpp.type, np.type);
EXPECT_EQ(cpp.value.doubleValue, np.value.doubleValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
cpp.Set("test value");
cpp.CopyToNPVariant(&np);
CheckString("test value", np);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
cpp.SetNull();
cpp.CopyToNPVariant(&np);
EXPECT_EQ(cpp.type, np.type);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
NPObject *object = MakeVoidObject();
cpp.Set(object);
cpp.CopyToNPVariant(&np);
- NPN_ReleaseObject(object);
+ WebBindings::releaseObject(object);
cpp.SetNull();
CheckObject(np);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
}
TEST(CppVariantTest, SetsTypeAndValueFromNPVariant) {
@@ -226,37 +225,37 @@ TEST(CppVariantTest, SetsTypeAndValueFromNPVariant) {
VOID_TO_NPVARIANT(np);
cpp.Set(np);
EXPECT_EQ(np.type, cpp.type);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
NULL_TO_NPVARIANT(np);
cpp.Set(np);
EXPECT_EQ(np.type, cpp.type);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
BOOLEAN_TO_NPVARIANT(true, np);
cpp.Set(np);
EXPECT_EQ(np.type, cpp.type);
EXPECT_EQ(np.value.boolValue, cpp.value.boolValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
INT32_TO_NPVARIANT(15, np);
cpp.Set(np);
EXPECT_EQ(np.type, cpp.type);
EXPECT_EQ(np.value.intValue, cpp.value.intValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
DOUBLE_TO_NPVARIANT(2.71828, np);
cpp.Set(np);
EXPECT_EQ(np.type, cpp.type);
EXPECT_EQ(np.value.doubleValue, cpp.value.doubleValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
NPString np_ascii_str = { "1st test value",
static_cast<uint32_t>(strlen("1st test value")) };
_NPN_InitializeVariantWithStringCopy(&np, &np_ascii_str);
cpp.Set(np);
CheckString("1st test value", cpp);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
// Test characters represented in 2/3/4 bytes in UTF-8
// Greek alpha, Chinese number 1 (horizontal bar),
@@ -267,12 +266,13 @@ TEST(CppVariantTest, SetsTypeAndValueFromNPVariant) {
_NPN_InitializeVariantWithStringCopy(&np, &np_intl_str);
cpp.Set(np);
CheckString("\xce\xb1\xe4\xb8\x80\xf0\x90\x90\x84", cpp);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
NPObject *obj = MakeVoidObject();
OBJECT_TO_NPVARIANT(obj, np); // Doesn't make a copy.
cpp.Set(np);
- NPN_ReleaseVariantValue(&np); // or NPN_ReleaseObject but NOT both
+ // Use this or WebBindings::releaseObject but NOT both.
+ WebBindings::releaseVariantValue(&np);
CheckObject(cpp);
}
@@ -318,7 +318,7 @@ TEST(CppVariantTest, SetsSimpleTypesAndValues) {
NPObject* obj = MakeVoidObject();
cpp.Set(obj);
- NPN_ReleaseObject(obj);
+ WebBindings::releaseObject(obj);
CheckObject(cpp);
}
@@ -341,7 +341,7 @@ TEST(CppVariantTest, FreeDataReleasesObject) {
EXPECT_EQ(0, g_deallocate_call_count);
cpp.Set(object);
- NPN_ReleaseObject(object);
+ WebBindings::releaseObject(object);
EXPECT_EQ(0, g_deallocate_call_count);
cpp.FreeData();
EXPECT_EQ(1, g_deallocate_call_count);
@@ -428,6 +428,6 @@ TEST(CppVariantTest, IsTypeFunctionsWork) {
EXPECT_FALSE(cpp.isNull());
EXPECT_FALSE(cpp.isEmpty());
EXPECT_TRUE(cpp.isObject());
- NPN_ReleaseObject(obj);
+ WebBindings::releaseObject(obj);
CheckObject(cpp);
}
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc
index 09d43e6..27445a5 100644
--- a/webkit/glue/plugins/plugin_host.cc
+++ b/webkit/glue/plugins/plugin_host.cc
@@ -11,6 +11,7 @@
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "net/base/net_util.h"
+#include "webkit/api/public/WebBindings.h"
#include "webkit/default_plugin/default_plugin_shared.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/webplugininfo.h"
@@ -21,6 +22,7 @@
#include "webkit/glue/plugins/plugin_stream_url.h"
#include "third_party/npapi/bindings/npruntime.h"
+using WebKit::WebBindings;
namespace NPAPI
{
@@ -75,30 +77,30 @@ void PluginHost::InitializeHostFuncs() {
host_funcs_.forceredraw = &NPN_ForceRedraw;
// These come from the Javascript Engine
- host_funcs_.getstringidentifier = NPN_GetStringIdentifier;
- host_funcs_.getstringidentifiers = NPN_GetStringIdentifiers;
- host_funcs_.getintidentifier = NPN_GetIntIdentifier;
- host_funcs_.identifierisstring = NPN_IdentifierIsString;
- host_funcs_.utf8fromidentifier = NPN_UTF8FromIdentifier;
- host_funcs_.intfromidentifier = NPN_IntFromIdentifier;
- host_funcs_.createobject = NPN_CreateObject;
- host_funcs_.retainobject = NPN_RetainObject;
- host_funcs_.releaseobject = NPN_ReleaseObject;
- host_funcs_.invoke = NPN_Invoke;
- host_funcs_.invokeDefault = NPN_InvokeDefault;
- host_funcs_.evaluate = NPN_Evaluate;
- host_funcs_.getproperty = NPN_GetProperty;
- host_funcs_.setproperty = NPN_SetProperty;
- host_funcs_.removeproperty = NPN_RemoveProperty;
- host_funcs_.hasproperty = NPN_HasProperty;
- host_funcs_.hasmethod = NPN_HasMethod;
- host_funcs_.releasevariantvalue = NPN_ReleaseVariantValue;
- host_funcs_.setexception = NPN_SetException;
- host_funcs_.pushpopupsenabledstate = &NPN_PushPopupsEnabledState;
- host_funcs_.poppopupsenabledstate = &NPN_PopPopupsEnabledState;
- host_funcs_.enumerate = &NPN_Enumerate;
- host_funcs_.pluginthreadasynccall = &NPN_PluginThreadAsyncCall;
- host_funcs_.construct = &NPN_Construct;
+ host_funcs_.getstringidentifier = WebBindings::getStringIdentifier;
+ host_funcs_.getstringidentifiers = WebBindings::getStringIdentifiers;
+ host_funcs_.getintidentifier = WebBindings::getIntIdentifier;
+ host_funcs_.identifierisstring = WebBindings::identifierIsString;
+ host_funcs_.utf8fromidentifier = WebBindings::utf8FromIdentifier;
+ host_funcs_.intfromidentifier = WebBindings::intFromIdentifier;
+ host_funcs_.createobject = WebBindings::createObject;
+ host_funcs_.retainobject = WebBindings::retainObject;
+ host_funcs_.releaseobject = WebBindings::releaseObject;
+ host_funcs_.invoke = WebBindings::invoke;
+ host_funcs_.invokeDefault = WebBindings::invokeDefault;
+ host_funcs_.evaluate = WebBindings::evaluate;
+ host_funcs_.getproperty = WebBindings::getProperty;
+ host_funcs_.setproperty = WebBindings::setProperty;
+ host_funcs_.removeproperty = WebBindings::removeProperty;
+ host_funcs_.hasproperty = WebBindings::hasProperty;
+ host_funcs_.hasmethod = WebBindings::hasMethod;
+ host_funcs_.releasevariantvalue = WebBindings::releaseVariantValue;
+ host_funcs_.setexception = WebBindings::setException;
+ host_funcs_.pushpopupsenabledstate = NPN_PushPopupsEnabledState;
+ host_funcs_.poppopupsenabledstate = NPN_PopPopupsEnabledState;
+ host_funcs_.enumerate = WebBindings::enumerate;
+ host_funcs_.pluginthreadasynccall = NPN_PluginThreadAsyncCall;
+ host_funcs_.construct = WebBindings::construct;
}
@@ -677,7 +679,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) {
// described here:
// <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess>
if (np_object) {
- NPN_RetainObject(np_object);
+ WebBindings::retainObject(np_object);
void **v = (void **)value;
*v = np_object;
rv = NPERR_NO_ERROR;
@@ -694,7 +696,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) {
// described here:
// <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess>
if (np_object) {
- NPN_RetainObject(np_object);
+ WebBindings::retainObject(np_object);
void **v = (void **)value;
*v = np_object;
rv = NPERR_NO_ERROR;