Bug 937317 - Make TabChildGlobal implement nsIGlobalObject. r=bz

This commit is contained in:
Bobby Holley 2013-12-06 12:01:41 -08:00
parent d98938d032
commit 7bba051425
2 changed files with 15 additions and 2 deletions

View File

@ -2492,6 +2492,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TabChildGlobal)
NS_INTERFACE_MAP_ENTRY(nsISyncMessageSender)
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
@ -2556,10 +2557,20 @@ TabChildGlobal::GetJSContextForEventHandlers()
return nsContentUtils::GetSafeJSContext();
}
nsIPrincipal*
nsIPrincipal*
TabChildGlobal::GetPrincipal()
{
if (!mTabChild)
return nullptr;
return mTabChild->GetPrincipal();
}
JSObject*
TabChildGlobal::GetGlobalJSObject()
{
NS_ENSURE_TRUE(mTabChild, nullptr);
nsCOMPtr<nsIXPConnectJSObjectHolder> ref = mTabChild->GetGlobal();
NS_ENSURE_TRUE(ref, nullptr);
return ref->GetJSObject();
}

View File

@ -51,7 +51,8 @@ class ClonedMessageData;
class TabChildGlobal : public nsDOMEventTargetHelper,
public nsIContentFrameMessageManager,
public nsIScriptObjectPrincipal
public nsIScriptObjectPrincipal,
public nsIGlobalObject
{
public:
TabChildGlobal(TabChild* aTabChild);
@ -127,6 +128,7 @@ public:
virtual JSContext* GetJSContextForEventHandlers() MOZ_OVERRIDE;
virtual nsIPrincipal* GetPrincipal() MOZ_OVERRIDE;
virtual JSObject* GetGlobalJSObject() MOZ_OVERRIDE;
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
TabChild* mTabChild;