Back to index

lightning-sunbird  0.9+nobinonly
nsWebBrowser.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications, Inc.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Travis Bogard <travis@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef nsWebBrowser_h__
00041 #define nsWebBrowser_h__
00042 
00043 // Local Includes
00044 #include "nsDocShellTreeOwner.h"
00045 
00046 // Core Includes
00047 #include "nsCOMPtr.h"
00048 
00049 // Interfaces needed
00050 #include "nsCWebBrowser.h"
00051 #include "nsIBaseWindow.h"
00052 #include "nsIDocShell.h"
00053 #include "nsIDocShellTreeItem.h"
00054 #include "nsIInterfaceRequestor.h"
00055 #include "nsIInterfaceRequestorUtils.h"
00056 #include "nsIScrollable.h"
00057 #include "nsISHistory.h"
00058 #include "nsITextScroll.h"
00059 #include "nsIWidget.h"
00060 #include "nsIWebProgress.h"
00061 #include "nsISecureBrowserUI.h"
00062 #include "nsIWebBrowser.h"
00063 #include "nsIWebNavigation.h"
00064 #include "nsIWebBrowserSetup.h"
00065 #include "nsIWebBrowserPersist.h"
00066 #include "nsIWebBrowserFocus.h"
00067 #include "nsIWebBrowserStream.h"
00068 #include "nsIWindowWatcher.h"
00069 #include "nsIPrintSettings.h"
00070 #include "nsEmbedStream.h"
00071 
00072 #include "nsVoidArray.h"
00073 #include "nsWeakPtr.h"
00074 
00075 class nsIContentViewerFile;
00076 
00077 class nsWebBrowserInitInfo
00078 {
00079 public:
00080    //nsIBaseWindow Stuff
00081    PRInt32                 x;
00082    PRInt32                 y;
00083    PRInt32                 cx;
00084    PRInt32                 cy;
00085    PRBool                  visible;
00086    nsCOMPtr<nsISHistory>   sessionHistory;
00087    nsString                name;
00088 };
00089 
00090 class nsWebBrowserListenerState
00091 {
00092 public:
00093     PRBool Equals(nsIWeakReference *aListener, const nsIID& aID) {
00094         if (mWeakPtr.get() == aListener && mID.Equals(aID)) return PR_TRUE;
00095         return PR_FALSE;
00096     };
00097 
00098     nsWeakPtr mWeakPtr;
00099     nsIID mID;
00100 };
00101 
00102 //  {F1EAC761-87E9-11d3-AF80-00A024FFC08C} - 
00103 #define NS_WEBBROWSER_CID \
00104 {0xf1eac761, 0x87e9, 0x11d3, { 0xaf, 0x80, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c }}
00105 
00106 
00107 class nsWebBrowser : public nsIWebBrowser,
00108                      public nsIWebNavigation,
00109                      public nsIWebBrowserSetup,
00110                      public nsIDocShellTreeItem,
00111                      public nsIBaseWindow,
00112                      public nsIScrollable, 
00113                      public nsITextScroll, 
00114                      public nsIInterfaceRequestor,
00115                      public nsIWebBrowserPersist,
00116                      public nsIWebBrowserFocus,
00117                      public nsIWebProgressListener,
00118                      public nsIWebBrowserStream,
00119                      public nsSupportsWeakReference
00120 {
00121 friend class nsDocShellTreeOwner;
00122 public:
00123     nsWebBrowser();
00124 
00125     NS_DECL_ISUPPORTS
00126 
00127     NS_DECL_NSIBASEWINDOW
00128     NS_DECL_NSIDOCSHELLTREEITEM
00129     NS_DECL_NSIINTERFACEREQUESTOR
00130     NS_DECL_NSISCROLLABLE   
00131     NS_DECL_NSITEXTSCROLL
00132     NS_DECL_NSIWEBBROWSER
00133     NS_DECL_NSIWEBNAVIGATION
00134     NS_DECL_NSIWEBBROWSERSETUP
00135     NS_DECL_NSIWEBBROWSERPERSIST
00136     NS_DECL_NSICANCELABLE
00137     NS_DECL_NSIWEBBROWSERFOCUS
00138     NS_DECL_NSIWEBBROWSERSTREAM
00139     NS_DECL_NSIWEBPROGRESSLISTENER
00140 
00141 protected:
00142     virtual ~nsWebBrowser();
00143     NS_IMETHOD InternalDestroy();
00144 
00145     NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
00146     NS_IMETHOD EnsureDocShellTreeOwner();
00147     NS_IMETHOD GetPrimaryContentWindow(nsIDOMWindowInternal **aDomWindow);
00148     NS_IMETHOD BindListener(nsISupports *aListener, const nsIID& aIID);
00149     NS_IMETHOD UnBindListener(nsISupports *aListener, const nsIID& aIID);
00150     NS_IMETHOD EnableGlobalHistory(PRBool aEnable);
00151 
00152     static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
00153 
00154 protected:
00155    nsDocShellTreeOwner*       mDocShellTreeOwner;
00156    nsCOMPtr<nsIDocShell>      mDocShell;
00157    nsCOMPtr<nsIInterfaceRequestor> mDocShellAsReq;
00158    nsCOMPtr<nsIBaseWindow>    mDocShellAsWin;
00159    nsCOMPtr<nsIDocShellTreeItem> mDocShellAsItem;
00160    nsCOMPtr<nsIWebNavigation> mDocShellAsNav;
00161    nsCOMPtr<nsIScrollable>    mDocShellAsScrollable;
00162    nsCOMPtr<nsITextScroll>    mDocShellAsTextScroll;
00163    nsCOMPtr<nsIWidget>        mInternalWidget;
00164    nsCOMPtr<nsIWindowWatcher> mWWatch;
00165    nsWebBrowserInitInfo*      mInitInfo;
00166    PRUint32                   mContentType;
00167    PRBool                     mActivating;
00168    nativeWindow               mParentNativeWindow;
00169    nsIWebProgressListener    *mProgressListener;
00170    nsCOMPtr<nsIWebProgress>      mWebProgress;
00171 
00172    nsCOMPtr<nsIPrintSettings> mPrintSettings;
00173 
00174    // cached background color
00175    nscolor                       mBackgroundColor;
00176 
00177    // persistence object
00178    nsCOMPtr<nsIWebBrowserPersist> mPersist;
00179    PRUint32                       mPersistCurrentState;
00180    PRUint32                       mPersistResult;
00181    PRUint32                       mPersistFlags;
00182 
00183    // stream
00184    nsEmbedStream                 *mStream;
00185    nsCOMPtr<nsISupports>          mStreamGuard;
00186 
00187    //Weak Reference interfaces...
00188    nsIWidget*                 mParentWidget;
00189    nsVoidArray *              mListenerArray;
00190    
00191 #if (defined(XP_MAC) || defined(XP_MACOSX)) && !defined(MOZ_WIDGET_COCOA)
00192    NS_IMETHOD EnsureTopLevelWidget(nativeWindow aWindow);
00193 
00194    nsIWidget*                 mTopLevelWidget;
00195 #endif
00196 
00197 };
00198 
00199 #endif /* nsWebBrowser_h__ */
00200 
00201