LCOV - code coverage report
Current view: directory - dom/ipc - TabChild.h (source / functions) Found Hit Coverage
Test: app.info Lines: 20 1 5.0 %
Date: 2012-06-02 Functions: 18 1 5.6 %

       1                 : /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */
       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) 2009
      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 mozilla_dom_TabChild_h
      40                 : #define mozilla_dom_TabChild_h
      41                 : 
      42                 : #ifndef _IMPL_NS_LAYOUT
      43                 : #include "mozilla/dom/PBrowserChild.h"
      44                 : #endif
      45                 : #include "nsIWebNavigation.h"
      46                 : #include "nsCOMPtr.h"
      47                 : #include "nsAutoPtr.h"
      48                 : #include "nsIWebBrowserChrome2.h"
      49                 : #include "nsIEmbeddingSiteWindow2.h"
      50                 : #include "nsIWebBrowserChromeFocus.h"
      51                 : #include "nsIWidget.h"
      52                 : #include "nsIDOMEventListener.h"
      53                 : #include "nsIDOMEventTarget.h"
      54                 : #include "nsIInterfaceRequestor.h"
      55                 : #include "nsIWindowProvider.h"
      56                 : #include "nsIXPCScriptable.h"
      57                 : #include "nsIClassInfo.h"
      58                 : #include "jsapi.h"
      59                 : #include "nsIXPConnect.h"
      60                 : #include "nsIDOMWindow.h"
      61                 : #include "nsIDocShell.h"
      62                 : #include "nsIDocShellTreeItem.h"
      63                 : #include "nsIDocShellTreeOwner.h"
      64                 : #include "nsIDocument.h"
      65                 : #include "nsNetUtil.h"
      66                 : #include "nsFrameMessageManager.h"
      67                 : #include "nsIScriptContext.h"
      68                 : #include "nsDOMEventTargetHelper.h"
      69                 : #include "nsIDialogCreator.h"
      70                 : #include "nsIDialogParamBlock.h"
      71                 : #include "nsIPresShell.h"
      72                 : #include "nsIPrincipal.h"
      73                 : #include "nsIScriptObjectPrincipal.h"
      74                 : #include "nsIScriptContext.h"
      75                 : #include "nsWeakReference.h"
      76                 : #include "nsITabChild.h"
      77                 : 
      78                 : struct gfxMatrix;
      79                 : 
      80                 : namespace mozilla {
      81                 : namespace layout {
      82                 : class RenderFrameChild;
      83                 : }
      84                 : 
      85                 : namespace dom {
      86                 : 
      87                 : class TabChild;
      88                 : class PContentDialogChild;
      89                 : 
      90                 : class TabChildGlobal : public nsDOMEventTargetHelper,
      91                 :                        public nsIContentFrameMessageManager,
      92                 :                        public nsIScriptObjectPrincipal,
      93                 :                        public nsIScriptContextPrincipal
      94               0 : {
      95                 : public:
      96                 :   TabChildGlobal(TabChild* aTabChild);
      97                 :   NS_DECL_ISUPPORTS_INHERITED
      98            1464 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, nsDOMEventTargetHelper)
      99               0 :   NS_FORWARD_SAFE_NSIFRAMEMESSAGEMANAGER(mMessageManager)
     100               0 :   NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
     101                 :                              const jsval& aObject,
     102                 :                              JSContext* aCx,
     103                 :                              PRUint8 aArgc,
     104                 :                              jsval* aRetval)
     105                 :   {
     106                 :     return mMessageManager
     107               0 :       ? mMessageManager->SendSyncMessage(aMessageName, aObject, aCx, aArgc, aRetval)
     108               0 :       : NS_ERROR_NULL_POINTER;
     109                 :   }
     110                 :   NS_IMETHOD GetContent(nsIDOMWindow** aContent);
     111                 :   NS_IMETHOD GetDocShell(nsIDocShell** aDocShell);
     112               0 :   NS_IMETHOD Dump(const nsAString& aStr)
     113                 :   {
     114               0 :     return mMessageManager ? mMessageManager->Dump(aStr) : NS_OK;
     115                 :   }
     116                 :   NS_IMETHOD PrivateNoteIntentionalCrash();
     117                 :   NS_IMETHOD Btoa(const nsAString& aBinaryData,
     118                 :                   nsAString& aAsciiBase64String);
     119                 :   NS_IMETHOD Atob(const nsAString& aAsciiString,
     120                 :                   nsAString& aBinaryData);
     121                 : 
     122               0 :   NS_IMETHOD AddEventListener(const nsAString& aType,
     123                 :                               nsIDOMEventListener* aListener,
     124                 :                               bool aUseCapture)
     125                 :   {
     126                 :     // By default add listeners only for trusted events!
     127                 :     return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
     128               0 :                                                     aUseCapture, false, 2);
     129                 :   }
     130               0 :   NS_IMETHOD AddEventListener(const nsAString& aType,
     131                 :                               nsIDOMEventListener* aListener,
     132                 :                               bool aUseCapture, bool aWantsUntrusted,
     133                 :                               PRUint8 optional_argc)
     134                 :   {
     135                 :     return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
     136                 :                                                     aUseCapture,
     137                 :                                                     aWantsUntrusted,
     138               0 :                                                     optional_argc);
     139                 :   }
     140                 : 
     141               0 :   virtual nsIScriptObjectPrincipal* GetObjectPrincipal() { return this; }
     142                 :   virtual JSContext* GetJSContextForEventHandlers();
     143                 :   virtual nsIPrincipal* GetPrincipal();
     144                 : 
     145                 :   nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
     146                 :   TabChild* mTabChild;
     147                 : };
     148                 : 
     149                 : class ContentListener : public nsIDOMEventListener
     150                 : {
     151                 : public:
     152               0 :   ContentListener(TabChild* aTabChild) : mTabChild(aTabChild) {}
     153                 :   NS_DECL_ISUPPORTS
     154                 :   NS_DECL_NSIDOMEVENTLISTENER
     155                 : protected:
     156                 :   TabChild* mTabChild;
     157                 : };
     158                 : 
     159                 : class TabChild : public PBrowserChild,
     160                 :                  public nsFrameScriptExecutor,
     161                 :                  public nsIWebBrowserChrome2,
     162                 :                  public nsIEmbeddingSiteWindow2,
     163                 :                  public nsIWebBrowserChromeFocus,
     164                 :                  public nsIInterfaceRequestor,
     165                 :                  public nsIWindowProvider,
     166                 :                  public nsSupportsWeakReference,
     167                 :                  public nsIDialogCreator,
     168                 :                  public nsITabChild
     169                 : {
     170                 :     typedef mozilla::layout::RenderFrameChild RenderFrameChild;
     171                 : 
     172                 : public:
     173                 :     TabChild(PRUint32 aChromeFlags);
     174                 :     virtual ~TabChild();
     175                 :     nsresult Init();
     176                 : 
     177                 :     NS_DECL_ISUPPORTS
     178                 :     NS_DECL_NSIWEBBROWSERCHROME
     179                 :     NS_DECL_NSIWEBBROWSERCHROME2
     180                 :     NS_DECL_NSIEMBEDDINGSITEWINDOW
     181                 :     NS_DECL_NSIEMBEDDINGSITEWINDOW2
     182                 :     NS_DECL_NSIWEBBROWSERCHROMEFOCUS
     183                 :     NS_DECL_NSIINTERFACEREQUESTOR
     184                 :     NS_DECL_NSIWINDOWPROVIDER
     185                 :     NS_DECL_NSIDIALOGCREATOR
     186                 : 
     187                 :     virtual bool RecvLoadURL(const nsCString& uri);
     188                 :     virtual bool RecvShow(const nsIntSize& size);
     189                 :     virtual bool RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size);
     190                 :     virtual bool RecvActivate();
     191                 :     virtual bool RecvDeactivate();
     192                 :     virtual bool RecvMouseEvent(const nsString& aType,
     193                 :                                 const float&    aX,
     194                 :                                 const float&    aY,
     195                 :                                 const PRInt32&  aButton,
     196                 :                                 const PRInt32&  aClickCount,
     197                 :                                 const PRInt32&  aModifiers,
     198                 :                                 const bool&     aIgnoreRootScrollFrame);
     199                 :     virtual bool RecvRealMouseEvent(const nsMouseEvent& event);
     200                 :     virtual bool RecvRealKeyEvent(const nsKeyEvent& event);
     201                 :     virtual bool RecvMouseScrollEvent(const nsMouseScrollEvent& event);
     202                 :     virtual bool RecvKeyEvent(const nsString& aType,
     203                 :                               const PRInt32&  aKeyCode,
     204                 :                               const PRInt32&  aCharCode,
     205                 :                               const PRInt32&  aModifiers,
     206                 :                               const bool&     aPreventDefault);
     207                 :     virtual bool RecvCompositionEvent(const nsCompositionEvent& event);
     208                 :     virtual bool RecvTextEvent(const nsTextEvent& event);
     209                 :     virtual bool RecvSelectionEvent(const nsSelectionEvent& event);
     210                 :     virtual bool RecvActivateFrameEvent(const nsString& aType, const bool& capture);
     211                 :     virtual bool RecvLoadRemoteScript(const nsString& aURL);
     212                 :     virtual bool RecvAsyncMessage(const nsString& aMessage,
     213                 :                                   const nsString& aJSON);
     214                 : 
     215                 :     virtual PDocumentRendererChild*
     216                 :     AllocPDocumentRenderer(const nsRect& documentRect, const gfxMatrix& transform,
     217                 :                            const nsString& bgcolor,
     218                 :                            const PRUint32& renderFlags, const bool& flushLayout,
     219                 :                            const nsIntSize& renderSize);
     220                 :     virtual bool DeallocPDocumentRenderer(PDocumentRendererChild* actor);
     221                 :     virtual bool RecvPDocumentRendererConstructor(PDocumentRendererChild* actor,
     222                 :                                                   const nsRect& documentRect,
     223                 :                                                   const gfxMatrix& transform,
     224                 :                                                   const nsString& bgcolor,
     225                 :                                                   const PRUint32& renderFlags,
     226                 :                                                   const bool& flushLayout,
     227                 :                                                   const nsIntSize& renderSize);
     228                 : 
     229                 :     virtual PContentDialogChild* AllocPContentDialog(const PRUint32&,
     230                 :                                                      const nsCString&,
     231                 :                                                      const nsCString&,
     232                 :                                                      const InfallibleTArray<int>&,
     233                 :                                                      const InfallibleTArray<nsString>&);
     234                 :     virtual bool DeallocPContentDialog(PContentDialogChild* aDialog);
     235                 :     static void ParamsToArrays(nsIDialogParamBlock* aParams,
     236                 :                                InfallibleTArray<int>& aIntParams,
     237                 :                                InfallibleTArray<nsString>& aStringParams);
     238                 :     static void ArraysToParams(const InfallibleTArray<int>& aIntParams,
     239                 :                                const InfallibleTArray<nsString>& aStringParams,
     240                 :                                nsIDialogParamBlock* aParams);
     241                 : 
     242                 :     virtual PContentPermissionRequestChild* AllocPContentPermissionRequest(const nsCString& aType, const IPC::URI& uri);
     243                 :     virtual bool DeallocPContentPermissionRequest(PContentPermissionRequestChild* actor);
     244                 : 
     245                 :     virtual POfflineCacheUpdateChild* AllocPOfflineCacheUpdate(const URI& manifestURI,
     246                 :             const URI& documentURI,
     247                 :             const nsCString& clientID,
     248                 :             const bool& stickDocument);
     249                 :     virtual bool DeallocPOfflineCacheUpdate(POfflineCacheUpdateChild* offlineCacheUpdate);
     250                 : 
     251               0 :     nsIWebNavigation* WebNavigation() { return mWebNav; }
     252                 : 
     253               0 :     JSContext* GetJSContext() { return mCx; }
     254                 : 
     255               0 :     nsIPrincipal* GetPrincipal() { return mPrincipal; }
     256                 : 
     257                 :     void SetBackgroundColor(const nscolor& aColor);
     258                 : protected:
     259                 :     NS_OVERRIDE
     260                 :     virtual PRenderFrameChild* AllocPRenderFrame();
     261                 :     NS_OVERRIDE
     262                 :     virtual bool DeallocPRenderFrame(PRenderFrameChild* aFrame);
     263                 :     NS_OVERRIDE
     264                 :     virtual bool RecvDestroy();
     265                 : 
     266                 :     bool DispatchWidgetEvent(nsGUIEvent& event);
     267                 : 
     268                 : private:
     269                 :     void ActorDestroy(ActorDestroyReason why);
     270                 : 
     271                 :     bool InitTabChildGlobal();
     272                 :     bool InitWidget(const nsIntSize& size);
     273                 :     void DestroyWindow();
     274                 : 
     275                 :     nsCOMPtr<nsIWebNavigation> mWebNav;
     276                 :     nsCOMPtr<nsIWidget> mWidget;
     277                 :     RenderFrameChild* mRemoteFrame;
     278                 :     nsRefPtr<TabChildGlobal> mTabChildGlobal;
     279                 :     PRUint32 mChromeFlags;
     280                 :     nsIntRect mOuterRect;
     281                 :     nscolor mLastBackgroundColor;
     282                 : 
     283                 :     DISALLOW_EVIL_CONSTRUCTORS(TabChild);
     284                 : };
     285                 : 
     286                 : inline TabChild*
     287               0 : GetTabChildFrom(nsIDocShell* aDocShell)
     288                 : {
     289               0 :     nsCOMPtr<nsITabChild> tc = do_GetInterface(aDocShell);
     290               0 :     return static_cast<TabChild*>(tc.get());
     291                 : }
     292                 : 
     293                 : inline TabChild*
     294                 : GetTabChildFrom(nsIPresShell* aPresShell)
     295                 : {
     296                 :     nsIDocument* doc = aPresShell->GetDocument();
     297                 :     if (!doc) {
     298                 :         return nsnull;
     299                 :     }
     300                 :     nsCOMPtr<nsISupports> container = doc->GetContainer();
     301                 :     nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
     302                 :     return GetTabChildFrom(docShell);
     303                 : }
     304                 : 
     305                 : inline TabChild*
     306                 : GetTabChildFrom(nsIDOMWindow* aWindow)
     307                 : {
     308                 :     nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
     309                 :     nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
     310                 :     return GetTabChildFrom(docShell);
     311                 : }
     312                 : 
     313                 : }
     314                 : }
     315                 : 
     316                 : #endif // mozilla_dom_TabChild_h

Generated by: LCOV version 1.7