/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */ /* vim: set sw=4 ts=8 et tw=80 : */ /* 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/. */ #ifndef mozilla_dom_TabChild_h #define mozilla_dom_TabChild_h #ifndef _IMPL_NS_LAYOUT #include "mozilla/dom/PBrowserChild.h" #endif #ifdef DEBUG #include "PCOMContentPermissionRequestChild.h" #endif /* DEBUG */ #include "nsIWebNavigation.h" #include "nsCOMPtr.h" #include "nsAutoPtr.h" #include "nsIWebBrowserChrome2.h" #include "nsIEmbeddingSiteWindow.h" #include "nsIWebBrowserChromeFocus.h" #include "nsIWidget.h" #include "nsIDOMEventListener.h" #include "nsIDOMEventTarget.h" #include "nsIInterfaceRequestor.h" #include "nsIWindowProvider.h" #include "nsIXPCScriptable.h" #include "nsIClassInfo.h" #include "jsapi.h" #include "nsIXPConnect.h" #include "nsIDOMWindow.h" #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeOwner.h" #include "nsIDocument.h" #include "nsNetUtil.h" #include "nsFrameMessageManager.h" #include "nsIScriptContext.h" #include "nsDOMEventTargetHelper.h" #include "nsIDialogCreator.h" #include "nsIDialogParamBlock.h" #include "nsIPresShell.h" #include "nsIPrincipal.h" #include "nsIScriptObjectPrincipal.h" #include "nsIScriptContext.h" #include "nsPIDOMWindow.h" #include "nsWeakReference.h" #include "nsITabChild.h" #include "mozilla/Attributes.h" #include "FrameMetrics.h" struct gfxMatrix; namespace mozilla { namespace layout { class RenderFrameChild; } namespace dom { class TabChild; class PContentDialogChild; class ClonedMessageData; class TabChildGlobal : public nsDOMEventTargetHelper, public nsIContentFrameMessageManager, public nsIScriptObjectPrincipal, public nsIScriptContextPrincipal { public: TabChildGlobal(TabChild* aTabChild); void Init(); NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, nsDOMEventTargetHelper) NS_FORWARD_SAFE_NSIFRAMEMESSAGEMANAGER(mMessageManager) NS_IMETHOD SendSyncMessage(const nsAString& aMessageName, const jsval& aObject, JSContext* aCx, PRUint8 aArgc, jsval* aRetval) { return mMessageManager ? mMessageManager->SendSyncMessage(aMessageName, aObject, aCx, aArgc, aRetval) : NS_ERROR_NULL_POINTER; } NS_IMETHOD GetContent(nsIDOMWindow** aContent); NS_IMETHOD GetDocShell(nsIDocShell** aDocShell); NS_IMETHOD Dump(const nsAString& aStr) { return mMessageManager ? mMessageManager->Dump(aStr) : NS_OK; } NS_IMETHOD PrivateNoteIntentionalCrash(); NS_IMETHOD Btoa(const nsAString& aBinaryData, nsAString& aAsciiBase64String); NS_IMETHOD Atob(const nsAString& aAsciiString, nsAString& aBinaryData); NS_IMETHOD AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener, bool aUseCapture) { // By default add listeners only for trusted events! return nsDOMEventTargetHelper::AddEventListener(aType, aListener, aUseCapture, false, 2); } NS_IMETHOD AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener, bool aUseCapture, bool aWantsUntrusted, PRUint8 optional_argc) { return nsDOMEventTargetHelper::AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted, optional_argc); } virtual nsIScriptObjectPrincipal* GetObjectPrincipal() { return this; } virtual JSContext* GetJSContextForEventHandlers(); virtual nsIPrincipal* GetPrincipal(); nsCOMPtr mMessageManager; TabChild* mTabChild; }; class ContentListener MOZ_FINAL : public nsIDOMEventListener { public: ContentListener(TabChild* aTabChild) : mTabChild(aTabChild) {} NS_DECL_ISUPPORTS NS_DECL_NSIDOMEVENTLISTENER protected: TabChild* mTabChild; }; class TabChild : public PBrowserChild, public nsFrameScriptExecutor, public nsIWebBrowserChrome2, public nsIEmbeddingSiteWindow, public nsIWebBrowserChromeFocus, public nsIInterfaceRequestor, public nsIWindowProvider, public nsSupportsWeakReference, public nsIDialogCreator, public nsITabChild, public nsIObserver { typedef mozilla::layout::RenderFrameChild RenderFrameChild; typedef mozilla::dom::ClonedMessageData ClonedMessageData; public: /** * Create a new TabChild object. * * |aIsBrowserElement| indicates whether the tab is inside an