Follow-on fix for bug 457825. Use sheet principal for agent and user sheets. r=dbaron...
[wine-gecko.git] / embedding / tests / wxEmbed / GeckoContainer.h
blob5c0a464d7937d40f42e2e72847d93de9fb0d71a1
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: Mozilla-sample-code 1.0
4 * Copyright (c) 2002 Netscape Communications Corporation and
5 * other contributors
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.
26 * Contributor(s):
27 * Adam Lock <adamlock@netscape.com>
29 * ***** END LICENSE BLOCK ***** */
31 #ifndef __WebBrowserChrome__
32 #define __WebBrowserChrome__
34 #include "nsCOMPtr.h"
35 #include "nsIGenericFactory.h"
36 #include "nsIWebBrowserChrome.h"
37 #include "nsIWebBrowserChromeFocus.h"
39 #include "nsIContentViewer.h"
40 #include "nsIContentViewerFile.h"
41 #include "nsIBaseWindow.h"
42 #include "nsIEmbeddingSiteWindow2.h"
43 #include "nsIWebNavigation.h"
44 #include "nsIWebProgressListener.h"
45 #include "nsIInterfaceRequestor.h"
46 #include "nsIInterfaceRequestorUtils.h"
47 #include "nsIWebBrowser.h"
48 #include "nsIURIContentListener.h"
49 #include "nsIObserver.h"
50 #include "nsWeakReference.h"
51 #include "nsIContextMenuListener.h"
52 #include "nsIContextMenuListener2.h"
53 #include "nsITooltipListener.h"
55 class GeckoContainerUI;
57 // Define a custom nsIGeckoContainer interface. It means that if we are passed
58 // some random nsIWebBrowserChrome object we can tell if its one of ours by
59 // QIing to see if it implements nsIGeckoContainer
61 #define NS_IGECKOCONTAINER_IID \
62 { 0xbf47a2ec, 0x9be0, 0x4f18, { 0x9a, 0xf0, 0x8e, 0x1c, 0x89, 0x2a, 0xa3, 0x1d } }
64 class NS_NO_VTABLE nsIGeckoContainer : public nsISupports
66 public:
67 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGECKOCONTAINER_IID)
69 NS_IMETHOD GetRole(nsACString &aRole) = 0;
70 NS_IMETHOD GetContainerUI(GeckoContainerUI **pUI) = 0;
73 NS_DEFINE_STATIC_IID_ACCESSOR(nsIGeckoContainer, NS_IGECKOCONTAINER_IID)
75 #define NS_DECL_NSIGECKOCONTAINER \
76 NS_IMETHOD GetRole(nsACString &aRole); \
77 NS_IMETHOD GetContainerUI(GeckoContainerUI **pUI);
79 class GeckoContainer :
80 public nsIWebBrowserChrome,
81 public nsIWebBrowserChromeFocus,
82 public nsIWebProgressListener,
83 public nsIEmbeddingSiteWindow2,
84 public nsIInterfaceRequestor,
85 public nsIObserver,
86 public nsIContextMenuListener2,
87 public nsITooltipListener,
88 public nsIURIContentListener,
89 public nsIGeckoContainer,
90 public nsSupportsWeakReference
92 public:
93 // Supply a container UI callback and optionally a role, e.g. "browser"
94 // which can be used to modify the behaviour depending on the value
95 // it contains.
96 GeckoContainer(GeckoContainerUI *pUI, const char *aRole = NULL);
97 virtual ~GeckoContainer();
99 NS_DECL_ISUPPORTS
100 NS_DECL_NSIWEBBROWSERCHROME
101 NS_DECL_NSIWEBBROWSERCHROMEFOCUS
102 NS_DECL_NSIWEBPROGRESSLISTENER
103 NS_DECL_NSIEMBEDDINGSITEWINDOW
104 NS_DECL_NSIEMBEDDINGSITEWINDOW2
105 NS_DECL_NSIINTERFACEREQUESTOR
106 NS_DECL_NSIOBSERVER
107 NS_DECL_NSICONTEXTMENULISTENER2
108 NS_DECL_NSITOOLTIPLISTENER
109 NS_DECL_NSIURICONTENTLISTENER
110 NS_DECL_NSIGECKOCONTAINER
112 nsresult CreateBrowser(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, nativeWindow aParent,
113 nsIWebBrowser **aBrowser);
115 void SetParent(nsIWebBrowserChrome *aParent)
116 { mDependentParent = aParent; }
118 protected:
119 nsresult SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRInt32 info1=0, PRUint32 info2=0);
121 void ContentFinishedLoading();
123 GeckoContainerUI *mUI;
124 nativeWindow mNativeWindow;
125 PRUint32 mChromeFlags;
126 PRBool mContinueModalLoop;
127 PRBool mSizeSet;
128 PRBool mIsChromeContainer;
129 PRBool mIsURIContentListener;
131 nsCString mRole;
132 nsCOMPtr<nsIWebBrowser> mWebBrowser;
133 nsCOMPtr<nsIWebBrowserChrome> mDependentParent; // opener (for dependent windows only)
137 class GeckoContainerUI
139 protected:
140 PRBool mBusy;
142 public:
143 GeckoContainerUI() :
144 mBusy(PR_FALSE)
147 // Called by the window creator when a new browser window is requested
148 virtual nsresult CreateBrowserWindow(PRUint32 aChromeFlags,
149 nsIWebBrowserChrome *aParent, nsIWebBrowserChrome **aNewWindow);
150 // Called when the content wants to be destroyed (e.g. a window.close() happened)
151 virtual void Destroy();
152 // Called when the Gecko has been torn down, allowing dangling references to be released
153 virtual void Destroyed();
154 // Called when the content wants focus
155 virtual void SetFocus();
156 // Called when the content wants focus (e.g. onblur handler)
157 virtual void KillFocus();
158 // Called when the status bar text needs to be updated (e.g. progress notifications)
159 virtual void UpdateStatusBarText(const PRUnichar* aStatusText);
160 // Called when the current URI has changed. Allows UI to update address bar
161 virtual void UpdateCurrentURI();
162 // Called when the browser busy state changes. Allows UI to display an hourglass
163 virtual void UpdateBusyState(PRBool aBusy);
164 // Called when total progress changes
165 virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax);
166 virtual void GetResourceStringById(PRInt32 aID, char ** aReturn);
167 // Called when a context menu event has been detected on the page
168 virtual void ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aContextMenuInfo);
169 // Called when a tooltip should be shown
170 virtual void ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText);
171 // Called when a tooltip should be hidden
172 virtual void HideTooltip();
173 // Called when the window should be hidden or shown
174 virtual void ShowWindow(PRBool aShow);
175 // Called when the browser area should be resized
176 virtual void SizeTo(PRInt32 aWidth, PRInt32 aHeight);
177 virtual void EnableChromeWindow(PRBool aEnabled);
178 virtual PRUint32 RunEventLoop(PRBool &aRunCondition);
181 #endif /* __WebBrowserChrome__ */