// ============================== // ! Scriptability related code ! // ============================== // // here the plugin is asked by Mozilla to tell if it is scriptable // we should return a valid interface id and a pointer to // nsScriptablePeer interface which we should have implemented // and which should be defined in the corressponding *.xpt file // in the bin/components folder NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { if(instance == NULL) return NPERR_INVALID_INSTANCE_ERROR; NPError rv = NPERR_NO_ERROR; if(instance == NULL) return NPERR_GENERIC_ERROR; CPlugin * plugin = (CPlugin *)instance->pdata; if(plugin == NULL) return NPERR_GENERIC_ERROR; switch (variable) { case NPPVpluginNameString: *((char **)value) = PLUGIN_NAME; break; case NPPVpluginDescriptionString: *((char **)value) = PLUGIN_DESCRIPTION; break; case NPPVpluginScriptableNPObject: *(NPObject **)value = plugin->GetScriptableObject(); break; default: rv = NPERR_GENERIC_ERROR; } return rv; }
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { if(instance == NULL) return NPERR_INVALID_INSTANCE_ERROR; NPError rv = NPERR_NO_ERROR; if(instance == NULL) return NPERR_GENERIC_ERROR; CPlugin * plugin = (CPlugin *)instance->pdata; if(plugin == NULL) return NPERR_GENERIC_ERROR; switch (variable) { case NPPVpluginNameString: *((char **)value) = NPPVPLUGINNAMESTRING; break; case NPPVpluginDescriptionString: *((char **)value) = NPPVPLUGINDESCRIPTIONSTRING; break; // Here we indicate that the plugin is scriptable. See this page for details: // https://developer.mozilla.org/en/Gecko_Plugin_API_Reference/Scripting_plugins case NPPVpluginScriptableNPObject: *(NPObject **)value = plugin->GetScriptableObject(); break; default: rv = plugin->GetValue(variable, value); } return rv; }
NPObject *NPP_GetScriptableInstance(NPP instance) { if(!instance) return 0; NPObject *npobj = 0; CPlugin * pPlugin = (CPlugin *)instance->pdata; if (!pPlugin) npobj = pPlugin->GetScriptableObject(); return npobj; }
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { if(instance == NULL) { return NPERR_INVALID_INSTANCE_ERROR; } NPError rv = NPERR_NO_ERROR; if(instance == NULL) { return NPERR_GENERIC_ERROR; } CPlugin * plugin = (CPlugin *)instance->pdata; if(plugin == NULL) { return NPERR_GENERIC_ERROR; } switch (variable) { case NPPVpluginNameString: { *((char **)value) = "NPRuntimeTest"; break; } case NPPVpluginDescriptionString: { *((char **)value) = "NPRuntime scriptability API test plugin"; break; } case NPPVpluginScriptableNPObject: { *(NPObject **)value = plugin->GetScriptableObject(); break; } default: { rv = NPERR_GENERIC_ERROR; } } return rv; }
// ============================== // ! Scriptability related code ! // ============================== // // here the plugin is asked by Mozilla to tell if it is scriptable // we should return a valid interface id and a pointer to // nsScriptablePeer interface which we should have implemented // and which should be defined in the corressponding *.xpt file // in the bin/components folder NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { NPError rv = NPERR_NO_ERROR; if (variable == NPPVpluginScriptableNPObject) { if (instance == NULL) return NPERR_INVALID_INSTANCE_ERROR; CPlugin *plugin = (CPlugin *) instance->pdata; if (plugin == NULL) return NPERR_GENERIC_ERROR; *(NPObject **) value = plugin->GetScriptableObject(); } else { rv = PluginGetValue(variable, value); } return rv; }
// ============================== // ! Scriptability related code ! // ============================== // // here the plugin is asked by Mozilla to tell if it is scriptable // we should return a valid interface id and a pointer to // nsScriptablePeer interface which we should have implemented // and which should be defined in the corressponding *.xpt file // in the bin/components folder NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { if(instance == NULL) return NPERR_INVALID_INSTANCE_ERROR; NPError rv = NPERR_NO_ERROR; if(instance == NULL) return NPERR_GENERIC_ERROR; CPlugin * plugin = (CPlugin *)instance->pdata; if(plugin == NULL) return NPERR_GENERIC_ERROR; switch (variable) { case NPPVpluginWindowBool: *((PRBool *)value) = PR_TRUE; break; case NPPVpluginNameString: *((char **)value) = "Boilerplate Plugin"; break; case NPPVpluginDescriptionString: *((char **)value) = "Boilerplate web plugin"; break; case NPPVpluginScriptableNPObject: if (!plugin->isInitialized()) { return NPERR_GENERIC_ERROR; } *((NPObject **)value) = plugin->GetScriptableObject(); break; default: rv = NPERR_GENERIC_ERROR; break; } return rv; }