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

@@ -54,7 +54,6 @@
#include "nsNPAPIPluginStreamListener.h"
#include "nsIServiceManager.h"
#include "nsThreadUtils.h"
#include "nsIPrivateBrowsingService.h"
#include "mozilla/Preferences.h"
#include "nsIPluginStreamListener.h"
@@ -105,6 +104,8 @@
#include "nsJSNPRuntime.h"
#include "nsIHttpAuthManager.h"
#include "nsICookieService.h"
#include "nsILoadContext.h"
#include "nsIDocShell.h"
#include "nsNetUtil.h"
@@ -2135,11 +2136,12 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
}
case NPNVprivateModeBool: {
nsCOMPtr<nsIPrivateBrowsingService> pbs = do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
if (pbs) {
bool enabled;
pbs->GetPrivateBrowsingEnabled(&enabled);
*(NPBool*)result = (NPBool)enabled;
nsCOMPtr<nsIDocument> doc = GetDocumentFromNPP(npp);
nsCOMPtr<nsPIDOMWindow> domwindow = do_QueryInterface(doc);
if (domwindow) {
nsCOMPtr<nsIDocShell> docShell = domwindow->GetDocShell();
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
*(NPBool*)result = (NPBool)(loadContext && loadContext->UsePrivateBrowsing());
return NPERR_NO_ERROR;
}
return NPERR_GENERIC_ERROR;