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"
14 #include "nsWeakReference.h"
15 #include "nsTObserverArray.h"
17 class nsAppShellWindowEnumerator
;
18 class nsASAppWindowEarlyToLateEnumerator
;
19 class nsASDOMWindowEarlyToLateEnumerator
;
20 class nsASAppWindowFrontToBackEnumerator
;
21 class nsASAppWindowBackToFrontEnumerator
;
22 class nsIWindowMediatorListener
;
25 class nsWindowMediator
: public nsIWindowMediator
,
27 public nsSupportsWeakReference
{
28 friend class nsAppShellWindowEnumerator
;
29 friend class nsASAppWindowEarlyToLateEnumerator
;
30 friend class nsASDOMWindowEarlyToLateEnumerator
;
31 friend class nsASAppWindowFrontToBackEnumerator
;
32 friend class nsASAppWindowBackToFrontEnumerator
;
35 virtual ~nsWindowMediator();
43 NS_DECL_NSIWINDOWMEDIATOR
46 static nsresult
GetDOMWindow(nsIAppWindow
* inWindow
,
47 nsCOMPtr
<nsPIDOMWindowOuter
>& outDOMWindow
);
50 void AddEnumerator(nsAppShellWindowEnumerator
* inEnumerator
);
51 int32_t RemoveEnumerator(nsAppShellWindowEnumerator
* inEnumerator
);
52 nsWindowInfo
* MostRecentWindowInfo(const char16_t
* inType
,
53 bool aSkipPrivateBrowsingOrClosed
= false);
55 nsresult
UnregisterWindow(nsWindowInfo
* inInfo
);
56 nsWindowInfo
* GetInfoFor(nsIAppWindow
* aWindow
);
57 nsWindowInfo
* GetInfoFor(nsIWidget
* aWindow
);
58 void SortZOrderFrontToBack();
59 void SortZOrderBackToFront();
61 nsTArray
<nsAppShellWindowEnumerator
*> mEnumeratorList
;
62 nsWindowInfo
* mOldestWindow
;
63 nsWindowInfo
* mTopmostWindow
;
68 typedef nsTObserverArray
<nsCOMPtr
<nsIWindowMediatorListener
>> ListenerArray
;
69 ListenerArray mListeners
;