Back to index

lightning-sunbird  0.9+nobinonly
WebBrowserChrome.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: Mozilla-sample-code 1.0
00003  *
00004  * Copyright (c) 2002 Netscape Communications Corporation and
00005  * other contributors
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this Mozilla sample software and associated documentation files
00009  * (the "Software"), to deal in the Software without restriction, including
00010  * without limitation the rights to use, copy, modify, merge, publish,
00011  * distribute, sublicense, and/or sell copies of the Software, and to permit
00012  * persons to whom the Software is furnished to do so, subject to the
00013  * following conditions:
00014  *
00015  * The above copyright notice and this permission notice shall be included
00016  * in all copies or substantial portions of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00020  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00021  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00022  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00023  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00024  * DEALINGS IN THE SOFTWARE.
00025  *
00026  * Contributor(s):
00027  *
00028  * ***** END LICENSE BLOCK ***** */
00029 
00030 #ifndef __WebBrowserChrome__
00031 #define __WebBrowserChrome__
00032 
00033 #include "nsCOMPtr.h"
00034 #include "nsString.h"
00035 #include "nsIWebBrowserChrome.h"
00036 #include "nsIWebBrowserChromeFocus.h"
00037 
00038 #include "nsIBaseWindow.h"
00039 #include "nsIEmbeddingSiteWindow.h"
00040 #include "nsIWebNavigation.h"
00041 #include "nsIWebProgressListener.h"
00042 #include "nsIInterfaceRequestor.h"
00043 #include "nsIInterfaceRequestorUtils.h"
00044 #include "nsIWebBrowser.h"
00045 #include "nsIObserver.h"
00046 #include "nsWeakReference.h"
00047 #include "nsISHistoryListener.h"
00048 #include "nsIContextMenuListener.h"
00049 #include "nsITooltipListener.h"
00050 
00051 class WebBrowserChromeUI
00052 {
00053 public:
00054     static nativeWindow CreateNativeWindow(nsIWebBrowserChrome* chrome);
00055     static void Destroy(nsIWebBrowserChrome* chrome);
00056     static void Destroyed(nsIWebBrowserChrome* chrome);
00057     static void SetFocus(nsIWebBrowserChrome *chrome);
00058     static void UpdateStatusBarText(nsIWebBrowserChrome *aChrome, const PRUnichar* aStatusText);
00059     static void UpdateCurrentURI(nsIWebBrowserChrome *aChrome);
00060     static void UpdateBusyState(nsIWebBrowserChrome *aChrome, PRBool aBusy);
00061     static void UpdateProgress(nsIWebBrowserChrome *aChrome, PRInt32 aCurrent, PRInt32 aMax);
00062     static void GetResourceStringById(PRInt32 aID, char ** aReturn);
00063     static void ShowContextMenu(nsIWebBrowserChrome *aChrome, PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode);
00064     static void ShowTooltip(nsIWebBrowserChrome *aChrome, PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText);
00065     static void HideTooltip(nsIWebBrowserChrome *aChrome);
00066     static void ShowWindow(nsIWebBrowserChrome *aChrome, PRBool aShow);
00067     static void SizeTo(nsIWebBrowserChrome *aChrome, PRInt32 aWidth, PRInt32 aHeight);
00068 };
00069 
00070 class WebBrowserChrome   : public nsIWebBrowserChrome,
00071                            public nsIWebBrowserChromeFocus,
00072                            public nsIWebProgressListener,
00073                            public nsIEmbeddingSiteWindow,
00074                            public nsIInterfaceRequestor,
00075                            public nsISHistoryListener,
00076                            public nsIObserver,
00077                            public nsIContextMenuListener,
00078                            public nsITooltipListener,
00079                            public nsSupportsWeakReference
00080 
00081 {
00082 public:
00083     WebBrowserChrome();
00084     virtual ~WebBrowserChrome();
00085 
00086     NS_DECL_ISUPPORTS
00087     NS_DECL_NSIWEBBROWSERCHROME
00088     NS_DECL_NSIWEBBROWSERCHROMEFOCUS
00089     NS_DECL_NSIWEBPROGRESSLISTENER
00090     NS_DECL_NSIEMBEDDINGSITEWINDOW
00091     NS_DECL_NSIINTERFACEREQUESTOR
00092     NS_DECL_NSISHISTORYLISTENER
00093     NS_DECL_NSIOBSERVER
00094     NS_DECL_NSICONTEXTMENULISTENER
00095     NS_DECL_NSITOOLTIPLISTENER
00096 
00097     nsresult CreateBrowser(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY,
00098                            nsIWebBrowser **aBrowser);
00099 
00100     void     SetParent(nsIWebBrowserChrome *aParent)
00101                { mDependentParent = aParent; }
00102    
00103 protected:
00104     nsresult SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRInt32 info1=0, PRUint32 info2=0);
00105 
00106     void ContentFinishedLoading();
00107 
00108     nativeWindow mNativeWindow;
00109     PRUint32     mChromeFlags;
00110     PRBool       mContinueModalLoop;
00111     PRBool       mSizeSet;
00112 
00113     nsCOMPtr<nsIWebBrowser> mWebBrowser;
00114     nsCOMPtr<nsIWebBrowserChrome> mDependentParent; // opener (for dependent windows only)
00115 };
00116 
00117 #endif /* __WebBrowserChrome__ */