1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: Mozilla-sample-code 1.0
4 * Copyright (c) 2002 Netscape Communications Corporation and
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this Mozilla sample software and associated documentation files
9 * (the "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to permit
12 * persons to whom the Software is furnished to do so, subject to the
13 * following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
28 * ***** END LICENSE BLOCK ***** */
30 #ifndef __WebBrowserChrome__
31 #define __WebBrowserChrome__
34 #include "nsIGenericFactory.h"
36 #include "nsIWebBrowserChrome.h"
37 #include "nsIWebBrowserChromeFocus.h"
39 #include "nsIDocShell.h"
40 #include "nsIContentViewer.h"
41 #include "nsIContentViewerFile.h"
42 #include "nsIBaseWindow.h"
43 #include "nsIEmbeddingSiteWindow.h"
44 #include "nsIWebNavigation.h"
45 #include "nsIWebProgressListener.h"
46 #include "nsIInterfaceRequestor.h"
47 #include "nsIInterfaceRequestorUtils.h"
48 #include "nsIWebBrowser.h"
49 #include "nsIObserver.h"
50 #include "nsWeakReference.h"
51 #include "nsISHistoryListener.h"
52 #include "nsIContextMenuListener.h"
53 #include "nsITooltipListener.h"
55 class WebBrowserChromeUI
58 static nativeWindow
CreateNativeWindow(nsIWebBrowserChrome
* chrome
);
59 static void Destroy(nsIWebBrowserChrome
* chrome
);
60 static void Destroyed(nsIWebBrowserChrome
* chrome
);
61 static void SetFocus(nsIWebBrowserChrome
*chrome
);
62 static void UpdateStatusBarText(nsIWebBrowserChrome
*aChrome
, const PRUnichar
* aStatusText
);
63 static void UpdateCurrentURI(nsIWebBrowserChrome
*aChrome
);
64 static void UpdateBusyState(nsIWebBrowserChrome
*aChrome
, PRBool aBusy
);
65 static void UpdateProgress(nsIWebBrowserChrome
*aChrome
, PRInt32 aCurrent
, PRInt32 aMax
);
66 static void GetResourceStringById(PRInt32 aID
, char ** aReturn
);
67 static void ShowContextMenu(nsIWebBrowserChrome
*aChrome
, PRUint32 aContextFlags
, nsIDOMEvent
*aEvent
, nsIDOMNode
*aNode
);
68 static void ShowTooltip(nsIWebBrowserChrome
*aChrome
, PRInt32 aXCoords
, PRInt32 aYCoords
, const PRUnichar
*aTipText
);
69 static void HideTooltip(nsIWebBrowserChrome
*aChrome
);
70 static void ShowWindow(nsIWebBrowserChrome
*aChrome
, PRBool aShow
);
71 static void SizeTo(nsIWebBrowserChrome
*aChrome
, PRInt32 aWidth
, PRInt32 aHeight
);
74 class WebBrowserChrome
: public nsIWebBrowserChrome
,
75 public nsIWebBrowserChromeFocus
,
76 public nsIWebProgressListener
,
77 public nsIEmbeddingSiteWindow
,
78 public nsIInterfaceRequestor
,
79 public nsISHistoryListener
,
81 public nsIContextMenuListener
,
82 public nsITooltipListener
,
83 public nsSupportsWeakReference
88 virtual ~WebBrowserChrome();
91 NS_DECL_NSIWEBBROWSERCHROME
92 NS_DECL_NSIWEBBROWSERCHROMEFOCUS
93 NS_DECL_NSIWEBPROGRESSLISTENER
94 NS_DECL_NSIEMBEDDINGSITEWINDOW
95 NS_DECL_NSIINTERFACEREQUESTOR
96 NS_DECL_NSISHISTORYLISTENER
98 NS_DECL_NSICONTEXTMENULISTENER
99 NS_DECL_NSITOOLTIPLISTENER
101 nsresult
CreateBrowser(PRInt32 aX
, PRInt32 aY
, PRInt32 aCX
, PRInt32 aCY
,
102 nsIWebBrowser
**aBrowser
);
104 void SetParent(nsIWebBrowserChrome
*aParent
)
105 { mDependentParent
= aParent
; }
108 nsresult
SendHistoryStatusMessage(nsIURI
* aURI
, char * operation
, PRInt32 info1
=0, PRUint32 info2
=0);
110 void ContentFinishedLoading();
112 nativeWindow mNativeWindow
;
113 PRUint32 mChromeFlags
;
114 PRBool mContinueModalLoop
;
117 nsCOMPtr
<nsIWebBrowser
> mWebBrowser
;
118 nsCOMPtr
<nsIWebBrowserChrome
> mDependentParent
; // opener (for dependent windows only)
121 #endif /* __WebBrowserChrome__ */