Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/browser-plugin/scriptable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'browser-plugin/scriptable.cpp')
-rw-r--r--browser-plugin/scriptable.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/browser-plugin/scriptable.cpp b/browser-plugin/scriptable.cpp
index d0c2854..2669cac 100644
--- a/browser-plugin/scriptable.cpp
+++ b/browser-plugin/scriptable.cpp
@@ -21,6 +21,7 @@
#include <scriptable.h>
#include "plugin.h"
+#include <string.h>
void
ScriptablePluginObjectBase::Invalidate ()
@@ -194,6 +195,8 @@ AllocateScriptablePluginObject (NPP npp, NPClass *aClass)
ScriptablePluginObject::ScriptablePluginObject (NPP npp) :
ScriptablePluginObjectBase (npp)
{
+ mTitleID = NPN_GetStringIdentifier ("title");
+
mZoomInID = NPN_GetStringIdentifier ("zoomIn");
mZoomOutID = NPN_GetStringIdentifier ("zoomOut");
mFindPreviousID = NPN_GetStringIdentifier ("findPrevious");
@@ -222,12 +225,36 @@ ScriptablePluginObject::HasMethod (NPIdentifier name)
bool
ScriptablePluginObject::HasProperty (NPIdentifier name)
{
+ NPIdentifier properties[] = {
+ mTitleID
+ };
+
+ for (guint i = 0; i < G_N_ELEMENTS(properties); i++) {
+ if (name == properties[i]) {
+ return true;
+ }
+ }
+
return false;
}
bool
ScriptablePluginObject::GetProperty (NPIdentifier name, NPVariant *result)
{
+ Plugin *plugin = reinterpret_cast<Plugin*> (mNpp->pdata);
+
+ if (name == mTitleID) {
+ if (plugin->mTitle) {
+ // STRINGZ_TO_NPVARIANT evaluates its argument twice..
+ char *np_string = NPN_StrDup (plugin->mTitle);
+ STRINGZ_TO_NPVARIANT (np_string, *result);
+ } else {
+ NULL_TO_NPVARIANT (*result);
+ }
+
+ return true;
+ }
+
return false;
}