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 nsWindowMediator_h_
7 #define nsWindowMediator_h_
10 #include "nsIWindowMediator.h"
11 #include "nsIObserver.h"
13 #include "nsPIDOMWindow.h"
15 #include "nsWeakReference.h"
16 #include "nsTObserverArray.h"
18 class nsAppShellWindowEnumerator
;
19 class nsASAppWindowEarlyToLateEnumerator
;
20 class nsASDOMWindowEarlyToLateEnumerator
;
21 class nsASAppWindowFrontToBackEnumerator
;
22 class nsASAppWindowBackToFrontEnumerator
;
23 class nsIWindowMediatorListener
;
26 class nsWindowMediator
: public nsIWindowMediator
,
28 public nsSupportsWeakReference
{
29 friend class nsAppShellWindowEnumerator
;
30 friend class nsASAppWindowEarlyToLateEnumerator
;
31 friend class nsASDOMWindowEarlyToLateEnumerator
;
32 friend class nsASAppWindowFrontToBackEnumerator
;
33 friend class nsASAppWindowBackToFrontEnumerator
;
36 virtual ~nsWindowMediator();
44 NS_DECL_NSIWINDOWMEDIATOR
47 static nsresult
GetDOMWindow(nsIAppWindow
* inWindow
,
48 nsCOMPtr
<nsPIDOMWindowOuter
>& outDOMWindow
);
51 void AddEnumerator(nsAppShellWindowEnumerator
* inEnumerator
);
52 int32_t RemoveEnumerator(nsAppShellWindowEnumerator
* inEnumerator
);
53 nsWindowInfo
* MostRecentWindowInfo(const char16_t
* inType
,
54 bool aSkipPrivateBrowsingOrClosed
= false);
56 nsresult
UnregisterWindow(nsWindowInfo
* inInfo
);
57 nsWindowInfo
* GetInfoFor(nsIAppWindow
* aWindow
);
58 nsWindowInfo
* GetInfoFor(nsIWidget
* aWindow
);
60 nsTArray
<nsAppShellWindowEnumerator
*> mEnumeratorList
;
61 nsWindowInfo
* mOldestWindow
;
62 nsWindowInfo
* mTopmostWindow
;
66 typedef nsTObserverArray
<nsCOMPtr
<nsIWindowMediatorListener
>> ListenerArray
;
67 ListenerArray mListeners
;