bool PluginAsyncSurrogate::GetPropertyHelper(NPObject* aObject, NPIdentifier aName, bool* aHasProperty, bool* aHasMethod, NPVariant* aResult) { PLUGIN_LOG_DEBUG_FUNCTION; if (!aObject) { return false; } RecursionGuard guard; if (guard.IsRecursive()) { return false; } if (!WaitForInit()) { return false; } AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject); NPObject* realObject = object->GetRealObject(); if (!realObject) { return false; } if (realObject->_class != PluginScriptableObjectParent::GetClass()) { NS_ERROR("Don't know what kind of object this is!"); return false; } PluginScriptableObjectParent* actor = static_cast<ParentNPObject*>(realObject)->parent; if (!actor) { return false; } bool success = actor->GetPropertyHelper(aName, aHasProperty, aHasMethod, aResult); if (!success) { const NPNetscapeFuncs* npn = mParent->GetNetscapeFuncs(); NPObject* pluginObject = nullptr; NPError nperror = npn->getvalue(mInstance, NPNVPluginElementNPObject, (void*)&pluginObject); if (nperror == NPERR_NO_ERROR) { NPPAutoPusher nppPusher(mInstance); bool hasProperty = nsJSObjWrapper::HasOwnProperty(pluginObject, aName); NPUTF8* idstr = npn->utf8fromidentifier(aName); npn->memfree(idstr); bool hasMethod = false; if (hasProperty) { hasMethod = pluginObject->_class->hasMethod(pluginObject, aName); success = pluginObject->_class->getProperty(pluginObject, aName, aResult); idstr = npn->utf8fromidentifier(aName); npn->memfree(idstr); } *aHasProperty = hasProperty; *aHasMethod = hasMethod; npn->releaseobject(pluginObject); } } return success; }
// static bool PluginAsyncSurrogate::ScriptableHasProperty(NPObject* aObject, NPIdentifier aName) { PLUGIN_LOG_DEBUG_FUNCTION; if (aObject->_class != GetClass()) { NS_ERROR("Don't know what kind of object this is!"); return false; } RecursionGuard guard; if (guard.IsRecursive()) { return false; } AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject); MOZ_ASSERT(object); bool checkPluginObject = !object->mSurrogate->mInstantiated && !object->mSurrogate->mAcceptCalls; if (!object->mSurrogate->WaitForInit()) { return false; } NPObject* realObject = object->GetRealObject(); if (!realObject) { return false; } bool result = realObject->_class->hasProperty(realObject, aName); const NPNetscapeFuncs* npn = object->mSurrogate->mParent->GetNetscapeFuncs(); NPUTF8* idstr = npn->utf8fromidentifier(aName); npn->memfree(idstr); if (!result && checkPluginObject) { // We may be calling into this object because properties in the WebIDL // object hadn't been set yet. Now that we're further along in // initialization, we should try again. NPObject* pluginObject = nullptr; NPError nperror = npn->getvalue(object->mSurrogate->mInstance, NPNVPluginElementNPObject, (void*)&pluginObject); if (nperror == NPERR_NO_ERROR) { NPPAutoPusher nppPusher(object->mSurrogate->mInstance); result = nsJSObjWrapper::HasOwnProperty(pluginObject, aName); npn->releaseobject(pluginObject); idstr = npn->utf8fromidentifier(aName); npn->memfree(idstr); } } return result; }