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
* Adam Lock <adamlock@netscape.com>
30
* ***** END LICENSE BLOCK ***** */
32
#ifndef __WebBrowserChrome__
33
#define __WebBrowserChrome__
36
#include "nsIGenericFactory.h"
37
#include "nsIWebBrowserChrome.h"
38
#include "nsIWebBrowserChromeFocus.h"
40
#include "nsIContentViewer.h"
41
#include "nsIContentViewerFile.h"
42
#include "nsIBaseWindow.h"
43
#include "nsIEmbeddingSiteWindow2.h"
44
#include "nsIWebNavigation.h"
45
#include "nsIWebProgressListener.h"
46
#include "nsIInterfaceRequestor.h"
47
#include "nsIInterfaceRequestorUtils.h"
48
#include "nsIWebBrowser.h"
49
#include "nsIURIContentListener.h"
50
#include "nsIObserver.h"
51
#include "nsWeakReference.h"
52
#include "nsIContextMenuListener.h"
53
#include "nsIContextMenuListener2.h"
54
#include "nsITooltipListener.h"
56
class GeckoContainerUI;
58
// Define a custom nsIGeckoContainer interface. It means that if we are passed
59
// some random nsIWebBrowserChrome object we can tell if its one of ours by
60
// QIing to see if it implements nsIGeckoContainer
62
#define NS_IGECKOCONTAINER_IID \
63
{ 0xbf47a2ec, 0x9be0, 0x4f18, { 0x9a, 0xf0, 0x8e, 0x1c, 0x89, 0x2a, 0xa3, 0x1d } }
65
class NS_NO_VTABLE nsIGeckoContainer : public nsISupports
68
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IGECKOCONTAINER_IID)
70
NS_IMETHOD GetRole(nsACString &aRole) = 0;
71
NS_IMETHOD GetContainerUI(GeckoContainerUI **pUI) = 0;
74
#define NS_DECL_NSIGECKOCONTAINER \
75
NS_IMETHOD GetRole(nsACString &aRole); \
76
NS_IMETHOD GetContainerUI(GeckoContainerUI **pUI);
78
class GeckoContainer :
79
public nsIWebBrowserChrome,
80
public nsIWebBrowserChromeFocus,
81
public nsIWebProgressListener,
82
public nsIEmbeddingSiteWindow2,
83
public nsIInterfaceRequestor,
85
public nsIContextMenuListener2,
86
public nsITooltipListener,
87
public nsIURIContentListener,
88
public nsIGeckoContainer,
89
public nsSupportsWeakReference
92
// Supply a container UI callback and optionally a role, e.g. "browser"
93
// which can be used to modify the behaviour depending on the value
95
GeckoContainer(GeckoContainerUI *pUI, const char *aRole = NULL);
96
virtual ~GeckoContainer();
99
NS_DECL_NSIWEBBROWSERCHROME
100
NS_DECL_NSIWEBBROWSERCHROMEFOCUS
101
NS_DECL_NSIWEBPROGRESSLISTENER
102
NS_DECL_NSIEMBEDDINGSITEWINDOW
103
NS_DECL_NSIEMBEDDINGSITEWINDOW2
104
NS_DECL_NSIINTERFACEREQUESTOR
106
NS_DECL_NSICONTEXTMENULISTENER2
107
NS_DECL_NSITOOLTIPLISTENER
108
NS_DECL_NSIURICONTENTLISTENER
109
NS_DECL_NSIGECKOCONTAINER
111
nsresult CreateBrowser(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, nativeWindow aParent,
112
nsIWebBrowser **aBrowser);
114
void SetParent(nsIWebBrowserChrome *aParent)
115
{ mDependentParent = aParent; }
118
nsresult SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRInt32 info1=0, PRUint32 info2=0);
120
void ContentFinishedLoading();
122
GeckoContainerUI *mUI;
123
nativeWindow mNativeWindow;
124
PRUint32 mChromeFlags;
125
PRBool mContinueModalLoop;
127
PRBool mIsChromeContainer;
128
PRBool mIsURIContentListener;
131
nsCOMPtr<nsIWebBrowser> mWebBrowser;
132
nsCOMPtr<nsIWebBrowserChrome> mDependentParent; // opener (for dependent windows only)
136
class GeckoContainerUI
146
// Called by the window creator when a new browser window is requested
147
virtual nsresult CreateBrowserWindow(PRUint32 aChromeFlags,
148
nsIWebBrowserChrome *aParent, nsIWebBrowserChrome **aNewWindow);
149
// Called when the content wants to be destroyed (e.g. a window.close() happened)
150
virtual void Destroy();
151
// Called when the Gecko has been torn down, allowing dangling references to be released
152
virtual void Destroyed();
153
// Called when the content wants focus
154
virtual void SetFocus();
155
// Called when the content wants focus (e.g. onblur handler)
156
virtual void KillFocus();
157
// Called when the status bar text needs to be updated (e.g. progress notifications)
158
virtual void UpdateStatusBarText(const PRUnichar* aStatusText);
159
// Called when the current URI has changed. Allows UI to update address bar
160
virtual void UpdateCurrentURI();
161
// Called when the browser busy state changes. Allows UI to display an hourglass
162
virtual void UpdateBusyState(PRBool aBusy);
163
// Called when total progress changes
164
virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax);
165
virtual void GetResourceStringById(PRInt32 aID, char ** aReturn);
166
// Called when a context menu event has been detected on the page
167
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aContextMenuInfo);
168
// Called when a tooltip should be shown
169
virtual void ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText);
170
// Called when a tooltip should be hidden
171
virtual void HideTooltip();
172
// Called when the window should be hidden or shown
173
virtual void ShowWindow(PRBool aShow);
174
// Called when the browser area should be resized
175
virtual void SizeTo(PRInt32 aWidth, PRInt32 aHeight);
176
virtual void EnableChromeWindow(PRBool aEnabled);
177
virtual PRUint32 RunEventLoop(PRBool &aRunCondition);
180
#endif /* __WebBrowserChrome__ */