2010-05-18 05:28:37 -07:00
|
|
|
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */
|
|
|
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-05-18 05:28:37 -07:00
|
|
|
|
|
|
|
#ifndef nsInProcessTabChildGlobal_h
|
|
|
|
#define nsInProcessTabChildGlobal_h
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsFrameMessageManager.h"
|
|
|
|
#include "nsIScriptContext.h"
|
2012-02-07 18:53:33 -08:00
|
|
|
#include "nsDOMEventTargetHelper.h"
|
2010-05-18 05:28:37 -07:00
|
|
|
#include "nsIScriptObjectPrincipal.h"
|
|
|
|
#include "nsIScriptContext.h"
|
|
|
|
#include "nsIClassInfo.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
|
2012-02-07 18:53:33 -08:00
|
|
|
class nsInProcessTabChildGlobal : public nsDOMEventTargetHelper,
|
2010-08-10 10:18:26 -07:00
|
|
|
public nsFrameScriptExecutor,
|
2010-05-18 05:28:37 -07:00
|
|
|
public nsIInProcessContentFrameMessageManager,
|
|
|
|
public nsIScriptObjectPrincipal,
|
2012-09-27 22:43:12 -07:00
|
|
|
public nsIScriptContextPrincipal,
|
|
|
|
public mozilla::dom::ipc::MessageManagerCallback
|
2010-05-18 05:28:37 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsInProcessTabChildGlobal(nsIDocShell* aShell, nsIContent* aOwner,
|
|
|
|
nsFrameMessageManager* aChrome);
|
|
|
|
virtual ~nsInProcessTabChildGlobal();
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsInProcessTabChildGlobal,
|
2012-02-07 18:53:33 -08:00
|
|
|
nsDOMEventTargetHelper)
|
2012-08-27 07:13:02 -07:00
|
|
|
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
|
|
|
|
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
|
2011-10-01 09:14:36 -07:00
|
|
|
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
|
|
|
|
const jsval& aObject,
|
|
|
|
JSContext* aCx,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t aArgc,
|
2011-10-01 09:14:36 -07:00
|
|
|
jsval* aRetval)
|
2010-05-18 05:28:37 -07:00
|
|
|
{
|
2011-10-01 09:14:36 -07:00
|
|
|
return mMessageManager
|
|
|
|
? mMessageManager->SendSyncMessage(aMessageName, aObject, aCx, aArgc, aRetval)
|
|
|
|
: NS_ERROR_NULL_POINTER;
|
2010-05-18 05:28:37 -07:00
|
|
|
}
|
|
|
|
NS_IMETHOD GetContent(nsIDOMWindow** aContent);
|
|
|
|
NS_IMETHOD GetDocShell(nsIDocShell** aDocShell);
|
|
|
|
NS_IMETHOD Dump(const nsAString& aStr)
|
|
|
|
{
|
|
|
|
return mMessageManager ? mMessageManager->Dump(aStr) : NS_OK;
|
|
|
|
}
|
2010-11-24 05:58:21 -08:00
|
|
|
NS_IMETHOD PrivateNoteIntentionalCrash();
|
2011-06-25 02:52:00 -07:00
|
|
|
NS_IMETHOD Btoa(const nsAString& aBinaryData,
|
|
|
|
nsAString& aAsciiBase64String);
|
|
|
|
NS_IMETHOD Atob(const nsAString& aAsciiString,
|
|
|
|
nsAString& aBinaryData);
|
|
|
|
|
2010-05-18 05:28:37 -07:00
|
|
|
NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER
|
|
|
|
|
2012-09-27 22:43:12 -07:00
|
|
|
/**
|
|
|
|
* MessageManagerCallback methods that we override.
|
|
|
|
*/
|
|
|
|
virtual bool DoSendSyncMessage(const nsAString& aMessage,
|
|
|
|
const mozilla::dom::StructuredCloneData& aData,
|
|
|
|
InfallibleTArray<nsString>* aJSONRetVal);
|
|
|
|
virtual bool DoSendAsyncMessage(const nsAString& aMessage,
|
|
|
|
const mozilla::dom::StructuredCloneData& aData);
|
|
|
|
|
2010-05-18 05:28:37 -07:00
|
|
|
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
|
|
|
NS_IMETHOD AddEventListener(const nsAString& aType,
|
|
|
|
nsIDOMEventListener* aListener,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aUseCapture)
|
2010-05-18 05:28:37 -07:00
|
|
|
{
|
|
|
|
// By default add listeners only for trusted events!
|
|
|
|
return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
|
2011-10-17 07:59:28 -07:00
|
|
|
aUseCapture, false, 2);
|
2010-05-18 05:28:37 -07:00
|
|
|
}
|
|
|
|
NS_IMETHOD AddEventListener(const nsAString& aType,
|
|
|
|
nsIDOMEventListener* aListener,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aUseCapture, bool aWantsUntrusted,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t optional_argc)
|
2010-05-18 05:28:37 -07:00
|
|
|
{
|
|
|
|
return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
|
|
|
|
aUseCapture,
|
|
|
|
aWantsUntrusted,
|
|
|
|
optional_argc);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsIScriptObjectPrincipal* GetObjectPrincipal() { return this; }
|
|
|
|
virtual JSContext* GetJSContextForEventHandlers() { return mCx; }
|
|
|
|
virtual nsIPrincipal* GetPrincipal() { return mPrincipal; }
|
|
|
|
void LoadFrameScript(const nsAString& aURL);
|
|
|
|
void Disconnect();
|
2011-09-28 23:19:26 -07:00
|
|
|
void SendMessageToParent(const nsString& aMessage, bool aSync,
|
2010-05-18 05:28:37 -07:00
|
|
|
const nsString& aJSON,
|
|
|
|
nsTArray<nsString>* aJSONRetVal);
|
|
|
|
nsFrameMessageManager* GetInnerManager()
|
|
|
|
{
|
|
|
|
return static_cast<nsFrameMessageManager*>(mMessageManager.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetOwner(nsIContent* aOwner) { mOwner = aOwner; }
|
|
|
|
nsFrameMessageManager* GetChromeMessageManager()
|
|
|
|
{
|
|
|
|
return mChromeMessageManager;
|
|
|
|
}
|
|
|
|
void SetChromeMessageManager(nsFrameMessageManager* aParent)
|
|
|
|
{
|
|
|
|
mChromeMessageManager = aParent;
|
|
|
|
}
|
2010-08-12 09:47:22 -07:00
|
|
|
|
|
|
|
void DelayedDisconnect();
|
2010-05-18 05:28:37 -07:00
|
|
|
protected:
|
|
|
|
nsresult Init();
|
|
|
|
nsresult InitTabChildGlobal();
|
|
|
|
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
|
|
|
|
nsCOMPtr<nsIDocShell> mDocShell;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInitialized;
|
|
|
|
bool mLoadingScript;
|
|
|
|
bool mDelayedDisconnect;
|
2012-05-08 09:20:35 -07:00
|
|
|
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 10:32:37 -08:00
|
|
|
// Is this the message manager for an in-process <iframe mozbrowser> or
|
|
|
|
// <iframe mozapp>? This affects where events get sent, so it affects
|
|
|
|
// PreHandleEvent.
|
|
|
|
bool mIsBrowserOrAppFrame;
|
2010-05-18 05:28:37 -07:00
|
|
|
public:
|
|
|
|
nsIContent* mOwner;
|
|
|
|
nsFrameMessageManager* mChromeMessageManager;
|
2010-06-11 04:14:01 -07:00
|
|
|
nsTArray<nsCOMPtr<nsIRunnable> > mASyncMessages;
|
2010-05-18 05:28:37 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|