~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/embedding/tests/wxEmbed/GeckoContainer.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ***** BEGIN LICENSE BLOCK *****
 
2
 * Version: Mozilla-sample-code 1.0
 
3
 *
 
4
 * Copyright (c) 2002 Netscape Communications Corporation and
 
5
 * other contributors
 
6
 *
 
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:
 
14
 *
 
15
 * The above copyright notice and this permission notice shall be included
 
16
 * in all copies or substantial portions of the Software.
 
17
 *
 
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.
 
25
 *
 
26
 * Contributor(s):
 
27
 *
 
28
 *   Adam Lock <adamlock@netscape.com>
 
29
 *
 
30
 * ***** END LICENSE BLOCK ***** */
 
31
 
 
32
#ifndef __WebBrowserChrome__
 
33
#define __WebBrowserChrome__
 
34
 
 
35
#include "nsCOMPtr.h"
 
36
#include "nsIGenericFactory.h"
 
37
#include "nsIWebBrowserChrome.h"
 
38
#include "nsIWebBrowserChromeFocus.h"
 
39
 
 
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"
 
55
 
 
56
class GeckoContainerUI;
 
57
 
 
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
 
61
 
 
62
#define NS_IGECKOCONTAINER_IID \
 
63
    { 0xbf47a2ec, 0x9be0, 0x4f18, { 0x9a, 0xf0, 0x8e, 0x1c, 0x89, 0x2a, 0xa3, 0x1d } }
 
64
 
 
65
class NS_NO_VTABLE nsIGeckoContainer : public nsISupports
 
66
{
 
67
public:
 
68
    NS_DEFINE_STATIC_IID_ACCESSOR(NS_IGECKOCONTAINER_IID)
 
69
 
 
70
    NS_IMETHOD GetRole(nsACString &aRole) = 0;
 
71
    NS_IMETHOD GetContainerUI(GeckoContainerUI **pUI) = 0;
 
72
};
 
73
 
 
74
#define NS_DECL_NSIGECKOCONTAINER \
 
75
    NS_IMETHOD GetRole(nsACString &aRole); \
 
76
    NS_IMETHOD GetContainerUI(GeckoContainerUI **pUI);
 
77
 
 
78
class GeckoContainer   :
 
79
    public nsIWebBrowserChrome,
 
80
    public nsIWebBrowserChromeFocus,
 
81
    public nsIWebProgressListener,
 
82
    public nsIEmbeddingSiteWindow2,
 
83
    public nsIInterfaceRequestor,
 
84
    public nsIObserver,
 
85
    public nsIContextMenuListener2,
 
86
    public nsITooltipListener,
 
87
    public nsIURIContentListener,
 
88
    public nsIGeckoContainer,
 
89
    public nsSupportsWeakReference
 
90
{
 
91
public:
 
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
 
94
    // it contains.
 
95
    GeckoContainer(GeckoContainerUI *pUI, const char *aRole = NULL);
 
96
    virtual ~GeckoContainer();
 
97
 
 
98
    NS_DECL_ISUPPORTS
 
99
    NS_DECL_NSIWEBBROWSERCHROME
 
100
    NS_DECL_NSIWEBBROWSERCHROMEFOCUS
 
101
    NS_DECL_NSIWEBPROGRESSLISTENER
 
102
    NS_DECL_NSIEMBEDDINGSITEWINDOW
 
103
    NS_DECL_NSIEMBEDDINGSITEWINDOW2
 
104
    NS_DECL_NSIINTERFACEREQUESTOR
 
105
    NS_DECL_NSIOBSERVER
 
106
    NS_DECL_NSICONTEXTMENULISTENER2
 
107
    NS_DECL_NSITOOLTIPLISTENER
 
108
    NS_DECL_NSIURICONTENTLISTENER
 
109
    NS_DECL_NSIGECKOCONTAINER
 
110
 
 
111
    nsresult CreateBrowser(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, nativeWindow aParent,
 
112
                           nsIWebBrowser **aBrowser);
 
113
 
 
114
    void     SetParent(nsIWebBrowserChrome *aParent)
 
115
               { mDependentParent = aParent; }
 
116
   
 
117
protected:
 
118
    nsresult SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRInt32 info1=0, PRUint32 info2=0);
 
119
 
 
120
    void ContentFinishedLoading();
 
121
 
 
122
    GeckoContainerUI *mUI;
 
123
    nativeWindow mNativeWindow;
 
124
    PRUint32     mChromeFlags;
 
125
    PRBool       mContinueModalLoop;
 
126
    PRBool       mSizeSet;
 
127
    PRBool       mIsChromeContainer;
 
128
    PRBool       mIsURIContentListener;
 
129
 
 
130
    nsCString    mRole;
 
131
    nsCOMPtr<nsIWebBrowser> mWebBrowser;
 
132
    nsCOMPtr<nsIWebBrowserChrome> mDependentParent; // opener (for dependent windows only)
 
133
};
 
134
 
 
135
 
 
136
class GeckoContainerUI
 
137
{
 
138
protected:
 
139
    PRBool mBusy;
 
140
 
 
141
public:
 
142
    GeckoContainerUI() :
 
143
        mBusy(PR_FALSE)
 
144
    {
 
145
    }
 
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);
 
178
};
 
179
 
 
180
#endif /* __WebBrowserChrome__ */