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
Родитель aa292c441a
Коммит 72052090c1
5 изменённых файлов: 175 добавлений и 6 удалений

Просмотреть файл

@ -49,6 +49,7 @@ using NPError;
using NPRemoteWindow; using NPRemoteWindow;
using NPRemoteEvent; using NPRemoteEvent;
using NPRect; using NPRect;
using NPNURLVariable;
using mozilla::plugins::NativeWindowHandle; using mozilla::plugins::NativeWindowHandle;
namespace mozilla { namespace mozilla {
@ -126,6 +127,18 @@ parent:
rpc NPN_PopPopupsEnabledState() rpc NPN_PopPopupsEnabledState()
returns (bool aSuccess); 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: both:
rpc PPluginScriptableObject(); rpc PPluginScriptableObject();

Просмотреть файл

@ -747,6 +747,61 @@ PluginInstanceParent::AnswerNPN_PopPopupsEnabledState(bool* aSuccess)
return true; 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) #if defined(OS_WIN)
/* windowless drawing helpers */ /* windowless drawing helpers */

Просмотреть файл

@ -161,6 +161,26 @@ public:
virtual bool virtual bool
AnswerNPN_PopPopupsEnabledState(bool* aSuccess); 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_SetWindow(const NPWindow* aWindow);
NPError NPP_GetValue(NPPVariable variable, void *ret_value); NPError NPP_GetValue(NPPVariable variable, void *ret_value);

Просмотреть файл

@ -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 */ } /* namespace IPC */

Просмотреть файл

@ -1295,8 +1295,28 @@ _getvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
{ {
PLUGIN_LOG_DEBUG_FUNCTION; PLUGIN_LOG_DEBUG_FUNCTION;
AssertPluginThread(); 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 NPError NP_CALLBACK
@ -1305,8 +1325,24 @@ _setvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
{ {
PLUGIN_LOG_DEBUG_FUNCTION; PLUGIN_LOG_DEBUG_FUNCTION;
AssertPluginThread(); 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 NPError NP_CALLBACK
@ -1318,8 +1354,28 @@ _getauthenticationinfo(NPP npp, const char *protocol,
{ {
PLUGIN_LOG_DEBUG_FUNCTION; PLUGIN_LOG_DEBUG_FUNCTION;
AssertPluginThread(); 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 uint32_t NP_CALLBACK