Bug 1728955: part 8) Refactor `DisplayErrCode` in Windows' `nsClipboard`. r=masayuki
[gecko.git] / xpfe / appshell / nsWindowMediator.h
blob9b2c7506613ec47e4cfb1eb8c111b53c112b5e42
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_
9 #include "nsCOMPtr.h"
10 #include "nsIWindowMediator.h"
11 #include "nsIObserver.h"
12 #include "nsTArray.h"
13 #include "nsString.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;
23 struct nsWindowInfo;
25 class nsWindowMediator : public nsIWindowMediator,
26 public nsIObserver,
27 public nsSupportsWeakReference {
28 friend class nsAppShellWindowEnumerator;
29 friend class nsASAppWindowEarlyToLateEnumerator;
30 friend class nsASDOMWindowEarlyToLateEnumerator;
31 friend class nsASAppWindowFrontToBackEnumerator;
32 friend class nsASAppWindowBackToFrontEnumerator;
34 protected:
35 virtual ~nsWindowMediator();
37 public:
38 nsWindowMediator();
40 nsresult Init();
42 NS_DECL_ISUPPORTS
43 NS_DECL_NSIWINDOWMEDIATOR
44 NS_DECL_NSIOBSERVER
46 static nsresult GetDOMWindow(nsIAppWindow* inWindow,
47 nsCOMPtr<nsPIDOMWindowOuter>& outDOMWindow);
49 private:
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;
64 int32_t mTimeStamp;
65 bool mSortingZOrder;
66 bool mReady;
68 typedef nsTObserverArray<nsCOMPtr<nsIWindowMediatorListener>> ListenerArray;
69 ListenerArray mListeners;
72 #endif