LCOV - code coverage report
Current view: top level - dom/base - nsInProcessTabChildGlobal.h (source / functions) Hit Total Coverage
Test: output.info Lines: 7 29 24.1 %
Date: 2017-07-14 16:53:18 Functions: 7 24 29.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef nsInProcessTabChildGlobal_h
       8             : #define nsInProcessTabChildGlobal_h
       9             : 
      10             : #include "mozilla/Attributes.h"
      11             : #include "mozilla/DOMEventTargetHelper.h"
      12             : #include "nsCOMPtr.h"
      13             : #include "nsFrameMessageManager.h"
      14             : #include "nsIScriptContext.h"
      15             : #include "nsIScriptObjectPrincipal.h"
      16             : #include "nsIScriptContext.h"
      17             : #include "nsIClassInfo.h"
      18             : #include "nsIDocShell.h"
      19             : #include "nsIDOMElement.h"
      20             : #include "nsCOMArray.h"
      21             : #include "nsIRunnable.h"
      22             : #include "nsIGlobalObject.h"
      23             : #include "nsIScriptObjectPrincipal.h"
      24             : #include "nsWeakReference.h"
      25             : 
      26             : namespace mozilla {
      27             : class EventChainPreVisitor;
      28             : } // namespace mozilla
      29             : 
      30             : class nsInProcessTabChildGlobal : public mozilla::DOMEventTargetHelper,
      31             :                                   public nsMessageManagerScriptExecutor,
      32             :                                   public nsIInProcessContentFrameMessageManager,
      33             :                                   public nsIGlobalObject,
      34             :                                   public nsIScriptObjectPrincipal,
      35             :                                   public nsSupportsWeakReference,
      36             :                                   public mozilla::dom::ipc::MessageManagerCallback
      37             : {
      38             :   typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
      39             : 
      40             :   using mozilla::dom::ipc::MessageManagerCallback::GetProcessMessageManager;
      41             : 
      42             : public:
      43             :   nsInProcessTabChildGlobal(nsIDocShell* aShell, nsIContent* aOwner,
      44             :                             nsFrameMessageManager* aChrome);
      45             :   NS_DECL_ISUPPORTS_INHERITED
      46           7 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsInProcessTabChildGlobal,
      47             :                                                          mozilla::DOMEventTargetHelper)
      48             : 
      49          29 :   NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
      50           0 :   NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
      51           0 :   NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(mMessageManager)
      52           0 :   NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
      53             :                              JS::Handle<JS::Value> aObject,
      54             :                              JS::Handle<JS::Value> aRemote,
      55             :                              nsIPrincipal* aPrincipal,
      56             :                              JSContext* aCx,
      57             :                              uint8_t aArgc,
      58             :                              JS::MutableHandle<JS::Value> aRetval) override
      59             :   {
      60             :     return mMessageManager
      61           0 :       ? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote,
      62           0 :                                          aPrincipal, aCx, aArgc, aRetval)
      63           0 :       : NS_ERROR_NULL_POINTER;
      64             :   }
      65           0 :   NS_IMETHOD SendRpcMessage(const nsAString& aMessageName,
      66             :                             JS::Handle<JS::Value> aObject,
      67             :                             JS::Handle<JS::Value> aRemote,
      68             :                             nsIPrincipal* aPrincipal,
      69             :                             JSContext* aCx,
      70             :                             uint8_t aArgc,
      71             :                             JS::MutableHandle<JS::Value> aRetval) override
      72             :   {
      73             :     return mMessageManager
      74           0 :       ? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote,
      75           0 :                                         aPrincipal, aCx, aArgc, aRetval)
      76           0 :       : NS_ERROR_NULL_POINTER;
      77             :   }
      78             :   NS_IMETHOD GetContent(mozIDOMWindowProxy** aContent) override;
      79             :   NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) override;
      80             : 
      81             :   NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER
      82             : 
      83             :   /**
      84             :    * MessageManagerCallback methods that we override.
      85             :    */
      86             :   virtual bool DoSendBlockingMessage(JSContext* aCx,
      87             :                                       const nsAString& aMessage,
      88             :                                       StructuredCloneData& aData,
      89             :                                       JS::Handle<JSObject *> aCpows,
      90             :                                       nsIPrincipal* aPrincipal,
      91             :                                       nsTArray<StructuredCloneData>* aRetVal,
      92             :                                       bool aIsSync) override;
      93             :   virtual nsresult DoSendAsyncMessage(JSContext* aCx,
      94             :                                       const nsAString& aMessage,
      95             :                                       StructuredCloneData& aData,
      96             :                                       JS::Handle<JSObject *> aCpows,
      97             :                                       nsIPrincipal* aPrincipal) override;
      98             : 
      99             :   virtual nsresult GetEventTargetParent(
     100             :                      mozilla::EventChainPreVisitor& aVisitor) override;
     101           0 :   NS_IMETHOD AddEventListener(const nsAString& aType,
     102             :                               nsIDOMEventListener* aListener,
     103             :                               bool aUseCapture)
     104             :   {
     105             :     // By default add listeners only for trusted events!
     106           0 :     return mozilla::DOMEventTargetHelper::AddEventListener(aType, aListener,
     107             :                                                            aUseCapture, false,
     108           0 :                                                            2);
     109             :   }
     110          26 :   NS_IMETHOD AddEventListener(const nsAString& aType,
     111             :                               nsIDOMEventListener* aListener,
     112             :                               bool aUseCapture, bool aWantsUntrusted,
     113             :                               uint8_t optional_argc) override
     114             :   {
     115          26 :     return mozilla::DOMEventTargetHelper::AddEventListener(aType, aListener,
     116             :                                                            aUseCapture,
     117             :                                                            aWantsUntrusted,
     118          26 :                                                            optional_argc);
     119             :   }
     120             :   using mozilla::DOMEventTargetHelper::AddEventListener;
     121             : 
     122           0 :   virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
     123             :   void LoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope);
     124             :   void FireUnloadEvent();
     125             :   void DisconnectEventListeners();
     126             :   void Disconnect();
     127             :   void SendMessageToParent(const nsString& aMessage, bool aSync,
     128             :                            const nsString& aJSON,
     129             :                            nsTArray<nsString>* aJSONRetVal);
     130           0 :   nsFrameMessageManager* GetInnerManager()
     131             :   {
     132           0 :     return static_cast<nsFrameMessageManager*>(mMessageManager.get());
     133             :   }
     134             : 
     135           0 :   void SetOwner(nsIContent* aOwner) { mOwner = aOwner; }
     136             :   nsFrameMessageManager* GetChromeMessageManager()
     137             :   {
     138             :     return mChromeMessageManager;
     139             :   }
     140           0 :   void SetChromeMessageManager(nsFrameMessageManager* aParent)
     141             :   {
     142           0 :     mChromeMessageManager = aParent;
     143           0 :   }
     144             : 
     145         542 :   virtual JSObject* GetGlobalJSObject() override {
     146         542 :     return mGlobal;
     147             :   }
     148           0 :   virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
     149             :   {
     150           0 :     MOZ_CRASH("nsInProcessTabChildGlobal doesn't use DOM bindings!");
     151             :   }
     152             : 
     153             :   already_AddRefed<nsIFrameLoader> GetFrameLoader();
     154             : 
     155             : protected:
     156             :   virtual ~nsInProcessTabChildGlobal();
     157             : 
     158             :   nsresult Init();
     159             :   nsresult InitTabChildGlobal();
     160             :   nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
     161             :   nsCOMPtr<nsIDocShell> mDocShell;
     162             :   bool mInitialized;
     163             :   bool mLoadingScript;
     164             : 
     165             :   // Is this the message manager for an in-process <iframe mozbrowser>? This
     166             :   // affects where events get sent, so it affects GetEventTargetParent.
     167             :   bool mIsBrowserFrame;
     168             :   bool mPreventEventsEscaping;
     169             : 
     170             :   // We keep a strong reference to the frameloader after we've started
     171             :   // teardown. This allows us to dispatch message manager messages during this
     172             :   // time.
     173             :   nsCOMPtr<nsIFrameLoader> mFrameLoader;
     174             : public:
     175             :   nsIContent* mOwner;
     176             :   nsFrameMessageManager* mChromeMessageManager;
     177             : };
     178             : 
     179             : #endif

Generated by: LCOV version 1.13