Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsWebBrowser_h__
8 #define nsWebBrowser_h__
10 // Local Includes
11 #include "nsDocShellTreeOwner.h"
13 // Core Includes
14 #include "nsCOMPtr.h"
16 // Interfaces needed
17 #include "nsCWebBrowser.h"
18 #include "nsIBaseWindow.h"
19 #include "nsIDocShell.h"
20 #include "nsIDocShellTreeItem.h"
21 #include "nsIInterfaceRequestor.h"
22 #include "nsIInterfaceRequestorUtils.h"
23 #include "nsIScrollable.h"
24 #include "nsISHistory.h"
25 #include "nsITextScroll.h"
26 #include "nsIWidget.h"
27 #include "nsIWebProgress.h"
28 #include "nsISecureBrowserUI.h"
29 #include "nsIWebBrowser.h"
30 #include "nsIWebNavigation.h"
31 #include "nsIWebBrowserSetup.h"
32 #include "nsIWebBrowserPersist.h"
33 #include "nsIWebBrowserFocus.h"
34 #include "nsIWebBrowserStream.h"
35 #include "nsIWindowWatcher.h"
36 #include "nsIPrintSettings.h"
37 #include "nsEmbedStream.h"
38 #include "nsIWidgetListener.h"
40 #include "nsTArray.h"
41 #include "nsWeakPtr.h"
43 class nsIContentViewerFile;
45 class nsWebBrowserInitInfo
46 {
47 public:
48 //nsIBaseWindow Stuff
49 int32_t x;
50 int32_t y;
51 int32_t cx;
52 int32_t cy;
53 bool visible;
54 nsCOMPtr<nsISHistory> sessionHistory;
55 nsString name;
56 };
58 class nsWebBrowserListenerState
59 {
60 public:
61 bool Equals(nsIWeakReference *aListener, const nsIID& aID) {
62 if (mWeakPtr.get() == aListener && mID.Equals(aID)) return true;
63 return false;
64 }
66 nsWeakPtr mWeakPtr;
67 nsIID mID;
68 };
70 // {cda5863a-aa9c-411e-be49-ea0d525ab4b5} -
71 #define NS_WEBBROWSER_CID \
72 {0xcda5863a, 0xaa9c, 0x411e, { 0xbe, 0x49, 0xea, 0x0d, 0x52, 0x5a, 0xb4, 0xb5 }}
75 class nsWebBrowser : public nsIWebBrowser,
76 public nsIWebNavigation,
77 public nsIWebBrowserSetup,
78 public nsIDocShellTreeItem,
79 public nsIBaseWindow,
80 public nsIScrollable,
81 public nsITextScroll,
82 public nsIInterfaceRequestor,
83 public nsIWebBrowserPersist,
84 public nsIWebBrowserFocus,
85 public nsIWebProgressListener,
86 public nsIWebBrowserStream,
87 public nsIWidgetListener,
88 public nsSupportsWeakReference
89 {
90 friend class nsDocShellTreeOwner;
91 public:
92 nsWebBrowser();
94 NS_DECL_ISUPPORTS
96 NS_DECL_NSIBASEWINDOW
97 NS_DECL_NSIDOCSHELLTREEITEM
98 NS_DECL_NSIINTERFACEREQUESTOR
99 NS_DECL_NSISCROLLABLE
100 NS_DECL_NSITEXTSCROLL
101 NS_DECL_NSIWEBBROWSER
102 NS_DECL_NSIWEBNAVIGATION
103 NS_DECL_NSIWEBBROWSERSETUP
104 NS_DECL_NSIWEBBROWSERPERSIST
105 NS_DECL_NSICANCELABLE
106 NS_DECL_NSIWEBBROWSERFOCUS
107 NS_DECL_NSIWEBBROWSERSTREAM
108 NS_DECL_NSIWEBPROGRESSLISTENER
110 protected:
111 virtual ~nsWebBrowser();
112 NS_IMETHOD InternalDestroy();
114 // XXXbz why are these NS_IMETHOD? They're not interface methods!
115 NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
116 NS_IMETHOD EnsureDocShellTreeOwner();
117 NS_IMETHOD GetPrimaryContentWindow(nsIDOMWindow **aDomWindow);
118 NS_IMETHOD BindListener(nsISupports *aListener, const nsIID& aIID);
119 NS_IMETHOD UnBindListener(nsISupports *aListener, const nsIID& aIID);
120 NS_IMETHOD EnableGlobalHistory(bool aEnable);
122 // nsIWidgetListener
123 virtual void WindowRaised(nsIWidget* aWidget);
124 virtual void WindowLowered(nsIWidget* aWidget);
125 virtual bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion) MOZ_OVERRIDE;
127 protected:
128 nsDocShellTreeOwner* mDocShellTreeOwner;
129 nsCOMPtr<nsIDocShell> mDocShell;
130 nsCOMPtr<nsIInterfaceRequestor> mDocShellAsReq;
131 nsCOMPtr<nsIBaseWindow> mDocShellAsWin;
132 nsCOMPtr<nsIWebNavigation> mDocShellAsNav;
133 nsCOMPtr<nsIScrollable> mDocShellAsScrollable;
134 nsCOMPtr<nsITextScroll> mDocShellAsTextScroll;
135 nsCOMPtr<nsIWidget> mInternalWidget;
136 nsCOMPtr<nsIWindowWatcher> mWWatch;
137 nsWebBrowserInitInfo* mInitInfo;
138 uint32_t mContentType;
139 bool mActivating;
140 bool mShouldEnableHistory;
141 bool mIsActive;
142 nativeWindow mParentNativeWindow;
143 nsIWebProgressListener *mProgressListener;
144 nsCOMPtr<nsIWebProgress> mWebProgress;
146 nsCOMPtr<nsIPrintSettings> mPrintSettings;
148 // cached background color
149 nscolor mBackgroundColor;
151 // persistence object
152 nsCOMPtr<nsIWebBrowserPersist> mPersist;
153 uint32_t mPersistCurrentState;
154 nsresult mPersistResult;
155 uint32_t mPersistFlags;
157 // stream
158 nsEmbedStream *mStream;
159 nsCOMPtr<nsISupports> mStreamGuard;
161 //Weak Reference interfaces...
162 nsIWidget* mParentWidget;
163 nsTArray<nsWebBrowserListenerState*>* mListenerArray;
164 };
166 #endif /* nsWebBrowser_h__ */