LCOV - code coverage report
Current view: directory - content/base/src - nsInProcessTabChildGlobal.h (source / functions) Found Hit Coverage
Test: app.info Lines: 20 1 5.0 %
Date: 2012-06-02 Functions: 16 1 6.2 %

       1                 : /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */
       2                 : /* vim: set sw=4 ts=8 et tw=80 : */
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Mozilla Content App.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  *   The Mozilla Foundation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef nsInProcessTabChildGlobal_h
      40                 : #define nsInProcessTabChildGlobal_h
      41                 : 
      42                 : #include "nsCOMPtr.h"
      43                 : #include "nsFrameMessageManager.h"
      44                 : #include "nsIScriptContext.h"
      45                 : #include "nsDOMEventTargetHelper.h"
      46                 : #include "nsIScriptObjectPrincipal.h"
      47                 : #include "nsIScriptContext.h"
      48                 : #include "nsIClassInfo.h"
      49                 : #include "jsapi.h"
      50                 : #include "nsIDocShell.h"
      51                 : #include "nsIDOMElement.h"
      52                 : #include "nsCOMArray.h"
      53                 : #include "nsThreadUtils.h"
      54                 : 
      55                 : class nsInProcessTabChildGlobal : public nsDOMEventTargetHelper,
      56                 :                                   public nsFrameScriptExecutor,
      57                 :                                   public nsIInProcessContentFrameMessageManager,
      58                 :                                   public nsIScriptObjectPrincipal,
      59                 :                                   public nsIScriptContextPrincipal
      60                 : {
      61                 : public:
      62                 :   nsInProcessTabChildGlobal(nsIDocShell* aShell, nsIContent* aOwner,
      63                 :                             nsFrameMessageManager* aChrome);
      64                 :   virtual ~nsInProcessTabChildGlobal();
      65                 :   NS_DECL_ISUPPORTS_INHERITED
      66            1464 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsInProcessTabChildGlobal,
      67                 :                                            nsDOMEventTargetHelper)
      68               0 :   NS_FORWARD_SAFE_NSIFRAMEMESSAGEMANAGER(mMessageManager)
      69               0 :   NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
      70                 :                              const jsval& aObject,
      71                 :                              JSContext* aCx,
      72                 :                              PRUint8 aArgc,
      73                 :                              jsval* aRetval)
      74                 :   {
      75                 :     return mMessageManager
      76               0 :       ? mMessageManager->SendSyncMessage(aMessageName, aObject, aCx, aArgc, aRetval)
      77               0 :       : NS_ERROR_NULL_POINTER;
      78                 :   }
      79                 :   NS_IMETHOD GetContent(nsIDOMWindow** aContent);
      80                 :   NS_IMETHOD GetDocShell(nsIDocShell** aDocShell);
      81               0 :   NS_IMETHOD Dump(const nsAString& aStr)
      82                 :   {
      83               0 :     return mMessageManager ? mMessageManager->Dump(aStr) : NS_OK;
      84                 :   }
      85                 :   NS_IMETHOD PrivateNoteIntentionalCrash();
      86                 :   NS_IMETHOD Btoa(const nsAString& aBinaryData,
      87                 :                   nsAString& aAsciiBase64String);
      88                 :   NS_IMETHOD Atob(const nsAString& aAsciiString,
      89                 :                   nsAString& aBinaryData);
      90                 : 
      91                 :   NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER
      92                 : 
      93                 :   virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
      94               0 :   NS_IMETHOD AddEventListener(const nsAString& aType,
      95                 :                               nsIDOMEventListener* aListener,
      96                 :                               bool aUseCapture)
      97                 :   {
      98                 :     // By default add listeners only for trusted events!
      99                 :     return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
     100               0 :                                                     aUseCapture, false, 2);
     101                 :   }
     102               0 :   NS_IMETHOD AddEventListener(const nsAString& aType,
     103                 :                               nsIDOMEventListener* aListener,
     104                 :                               bool aUseCapture, bool aWantsUntrusted,
     105                 :                               PRUint8 optional_argc)
     106                 :   {
     107                 :     return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
     108                 :                                                     aUseCapture,
     109                 :                                                     aWantsUntrusted,
     110               0 :                                                     optional_argc);
     111                 :   }
     112                 : 
     113               0 :   virtual nsIScriptObjectPrincipal* GetObjectPrincipal() { return this; }
     114               0 :   virtual JSContext* GetJSContextForEventHandlers() { return mCx; }
     115               0 :   virtual nsIPrincipal* GetPrincipal() { return mPrincipal; }
     116                 :   void LoadFrameScript(const nsAString& aURL);
     117                 :   void Disconnect();
     118                 :   void SendMessageToParent(const nsString& aMessage, bool aSync,
     119                 :                            const nsString& aJSON,
     120                 :                            nsTArray<nsString>* aJSONRetVal);
     121               0 :   nsFrameMessageManager* GetInnerManager()
     122                 :   {
     123               0 :     return static_cast<nsFrameMessageManager*>(mMessageManager.get());
     124                 :   }
     125                 : 
     126               0 :   void SetOwner(nsIContent* aOwner) { mOwner = aOwner; }
     127                 :   nsFrameMessageManager* GetChromeMessageManager()
     128                 :   {
     129                 :     return mChromeMessageManager;
     130                 :   }
     131               0 :   void SetChromeMessageManager(nsFrameMessageManager* aParent)
     132                 :   {
     133               0 :     mChromeMessageManager = aParent;
     134               0 :   }
     135                 : 
     136                 :   void DelayedDisconnect();
     137                 : protected:
     138                 :   nsresult Init();
     139                 :   nsresult InitTabChildGlobal();
     140                 :   nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
     141                 :   nsCOMPtr<nsIDocShell> mDocShell;
     142                 :   bool mInitialized;
     143                 :   bool mLoadingScript;
     144                 :   bool mDelayedDisconnect;
     145                 : public:
     146                 :   nsIContent* mOwner;
     147                 :   nsFrameMessageManager* mChromeMessageManager;
     148                 :   nsTArray<nsCOMPtr<nsIRunnable> > mASyncMessages;
     149                 : };
     150                 : 
     151                 : #endif

Generated by: LCOV version 1.7