Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--browser-plugin/scriptable.cpp39
-rw-r--r--browser-plugin/scriptable.h4
2 files changed, 41 insertions, 2 deletions
diff --git a/browser-plugin/scriptable.cpp b/browser-plugin/scriptable.cpp
index 2669cac..0be9736 100644
--- a/browser-plugin/scriptable.cpp
+++ b/browser-plugin/scriptable.cpp
@@ -193,9 +193,11 @@ AllocateScriptablePluginObject (NPP npp, NPClass *aClass)
}
ScriptablePluginObject::ScriptablePluginObject (NPP npp) :
- ScriptablePluginObjectBase (npp)
+ ScriptablePluginObjectBase (npp),
+ mMagicWrapper(0)
{
mTitleID = NPN_GetStringIdentifier ("title");
+ mMagicWrapperID = NPN_GetStringIdentifier ("magicWrapper");
mZoomInID = NPN_GetStringIdentifier ("zoomIn");
mZoomOutID = NPN_GetStringIdentifier ("zoomOut");
@@ -226,7 +228,8 @@ bool
ScriptablePluginObject::HasProperty (NPIdentifier name)
{
NPIdentifier properties[] = {
- mTitleID
+ mTitleID,
+ mMagicWrapperID
};
for (guint i = 0; i < G_N_ELEMENTS(properties); i++) {
@@ -259,6 +262,38 @@ ScriptablePluginObject::GetProperty (NPIdentifier name, NPVariant *result)
}
bool
+ScriptablePluginObject::SetProperty (NPIdentifier name, const NPVariant *value)
+{
+ Plugin *plugin = reinterpret_cast<Plugin*> (mNpp->pdata);
+
+ if (name == mMagicWrapperID) {
+ NPObject *newWrapper = NULL;
+
+ if (NPVARIANT_IS_OBJECT (*value)) {
+ newWrapper = NPVARIANT_TO_OBJECT (*value);
+ } else if (NPVARIANT_IS_VOID (*value) ||
+ NPVARIANT_IS_NULL (*value)) {
+ // ok, newWrapper=NULL
+ } else {
+ NPN_SetException (this, "Invalid type for magicWrapper, expected object or null");
+ return false;
+ }
+
+ if (newWrapper) {
+ NPN_RetainObject (newWrapper);
+ }
+ if (mMagicWrapper) {
+ NPN_ReleaseObject (mMagicWrapper);
+ }
+ mMagicWrapper = newWrapper;
+
+ return true;
+ }
+
+ return false;
+}
+
+bool
ScriptablePluginObject::Invoke (NPIdentifier name, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
diff --git a/browser-plugin/scriptable.h b/browser-plugin/scriptable.h
index 0b9bf29..4a96b77 100644
--- a/browser-plugin/scriptable.h
+++ b/browser-plugin/scriptable.h
@@ -83,6 +83,7 @@ class ScriptablePluginObject : public ScriptablePluginObjectBase
virtual bool HasMethod (NPIdentifier name);
virtual bool HasProperty (NPIdentifier name);
virtual bool GetProperty (NPIdentifier name, NPVariant *result);
+ virtual bool SetProperty (NPIdentifier name, const NPVariant *value);
virtual bool Invoke (NPIdentifier name, const NPVariant *args,
uint32_t argCount, NPVariant *result);
virtual bool InvokeDefault (const NPVariant *args, uint32_t argCount,
@@ -90,11 +91,14 @@ class ScriptablePluginObject : public ScriptablePluginObjectBase
private:
NPIdentifier mTitleID;
+ NPIdentifier mMagicWrapperID;
NPIdentifier mZoomInID;
NPIdentifier mZoomOutID;
NPIdentifier mFindPreviousID;
NPIdentifier mFindNextID;
+
+ NPObject *mMagicWrapper;
};
class ConstructablePluginObject : public ScriptablePluginObjectBase