embedding/components/windowwatcher/src/nsWindowWatcher.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef __nsWindowWatcher_h__
     7 #define __nsWindowWatcher_h__
     9 // {a21bfa01-f349-4394-a84c-8de5cf0737d0}
    10 #define NS_WINDOWWATCHER_CID \
    11  {0xa21bfa01, 0xf349, 0x4394, {0xa8, 0x4c, 0x8d, 0xe5, 0xcf, 0x7, 0x37, 0xd0}}
    13 #include "nsCOMPtr.h"
    14 #include "mozilla/Mutex.h"
    15 #include "nsIWindowCreator.h" // for stupid compilers
    16 #include "nsIWindowWatcher.h"
    17 #include "nsIPromptFactory.h"
    18 #include "nsPIWindowWatcher.h"
    19 #include "nsTArray.h"
    20 #include "js/TypeDecls.h"
    22 class  nsIURI;
    23 class  nsIDocShellTreeItem;
    24 class  nsIDocShellTreeOwner;
    25 class  nsIWebBrowserChrome;
    26 class  nsString;
    27 class  nsWatcherWindowEnumerator;
    28 class  nsIScriptContext;
    29 class  nsPromptService;
    30 struct nsWatcherWindowEntry;
    31 struct SizeSpec;
    33 class nsWindowWatcher :
    34       public nsIWindowWatcher,
    35       public nsPIWindowWatcher,
    36       public nsIPromptFactory
    37 {
    38 friend class nsWatcherWindowEnumerator;
    40 public:
    41   nsWindowWatcher();
    42   virtual ~nsWindowWatcher();
    44   nsresult Init();
    46   NS_DECL_ISUPPORTS
    48   NS_DECL_NSIWINDOWWATCHER
    49   NS_DECL_NSPIWINDOWWATCHER
    50   NS_DECL_NSIPROMPTFACTORY
    52 protected:
    53   friend class nsPromptService;
    54   bool AddEnumerator(nsWatcherWindowEnumerator* inEnumerator);
    55   bool RemoveEnumerator(nsWatcherWindowEnumerator* inEnumerator);
    57   nsWatcherWindowEntry *FindWindowEntry(nsIDOMWindow *aWindow);
    58   nsresult RemoveWindow(nsWatcherWindowEntry *inInfo);
    60   // Get the caller tree item.  Look on the JS stack, then fall back
    61   // to the parent if there's nothing there.
    62   already_AddRefed<nsIDocShellTreeItem>
    63     GetCallerTreeItem(nsIDocShellTreeItem* aParentItem);
    65   // Unlike GetWindowByName this will look for a caller on the JS
    66   // stack, and then fall back on aCurrentWindow if it can't find one.
    67   already_AddRefed<nsIDOMWindow>
    68     SafeGetWindowByName(const nsAString& aName, nsIDOMWindow* aCurrentWindow);
    70   // Just like OpenWindowJS, but knows whether it got called via OpenWindowJS
    71   // (which means called from script) or called via OpenWindow.
    72   nsresult OpenWindowInternal(nsIDOMWindow *aParent,
    73                               const char *aUrl,
    74                               const char *aName,
    75                               const char *aFeatures,
    76                               bool aCalledFromJS,
    77                               bool aDialog,
    78                               bool aNavigate,
    79                               nsIArray *argv,
    80                               nsIDOMWindow **_retval);
    82   static JSContext *GetJSContextFromWindow(nsIDOMWindow *aWindow);
    83   static nsresult   URIfromURL(const char *aURL,
    84                                nsIDOMWindow *aParent,
    85                                nsIURI **aURI);
    87   static uint32_t   CalculateChromeFlags(nsIDOMWindow *aParent,
    88                                          const char *aFeatures,
    89                                          bool aFeaturesSpecified,
    90                                          bool aDialog,
    91                                          bool aChromeURL,
    92                                          bool aHasChromeParent);
    93   static int32_t    WinHasOption(const char *aOptions, const char *aName,
    94                                  int32_t aDefault, bool *aPresenceFlag);
    95   /* Compute the right SizeSpec based on aFeatures */
    96   static void       CalcSizeSpec(const char* aFeatures, SizeSpec& aResult);
    97   static nsresult   ReadyOpenedDocShellItem(nsIDocShellTreeItem *aOpenedItem,
    98                                             nsIDOMWindow *aParent,
    99                                             bool aWindowIsNew,
   100                                             nsIDOMWindow **aOpenedWindow);
   101   static void       SizeOpenedDocShellItem(nsIDocShellTreeItem *aDocShellItem,
   102                                            nsIDOMWindow *aParent,
   103                                            const SizeSpec & aSizeSpec);
   104   static void       GetWindowTreeItem(nsIDOMWindow *inWindow,
   105                                       nsIDocShellTreeItem **outTreeItem);
   106   static void       GetWindowTreeOwner(nsIDOMWindow *inWindow,
   107                                        nsIDocShellTreeOwner **outTreeOwner);
   109   nsTArray<nsWatcherWindowEnumerator*> mEnumeratorList;
   110   nsWatcherWindowEntry *mOldestWindow;
   111   mozilla::Mutex        mListLock;
   113   nsCOMPtr<nsIWindowCreator> mWindowCreator;
   114 };
   116 #endif

mercurial