From ae40e6243010b7049525f02b3d6d6f6497d1a70c Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Tue, 25 Aug 2009 10:45:50 +0000 Subject: browser-plugin: add methods for calling browser wrapper functions --- 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 (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; -- cgit v0.9.1