Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTommi Komulainen <tko@litl.com>2009-08-25 10:45:50 (GMT)
committer Marco Pesenti Gritti <marcopg@litl.com>2010-07-27 22:04:22 (GMT)
commitae40e6243010b7049525f02b3d6d6f6497d1a70c (patch)
treea8dab4ec14f013e9a3513e1023290018ec6b33a8
parent4ca63208acd85880d873b2e59e6ce42df33f874c (diff)
browser-plugin: add methods for calling browser wrapper functions
-rw-r--r--browser-plugin/plugin.cpp9
-rw-r--r--browser-plugin/plugin.h2
-rw-r--r--browser-plugin/scriptable.cpp16
-rw-r--r--browser-plugin/scriptable.h2
4 files changed, 29 insertions, 0 deletions
diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp
index db1f4f5..978f9c0 100644
--- a/browser-plugin/plugin.cpp
+++ b/browser-plugin/plugin.cpp
@@ -161,6 +161,15 @@ Plugin::GetScriptableNPObject ()
}
void
+Plugin::CallBrowser(const char *function_name)
+{
+ ScriptablePluginObject *obj = static_cast<ScriptablePluginObject*> (mScriptableObject);
+ if (obj) {
+ obj->CallBrowser (function_name);
+ }
+}
+
+void
Plugin::UpdateSizingMode ()
{
EvSizingMode sizingMode;
diff --git a/browser-plugin/plugin.h b/browser-plugin/plugin.h
index 58fbc96..95c53ef 100644
--- a/browser-plugin/plugin.h
+++ b/browser-plugin/plugin.h
@@ -44,6 +44,8 @@ class Plugin {
void UpdateSizingMode ();
void ClearLoadJob ();
+ void CallBrowser (const char *function_name);
+
static void SizingModeCallback (EvView *view,
GParamSpec *pspec,
gpointer data);
diff --git a/browser-plugin/scriptable.cpp b/browser-plugin/scriptable.cpp
index 0be9736..ff4f064 100644
--- a/browser-plugin/scriptable.cpp
+++ b/browser-plugin/scriptable.cpp
@@ -293,6 +293,22 @@ ScriptablePluginObject::SetProperty (NPIdentifier name, const NPVariant *value)
return false;
}
+void
+ScriptablePluginObject::CallBrowser (const char *function_name)
+{
+ if (!mMagicWrapper) {
+ return;
+ }
+
+ NPVariant rval;
+
+ if (NPERR_NO_ERROR == NPN_Invoke (mNpp, mMagicWrapper,
+ NPN_GetStringIdentifier (function_name),
+ NULL, 0, &rval)) {
+ NPN_ReleaseVariantValue (&rval);
+ }
+}
+
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 4a96b77..79a9519 100644
--- a/browser-plugin/scriptable.h
+++ b/browser-plugin/scriptable.h
@@ -89,6 +89,8 @@ class ScriptablePluginObject : public ScriptablePluginObjectBase
virtual bool InvokeDefault (const NPVariant *args, uint32_t argCount,
NPVariant *result);
+ virtual void CallBrowser (const char *function_name);
+
private:
NPIdentifier mTitleID;
NPIdentifier mMagicWrapperID;