Bug 539755 - Implement NPN_GetValueForURL, NPN_SetValueForURL, and NPN_GetAuthenticationInfo, r=bent

This commit is contained in:
Benjamin Smedberg 2010-01-15 11:26:46 -05:00
parent 83a5e9f243
commit 8cf3963e32
5 changed files with 175 additions and 6 deletions

View File

@ -49,6 +49,7 @@ using NPError;
using NPRemoteWindow;
using NPRemoteEvent;
using NPRect;
using NPNURLVariable;
using mozilla::plugins::NativeWindowHandle;
namespace mozilla {
@ -126,6 +127,18 @@ parent:
rpc NPN_PopPopupsEnabledState()
returns (bool aSuccess);
rpc NPN_GetValueForURL(NPNURLVariable variable, nsCString url)
returns (nsCString value, NPError result);
rpc NPN_SetValueForURL(NPNURLVariable variable, nsCString url,
nsCString value)
returns (NPError result);
rpc NPN_GetAuthenticationInfo(nsCString protocol_, nsCString host,
int32_t port, nsCString scheme,
nsCString realm)
returns (nsCString username, nsCString password, NPError result);
both:
rpc PPluginScriptableObject();

View File

@ -747,6 +747,61 @@ PluginInstanceParent::AnswerNPN_PopPopupsEnabledState(bool* aSuccess)
return true;
}
bool
PluginInstanceParent::AnswerNPN_GetValueForURL(const NPNURLVariable& variable,
const nsCString& url,
nsCString* value,
NPError* result)
{
char* v;
uint32_t len;
*result = mNPNIface->getvalueforurl(mNPP, (NPNURLVariable) variable,
url.get(), &v, &len);
if (NPERR_NO_ERROR == *result)
value->Adopt(v, len);
return true;
}
bool
PluginInstanceParent::AnswerNPN_SetValueForURL(const NPNURLVariable& variable,
const nsCString& url,
const nsCString& value,
NPError* result)
{
*result = mNPNIface->setvalueforurl(mNPP, (NPNURLVariable) variable,
url.get(), value.get(),
value.Length());
return true;
}
bool
PluginInstanceParent::AnswerNPN_GetAuthenticationInfo(const nsCString& protocol,
const nsCString& host,
const int32_t& port,
const nsCString& scheme,
const nsCString& realm,
nsCString* username,
nsCString* password,
NPError* result)
{
char* u;
uint32_t ulen;
char* p;
uint32_t plen;
*result = mNPNIface->getauthenticationinfo(mNPP, protocol.get(),
host.get(), port,
scheme.get(), realm.get(),
&u, &ulen, &p, &plen);
if (NPERR_NO_ERROR == result) {
username->Adopt(u, ulen);
password->Adopt(p, plen);
}
return true;
}
#if defined(OS_WIN)
/* windowless drawing helpers */

View File

@ -161,6 +161,26 @@ public:
virtual bool
AnswerNPN_PopPopupsEnabledState(bool* aSuccess);
NS_OVERRIDE virtual bool
AnswerNPN_GetValueForURL(const NPNURLVariable& variable,
const nsCString& url,
nsCString* value, NPError* result);
NS_OVERRIDE virtual bool
AnswerNPN_SetValueForURL(const NPNURLVariable& variable,
const nsCString& url,
const nsCString& value, NPError* result);
NS_OVERRIDE virtual bool
AnswerNPN_GetAuthenticationInfo(const nsCString& protocol,
const nsCString& host,
const int32_t& port,
const nsCString& scheme,
const nsCString& realm,
nsCString* username,
nsCString* password,
NPError* result);
NPError NPP_SetWindow(const NPWindow* aWindow);
NPError NPP_GetValue(NPPVariable variable, void *ret_value);

View File

@ -616,6 +616,31 @@ struct ParamTraits<NPNVariable>
}
};
template<>
struct ParamTraits<NPNURLVariable>
{
typedef NPNURLVariable paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, int(aParam));
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
int intval;
if (ReadParam(aMsg, aIter, &intval)) {
switch (intval) {
case NPNURLVCookie:
case NPNURLVProxy:
*aResult = paramType(intval);
return true;
}
}
return false;
}
};
} /* namespace IPC */

View File

@ -1295,8 +1295,28 @@ _getvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
{
PLUGIN_LOG_DEBUG_FUNCTION;
AssertPluginThread();
NS_NOTYETIMPLEMENTED("Implement me!");
return NPERR_GENERIC_ERROR;
if (!url)
return NPERR_INVALID_URL;
if (!npp || !value || !len)
return NPERR_INVALID_PARAM;
switch (variable) {
case NPNURLVCookie:
case NPNURLVProxy:
nsCString v;
NPError result;
InstCast(npp)->
CallNPN_GetValueForURL(variable, nsCString(url), &v, &result);
if (NPERR_NO_ERROR == result) {
*value = ToNewCString(v);
*len = v.Length();
}
return result;
}
return NPERR_INVALID_PARAM;
}
NPError NP_CALLBACK
@ -1305,8 +1325,24 @@ _setvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
{
PLUGIN_LOG_DEBUG_FUNCTION;
AssertPluginThread();
NS_NOTYETIMPLEMENTED("Implement me!");
return NPERR_GENERIC_ERROR;
if (!value)
return NPERR_INVALID_PARAM;
if (!url)
return NPERR_INVALID_URL;
switch (variable) {
case NPNURLVCookie:
case NPNURLVProxy:
NPError result;
InstCast(npp)->CallNPN_SetValueForURL(variable, nsCString(url),
nsDependentCString(value, len),
&result);
return result;
}
return NPERR_INVALID_PARAM;
}
NPError NP_CALLBACK
@ -1318,8 +1354,28 @@ _getauthenticationinfo(NPP npp, const char *protocol,
{
PLUGIN_LOG_DEBUG_FUNCTION;
AssertPluginThread();
NS_NOTYETIMPLEMENTED("Implement me!");
return NPERR_GENERIC_ERROR;
if (!protocol || !host || !scheme || !realm || !username || !ulen ||
!password || !plen)
return NPERR_INVALID_PARAM;
nsCString u;
nsCString p;
NPError result;
InstCast(npp)->
CallNPN_GetAuthenticationInfo(nsDependentCString(protocol),
nsDependentCString(host),
port,
nsDependentCString(scheme),
nsDependentCString(realm),
&u, &p, &result);
if (NPERR_NO_ERROR == result) {
*username = ToNewCString(u);
*ulen = u.Length();
*password = ToNewCString(p);
*plen = p.Length();
}
return result;
}
uint32_t NP_CALLBACK