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; }
/** * Clears the HTTP authentication password database. */ void HttpAuthDatabase::ClearHttpAuthUsernamePassword() { if (!WaitForInit()) { return; } mDatabase->Delete(HTTPAUTH_TABLE_NAME, NULL, NULL); }
NPError PluginAsyncSurrogate::NPP_SetValue(NPNVariable aVariable, void* aValue) { if (!WaitForInit()) { return NPERR_GENERIC_ERROR; } return PluginModuleParent::NPP_SetValue(mInstance, aVariable, aValue); }
NPError PluginAsyncSurrogate::NPP_Destroy(NPSavedData** aSave) { if (!WaitForInit()) { return NPERR_GENERIC_ERROR; } return PluginModuleParent::NPP_Destroy(mInstance, aSave); }
/** * Retrieves the HTTP authentication username and password for a given host and realm pair. If * there are multiple username/password combinations for a host/realm, only the first one will * be returned. * * @param host the host the password applies to * @param realm the realm the password applies to * @return a String[] if found where String[0] is username (which can be null) and * String[1] is password. Null is returned if it can't find anything. */ AutoPtr< ArrayOf<String> > HttpAuthDatabase::GetHttpAuthUsernamePassword( /* [in] */ String host, /* [in] */ String realm) { if (host == NULL || realm == NULL || !WaitForInit()) { return NULL; } AutoPtr< ArrayOf<String> > columns = ArrayOf<String> >::Alloc(2); (*columns)[0] = HTTPAUTH_USERNAME_COL; (*columns)[1] = HTTPAUTH_PASSWORD_COL; String selection("("); selection += HTTPAUTH_HOST_COL; selection += " == ?) AND "; selection += "("; selection += HTTPAUTH_REALM_COL; selection += " == ?)"; AutoPtr< ArrayOf<String> > ret; AutoPtr<ICursor> cursor; // try { AutoPtr< ArrayOf<String> > hostRealm = ArrayOf<String>::Alloc(2); (*hostRealm)[0] = host; (*hostRealm)[1] = realm; mDatabase->Query(HTTPAUTH_TABLE_NAME, columns, selection, hostRealm, NULL, NULL, NULL, (ICursor**)&cursor); Boolean bMoveToFirst = FALSE; cursor->MoveToFirst(&bMoveToFirst); if (bMoveToFirst) { ret = ArrayOf<String>::Alloc(2); String str1, str2; Int32 index1, index2; cursor->GetColumnIndex(HTTPAUTH_USERNAME_COL, &index1); cursor->GetString(index1, &str1); cursor->GetColumnIndex(HTTPAUTH_USERNAME_COL, &index2); cursor->GetString(index2, &str2); (*ret)[0] = str1; (*ret)[1] = str2; } // } catch (IllegalStateException e) { // Log.e(LOGTAG, "getHttpAuthUsernamePassword", e); // } finally { // if (cursor != null) cursor.close(); // } return ret; }
/** * Sets the HTTP authentication password. Tuple (HTTPAUTH_HOST_COL, HTTPAUTH_REALM_COL, * HTTPAUTH_USERNAME_COL) is unique. * * @param host the host for the password * @param realm the realm for the password * @param username the username for the password. * @param password the password */ void HttpAuthDatabase::SetHttpAuthUsernamePassword( /* [in] */ String host, /* [in] */ String realm, /* [in] */ String username, /* [in] */ String password) { if (host == NULL || realm == NULL || !WaitForInit()) { return; } AutoPtr<IContentValues> c; CContentValues()::New((IContentValues**)&c); c->Put(HTTPAUTH_HOST_COL, host); c->Put(HTTPAUTH_REALM_COL, realm); c->Put(HTTPAUTH_USERNAME_COL, username); c->Put(HTTPAUTH_PASSWORD_COL, password); mDatabase->Insert(HTTPAUTH_TABLE_NAME, HTTPAUTH_HOST_COL, c); }
/** * Determines if there are any HTTP authentication passwords saved. * * @return true if there are passwords saved */ Boolean HttpAuthDatabase::HasHttpAuthUsernamePassword() { if (!WaitForInit()) { return FALSE; } AutoPtr<ICursor> cursor; Boolean ret = FALSE; // try { mDatabase->Query(HTTPAUTH_TABLE_NAME, ID_PROJECTION, NULL, NULL, NULL, NULL, NULL, (ICursor**)&cursor); cursor->MoveToFirst(&ret); // } catch (IllegalStateException e) { // Log.e(LOGTAG, "hasEntries", e); // } finally { // if (cursor != null) cursor.close(); // } return ret; }
NPError PluginAsyncSurrogate::NPP_GetValue(NPPVariable aVariable, void* aRetval) { if (aVariable != NPPVpluginScriptableNPObject) { if (!WaitForInit()) { return NPERR_GENERIC_ERROR; } PluginInstanceParent* instance = PluginInstanceParent::Cast(mInstance); MOZ_ASSERT(instance); return instance->NPP_GetValue(aVariable, aRetval); } NPObject* npobject = parent::_createobject(mInstance, const_cast<NPClass*>(GetClass())); MOZ_ASSERT(npobject); MOZ_ASSERT(npobject->_class == GetClass()); MOZ_ASSERT(npobject->referenceCount == 1); *(NPObject**)aRetval = npobject; return npobject ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR; }