1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : *
3 : * ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is the Mozilla browser.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * Netscape Communications, Inc.
20 : * Portions created by the Initial Developer are Copyright (C) 1999
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : * Travis Bogard <travis@netscape.com>
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either the GNU General Public License Version 2 or later (the "GPL"), or
28 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #ifndef nsWebBrowser_h__
41 : #define nsWebBrowser_h__
42 :
43 : // Local Includes
44 : #include "nsDocShellTreeOwner.h"
45 :
46 : // Core Includes
47 : #include "nsCOMPtr.h"
48 :
49 : // Interfaces needed
50 : #include "nsCWebBrowser.h"
51 : #include "nsIBaseWindow.h"
52 : #include "nsIDocShell.h"
53 : #include "nsIDocShellTreeItem.h"
54 : #include "nsIDocShellTreeNode.h"
55 : #include "nsIInterfaceRequestor.h"
56 : #include "nsIInterfaceRequestorUtils.h"
57 : #include "nsIScrollable.h"
58 : #include "nsISHistory.h"
59 : #include "nsITextScroll.h"
60 : #include "nsIWidget.h"
61 : #include "nsIWebProgress.h"
62 : #include "nsISecureBrowserUI.h"
63 : #include "nsIWebBrowser.h"
64 : #include "nsIWebNavigation.h"
65 : #include "nsIWebBrowserSetup.h"
66 : #include "nsIWebBrowserPersist.h"
67 : #include "nsIWebBrowserFocus.h"
68 : #include "nsIWebBrowserStream.h"
69 : #include "nsIWindowWatcher.h"
70 : #include "nsIPrintSettings.h"
71 : #include "nsEmbedStream.h"
72 :
73 : #include "nsTArray.h"
74 : #include "nsWeakPtr.h"
75 :
76 : class nsIContentViewerFile;
77 :
78 : class nsWebBrowserInitInfo
79 0 : {
80 : public:
81 : //nsIBaseWindow Stuff
82 : PRInt32 x;
83 : PRInt32 y;
84 : PRInt32 cx;
85 : PRInt32 cy;
86 : bool visible;
87 : nsCOMPtr<nsISHistory> sessionHistory;
88 : nsString name;
89 : };
90 :
91 : class nsWebBrowserListenerState
92 0 : {
93 : public:
94 0 : bool Equals(nsIWeakReference *aListener, const nsIID& aID) {
95 0 : if (mWeakPtr.get() == aListener && mID.Equals(aID)) return true;
96 0 : return false;
97 : }
98 :
99 : nsWeakPtr mWeakPtr;
100 : nsIID mID;
101 : };
102 :
103 : // {F1EAC761-87E9-11d3-AF80-00A024FFC08C} -
104 : #define NS_WEBBROWSER_CID \
105 : {0xf1eac761, 0x87e9, 0x11d3, { 0xaf, 0x80, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c }}
106 :
107 :
108 : class nsWebBrowser : public nsIWebBrowser,
109 : public nsIWebNavigation,
110 : public nsIWebBrowserSetup,
111 : public nsIDocShellTreeItem,
112 : public nsIBaseWindow,
113 : public nsIScrollable,
114 : public nsITextScroll,
115 : public nsIInterfaceRequestor,
116 : public nsIWebBrowserPersist,
117 : public nsIWebBrowserFocus,
118 : public nsIWebProgressListener,
119 : public nsIWebBrowserStream,
120 : public nsSupportsWeakReference
121 : {
122 : friend class nsDocShellTreeOwner;
123 : public:
124 : nsWebBrowser();
125 :
126 : NS_DECL_ISUPPORTS
127 :
128 : NS_DECL_NSIBASEWINDOW
129 : NS_DECL_NSIDOCSHELLTREEITEM
130 : NS_DECL_NSIDOCSHELLTREENODE
131 : NS_DECL_NSIINTERFACEREQUESTOR
132 : NS_DECL_NSISCROLLABLE
133 : NS_DECL_NSITEXTSCROLL
134 : NS_DECL_NSIWEBBROWSER
135 : NS_DECL_NSIWEBNAVIGATION
136 : NS_DECL_NSIWEBBROWSERSETUP
137 : NS_DECL_NSIWEBBROWSERPERSIST
138 : NS_DECL_NSICANCELABLE
139 : NS_DECL_NSIWEBBROWSERFOCUS
140 : NS_DECL_NSIWEBBROWSERSTREAM
141 : NS_DECL_NSIWEBPROGRESSLISTENER
142 :
143 : protected:
144 : virtual ~nsWebBrowser();
145 : NS_IMETHOD InternalDestroy();
146 :
147 : // XXXbz why are these NS_IMETHOD? They're not interface methods!
148 : NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
149 : NS_IMETHOD EnsureDocShellTreeOwner();
150 : NS_IMETHOD GetPrimaryContentWindow(nsIDOMWindow **aDomWindow);
151 : NS_IMETHOD BindListener(nsISupports *aListener, const nsIID& aIID);
152 : NS_IMETHOD UnBindListener(nsISupports *aListener, const nsIID& aIID);
153 : NS_IMETHOD EnableGlobalHistory(bool aEnable);
154 :
155 : static nsEventStatus HandleEvent(nsGUIEvent *aEvent);
156 :
157 : protected:
158 : nsDocShellTreeOwner* mDocShellTreeOwner;
159 : nsCOMPtr<nsIDocShell> mDocShell;
160 : nsCOMPtr<nsIInterfaceRequestor> mDocShellAsReq;
161 : nsCOMPtr<nsIBaseWindow> mDocShellAsWin;
162 : nsCOMPtr<nsIDocShellTreeItem> mDocShellAsItem;
163 : nsCOMPtr<nsIWebNavigation> mDocShellAsNav;
164 : nsCOMPtr<nsIScrollable> mDocShellAsScrollable;
165 : nsCOMPtr<nsITextScroll> mDocShellAsTextScroll;
166 : nsCOMPtr<nsIWidget> mInternalWidget;
167 : nsCOMPtr<nsIWindowWatcher> mWWatch;
168 : nsWebBrowserInitInfo* mInitInfo;
169 : PRUint32 mContentType;
170 : bool mActivating;
171 : bool mShouldEnableHistory;
172 : bool mIsActive;
173 : nativeWindow mParentNativeWindow;
174 : nsIWebProgressListener *mProgressListener;
175 : nsCOMPtr<nsIWebProgress> mWebProgress;
176 :
177 : nsCOMPtr<nsIPrintSettings> mPrintSettings;
178 :
179 : // cached background color
180 : nscolor mBackgroundColor;
181 :
182 : // persistence object
183 : nsCOMPtr<nsIWebBrowserPersist> mPersist;
184 : PRUint32 mPersistCurrentState;
185 : PRUint32 mPersistResult;
186 : PRUint32 mPersistFlags;
187 :
188 : // stream
189 : nsEmbedStream *mStream;
190 : nsCOMPtr<nsISupports> mStreamGuard;
191 :
192 : //Weak Reference interfaces...
193 : nsIWidget* mParentWidget;
194 : nsTArray<nsWebBrowserListenerState*>* mListenerArray;
195 : };
196 :
197 : #endif /* nsWebBrowser_h__ */
198 :
199 :
|