NPObject* PluginControllerProxy::windowScriptNPObject() { if (!m_windowNPObject) return 0; retainNPObject(m_windowNPObject); return m_windowNPObject; }
NPObjectMessageReceiver::NPObjectMessageReceiver(NPRemoteObjectMap* npRemoteObjectMap, Plugin* plugin, uint64_t npObjectID, NPObject* npObject) : m_npRemoteObjectMap(npRemoteObjectMap) , m_plugin(plugin) , m_npObjectID(npObjectID) , m_npObject(npObject) { retainNPObject(m_npObject); }
void JSNPObject::finishCreation(JSGlobalObject* globalObject) { Base::finishCreation(globalObject->globalData()); ASSERT(inherits(&s_info)); // We should never have an NPJSObject inside a JSNPObject. ASSERT(!NPJSObject::isNPJSObject(m_npObject)); retainNPObject(m_npObject); }
JSNPObject::JSNPObject(JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject) : JSObjectWithGlobalObject(globalObject, createStructure(globalObject->objectPrototype())) , m_objectMap(objectMap) , m_npObject(npObject) { // We should never have an NPJSObject inside a JSNPObject. ASSERT(!NPJSObject::isNPJSObject(m_npObject)); retainNPObject(m_npObject); }
NPVariant NPRemoteObjectMap::npVariantDataToNPVariant(const NPVariantData& npVariantData, Plugin* plugin) { NPVariant npVariant; switch (npVariantData.type()) { case NPVariantData::Void: VOID_TO_NPVARIANT(npVariant); break; case NPVariantData::Null: NULL_TO_NPVARIANT(npVariant); break; case NPVariantData::Bool: BOOLEAN_TO_NPVARIANT(npVariantData.boolValue(), npVariant); break; case NPVariantData::Int32: INT32_TO_NPVARIANT(npVariantData.int32Value(), npVariant); break; case NPVariantData::Double: DOUBLE_TO_NPVARIANT(npVariantData.doubleValue(), npVariant); break; case NPVariantData::String: { NPString npString = createNPString(npVariantData.stringValue()); STRINGN_TO_NPVARIANT(npString.UTF8Characters, npString.UTF8Length, npVariant); break; } case NPVariantData::LocalNPObjectID: { uint64_t npObjectID = npVariantData.localNPObjectIDValue(); ASSERT(npObjectID); NPObjectMessageReceiver* npObjectMessageReceiver = m_registeredNPObjects.get(npObjectID); if (!npObjectMessageReceiver) { ASSERT_NOT_REACHED(); VOID_TO_NPVARIANT(npVariant); break; } NPObject* npObject = npObjectMessageReceiver->npObject(); ASSERT(npObject); retainNPObject(npObject); OBJECT_TO_NPVARIANT(npObject, npVariant); break; } case NPVariantData::RemoteNPObjectID: { NPObject* npObjectProxy = createNPObjectProxy(npVariantData.remoteNPObjectIDValue(), plugin); OBJECT_TO_NPVARIANT(npObjectProxy, npVariant); break; } } return npVariant; }
NPObject* NPRuntimeObjectMap::getOrCreateNPObject(VM& vm, JSObject* jsObject) { // If this is a JSNPObject, we can just get its underlying NPObject. if (jsObject->classInfo() == JSNPObject::info()) { JSNPObject* jsNPObject = jsCast<JSNPObject*>(jsObject); NPObject* npObject = jsNPObject->npObject(); retainNPObject(npObject); return npObject; } // First, check if we already know about this object. if (NPJSObject* npJSObject = m_npJSObjects.get(jsObject)) { retainNPObject(npJSObject); return npJSObject; } NPJSObject* npJSObject = NPJSObject::create(vm, this, jsObject); m_npJSObjects.set(jsObject, npJSObject); return npJSObject; }
NPObject* NetscapePlugin::pluginScriptableNPObject() { ASSERT(m_isStarted); NPObject* scriptableNPObject = 0; if (NPP_GetValue(NPPVpluginScriptableNPObject, &scriptableNPObject) != NPERR_NO_ERROR) return 0; #if PLUGIN_ARCHITECTURE(MAC) if (m_pluginModule->pluginQuirks().contains(PluginQuirks::ReturnsNonRetainedScriptableNPObject)) retainNPObject(scriptableNPObject); #endif return scriptableNPObject; }
NPObject* PluginControllerProxy::pluginElementNPObject() { if (!m_pluginElementNPObject) { uint64_t pluginElementNPObjectID = 0; if (!m_connection->connection()->sendSync(Messages::PluginProxy::GetPluginElementNPObject(), Messages::PluginProxy::GetPluginElementNPObject::Reply(pluginElementNPObjectID), m_pluginInstanceID)) return 0; if (!pluginElementNPObjectID) return 0; m_pluginElementNPObject = m_connection->npRemoteObjectMap()->createNPObjectProxy(pluginElementNPObjectID, m_plugin.get()); ASSERT(m_pluginElementNPObject); } retainNPObject(m_pluginElementNPObject); return m_pluginElementNPObject; }
NPVariantData NPRemoteObjectMap::npVariantToNPVariantData(const NPVariant& variant, Plugin* plugin) { switch (variant.type) { case NPVariantType_Void: return NPVariantData::makeVoid(); case NPVariantType_Null: return NPVariantData::makeNull(); case NPVariantType_Bool: return NPVariantData::makeBool(variant.value.boolValue); case NPVariantType_Int32: return NPVariantData::makeInt32(variant.value.intValue); case NPVariantType_Double: return NPVariantData::makeDouble(variant.value.doubleValue); case NPVariantType_String: return NPVariantData::makeString(variant.value.stringValue.UTF8Characters, variant.value.stringValue.UTF8Length); case NPVariantType_Object: { NPObject* npObject = variant.value.objectValue; if (NPObjectProxy::isNPObjectProxy(npObject)) { NPObjectProxy* npObjectProxy = NPObjectProxy::toNPObjectProxy(npObject); uint64_t npObjectID = npObjectProxy->npObjectID(); // FIXME: Under some circumstances, this might leak the NPObjectProxy object. // Figure out how to avoid that. retainNPObject(npObjectProxy); return NPVariantData::makeRemoteNPObjectID(npObjectID); } uint64_t npObjectID = registerNPObject(npObject, plugin); return NPVariantData::makeLocalNPObjectID(npObjectID); } } ASSERT_NOT_REACHED(); return NPVariantData::makeVoid(); }
static NPObject *NPN_RetainObject(NPObject *npObject) { retainNPObject(npObject); return npObject; }