Bug 722942 - Obtain private browsing status from document of plugin owner, and watch private mode transitions on a per-instance basis. r=josh

This commit is contained in:
Josh Matthews
2012-04-24 00:49:25 -04:00
parent 4d2fd7525e
commit c62994d83a
6 changed files with 46 additions and 37 deletions

View File

@@ -48,7 +48,6 @@
#include "nsPluginHost.h"
#include "nsPluginSafety.h"
#include "nsPluginLogging.h"
#include "nsIPrivateBrowsingService.h"
#include "nsContentUtils.h"
#include "nsIDocument.h"
@@ -152,7 +151,7 @@ nsresult nsNPAPIPluginInstance::Initialize(nsNPAPIPlugin *aPlugin, nsIPluginInst
PL_strcpy(mMIMEType, aMIMEType);
}
}
return Start();
}
@@ -1143,7 +1142,7 @@ nsNPAPIPluginInstance::GetPluginAPIVersion(PRUint16* version)
}
nsresult
nsNPAPIPluginInstance::PrivateModeStateChanged()
nsNPAPIPluginInstance::PrivateModeStateChanged(bool enabled)
{
if (RUNNING != mRunning)
return NS_OK;
@@ -1155,23 +1154,15 @@ nsNPAPIPluginInstance::PrivateModeStateChanged()
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
if (pluginFunctions->setvalue) {
PluginDestructionGuard guard(this);
nsCOMPtr<nsIPrivateBrowsingService> pbs = do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
if (pbs) {
bool pme = false;
nsresult rv = pbs->GetPrivateBrowsingEnabled(&pme);
if (NS_FAILED(rv))
return rv;
if (!pluginFunctions->setvalue)
return NS_ERROR_FAILURE;
NPError error;
NPBool value = static_cast<NPBool>(pme);
NS_TRY_SAFE_CALL_RETURN(error, (*pluginFunctions->setvalue)(&mNPP, NPNVprivateModeBool, &value), this);
return (error == NPERR_NO_ERROR) ? NS_OK : NS_ERROR_FAILURE;
}
}
return NS_ERROR_FAILURE;
PluginDestructionGuard guard(this);
NPError error;
NPBool value = static_cast<NPBool>(enabled);
NS_TRY_SAFE_CALL_RETURN(error, (*pluginFunctions->setvalue)(&mNPP, NPNVprivateModeBool, &value), this);
return (error == NPERR_NO_ERROR) ? NS_OK : NS_ERROR_FAILURE;
}
class DelayUnscheduleEvent : public nsRunnable {