Bug 508167 - NPAPI additions for clearing recent history (e.g. for "flash cookies"). r=josh, a=beltzner

This commit is contained in:
Dan Witte
2011-02-08 14:16:07 -08:00
parent f75dfa4f18
commit 787ac1bb42
21 changed files with 820 additions and 19 deletions

View File

@@ -109,6 +109,8 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
: mSubprocess(new PluginProcessParent(aFilePath))
, mPluginThread(0)
, mShutdown(false)
, mClearSiteDataSupported(false)
, mGetSitesWithDataSupported(false)
, mNPNIface(NULL)
, mPlugin(NULL)
, mProcessStartTime(time(NULL))
@@ -383,7 +385,11 @@ PluginModuleParent::SetPluginFuncs(NPPluginFuncs* aFuncs)
aFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
aFuncs->javaClass = nsnull;
aFuncs->newp = nsnull; // Gecko should always call this through a PluginLibrary object
// Gecko should always call these functions through a PluginLibrary object.
aFuncs->newp = NULL;
aFuncs->clearsitedata = NULL;
aFuncs->getsiteswithdata = NULL;
aFuncs->destroy = NPP_Destroy;
aFuncs->setwindow = NPP_SetWindow;
aFuncs->newstream = NPP_NewStream;
@@ -400,9 +406,12 @@ PluginModuleParent::SetPluginFuncs(NPPluginFuncs* aFuncs)
aFuncs->lostfocus = NULL;
aFuncs->urlredirectnotify = NULL;
// Provide 'NPP_URLRedirectNotify' if it is supported by the plugin.
// Provide 'NPP_URLRedirectNotify', 'NPP_ClearSiteData', and
// 'NPP_GetSitesWithData' functionality if it is supported by the plugin.
bool urlRedirectSupported = false;
CallURLRedirectNotifySupported(&urlRedirectSupported);
unused << CallOptionalFunctionsSupported(&urlRedirectSupported,
&mClearSiteDataSupported,
&mGetSitesWithDataSupported);
if (urlRedirectSupported) {
aFuncs->urlredirectnotify = NPP_URLRedirectNotify;
}
@@ -835,6 +844,41 @@ PluginModuleParent::NPP_New(NPMIMEType pluginType, NPP instance,
return NS_OK;
}
nsresult
PluginModuleParent::NPP_ClearSiteData(const char* site, uint64_t flags,
uint64_t maxAge)
{
if (!mClearSiteDataSupported)
return NS_ERROR_NOT_AVAILABLE;
NPError result;
if (!CallNPP_ClearSiteData(NullableString(site), flags, maxAge, &result))
return NS_ERROR_FAILURE;
switch (result) {
case NPERR_NO_ERROR:
return NS_OK;
case NPERR_TIME_RANGE_NOT_SUPPORTED:
return NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED;
case NPERR_MALFORMED_SITE:
return NS_ERROR_INVALID_ARG;
default:
return NS_ERROR_FAILURE;
}
}
nsresult
PluginModuleParent::NPP_GetSitesWithData(InfallibleTArray<nsCString>& result)
{
if (!mGetSitesWithDataSupported)
return NS_ERROR_NOT_AVAILABLE;
if (!CallNPP_GetSitesWithData(&result))
return NS_ERROR_FAILURE;
return NS_OK;
}
bool
PluginModuleParent::AnswerNPN_GetValue_WithBoolReturn(const NPNVariable& aVariable,
NPError* aError,