Bug 1029494 Part 5: Replace AutoPushJSContext in nsNPAPIPlugin _getpluginelement. r=bholley
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
#include "nsWildCard.h"
|
#include "nsWildCard.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsCxPusher.h"
|
#include "nsCxPusher.h"
|
||||||
|
#include "mozilla/dom/ScriptSettings.h"
|
||||||
|
|
||||||
#include "nsIXPConnect.h"
|
#include "nsIXPConnect.h"
|
||||||
|
|
||||||
@@ -643,27 +644,6 @@ GetDocumentFromNPP(NPP npp)
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSContext *
|
|
||||||
GetJSContextFromDoc(nsIDocument *doc)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(doc->GetWindow());
|
|
||||||
NS_ENSURE_TRUE(sgo, nullptr);
|
|
||||||
|
|
||||||
nsIScriptContext *scx = sgo->GetContext();
|
|
||||||
NS_ENSURE_TRUE(scx, nullptr);
|
|
||||||
|
|
||||||
return scx->GetNativeContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
static JSContext *
|
|
||||||
GetJSContextFromNPP(NPP npp)
|
|
||||||
{
|
|
||||||
nsIDocument *doc = GetDocumentFromNPP(npp);
|
|
||||||
NS_ENSURE_TRUE(doc, nullptr);
|
|
||||||
|
|
||||||
return GetJSContextFromDoc(doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static already_AddRefed<nsIChannel>
|
static already_AddRefed<nsIChannel>
|
||||||
GetChannelFromNPP(NPP npp)
|
GetChannelFromNPP(NPP npp)
|
||||||
{
|
{
|
||||||
@@ -1239,9 +1219,16 @@ _getpluginelement(NPP npp)
|
|||||||
if (!element)
|
if (!element)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
AutoPushJSContext cx(GetJSContextFromNPP(npp));
|
nsIDocument *doc = GetDocumentFromNPP(npp);
|
||||||
NS_ENSURE_TRUE(cx, nullptr);
|
if (NS_WARN_IF(!doc)) {
|
||||||
JSAutoRequest ar(cx); // Unnecessary once bug 868130 lands.
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
dom::AutoJSAPI jsapi;
|
||||||
|
if (NS_WARN_IF(!jsapi.Init(doc->GetInnerWindow()))) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
JSContext* cx = jsapi.cx();
|
||||||
|
|
||||||
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID()));
|
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID()));
|
||||||
NS_ENSURE_TRUE(xpc, nullptr);
|
NS_ENSURE_TRUE(xpc, nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user