NPObjectProxy* NPObjectProxy::create(NPRemoteObjectMap* npRemoteObjectMap, Plugin* plugin, uint64_t npObjectID) { NPObjectProxy* npObjectProxy = toNPObjectProxy(createNPObject(0, npClass())); npObjectProxy->initialize(npRemoteObjectMap, plugin, npObjectID); return npObjectProxy; }
void NPRemoteObjectMap::pluginDestroyed(Plugin* plugin) { Vector<NPObjectMessageReceiver*> messageReceivers; // Gather the receivers associated with this plug-in. for (HashMap<uint64_t, NPObjectMessageReceiver*>::const_iterator it = m_registeredNPObjects.begin(), end = m_registeredNPObjects.end(); it != end; ++it) { NPObjectMessageReceiver* npObjectMessageReceiver = it->second; if (npObjectMessageReceiver->plugin() == plugin) messageReceivers.append(npObjectMessageReceiver); } // Now delete all the receivers. deleteAllValues(messageReceivers); Vector<NPObjectProxy*> objectProxies; for (HashSet<NPObjectProxy*>::const_iterator it = m_npObjectProxies.begin(), end = m_npObjectProxies.end(); it != end; ++it) { NPObjectProxy* npObjectProxy = *it; if (npObjectProxy->plugin() == plugin) objectProxies.append(npObjectProxy); } // Invalidate and remove all proxies associated with this plug-in. for (size_t i = 0; i < objectProxies.size(); ++i) { NPObjectProxy* npObjectProxy = objectProxies[i]; npObjectProxy->invalidate(); ASSERT(m_npObjectProxies.contains(npObjectProxy)); m_npObjectProxies.remove(npObjectProxy); } }
static uint64_t remoteNPObjectID(Plugin* plugin, NPObject* npObject) { if (!NPObjectProxy::isNPObjectProxy(npObject)) return 0; NPObjectProxy* npObjectProxy = NPObjectProxy::toNPObjectProxy(npObject); if (npObjectProxy->plugin() != plugin) return 0; return npObjectProxy->npObjectID(); }
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(); }