aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llwebbrowserctrl.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llwebbrowserctrl.h325
1 files changed, 0 insertions, 325 deletions
diff --git a/linden/indra/newview/llwebbrowserctrl.h b/linden/indra/newview/llwebbrowserctrl.h
deleted file mode 100644
index 79b8942..0000000
--- a/linden/indra/newview/llwebbrowserctrl.h
+++ /dev/null
@@ -1,325 +0,0 @@
1/**
2 * @file llwebbrowserctrl.h
3 * @brief Web browser UI control
4 *
5 * $LicenseInfo:firstyear=2006&license=viewergpl$
6 *
7 * Copyright (c) 2006-2009, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 */
32
33#ifndef LL_LLWEBBROWSERCTRL_H
34#define LL_LLWEBBROWSERCTRL_H
35
36////////////////////////////////////////////////////////////////////////////////
37// data class that is passed with an event
38class LLWebBrowserCtrlEvent
39{
40 public:
41 LLWebBrowserCtrlEvent()
42 {
43 };
44
45 LLWebBrowserCtrlEvent( int intValIn ) :
46 mIntVal( intValIn )
47 {
48 };
49
50 LLWebBrowserCtrlEvent( std::string stringValIn ) :
51 mIntVal(-1),
52 mStringVal( stringValIn )
53 {
54 };
55
56 LLWebBrowserCtrlEvent( std::string stringValIn, std::string stringValExIn ) :
57 mIntVal(-1),
58 mStringVal( stringValIn ),
59 mStringValEx( stringValExIn )
60 {
61 };
62
63 virtual ~LLWebBrowserCtrlEvent()
64 {
65 };
66
67 int getIntValue() const
68 {
69 return mIntVal;
70 };
71
72 std::string getStringValue() const
73 {
74 return mStringVal;
75 };
76
77 std::string getStringValueEx() const
78 {
79 return mStringValEx;
80 };
81
82 private:
83 int mIntVal;
84 std::string mStringVal;
85 std::string mStringValEx;
86};
87
88////////////////////////////////////////////////////////////////////////////////
89// Override these methods to observe web browser control events
90// (they are chained and fired after observing LLMozLibEvents)
91class LLWebBrowserCtrlObserver
92{
93 public:
94 virtual ~LLWebBrowserCtrlObserver() { };
95
96 typedef LLWebBrowserCtrlEvent EventType;
97 virtual void onNavigateBegin( const EventType& eventIn ) { };
98 virtual void onNavigateComplete( const EventType& eventIn ) { };
99 virtual void onUpdateProgress( const EventType& eventIn ) { };
100 virtual void onStatusTextChange( const EventType& eventIn ) { };
101 virtual void onLocationChange( const EventType& eventIn ) { };
102 virtual void onClickLinkHref( const EventType& eventIn ) { };
103 virtual void onClickLinkNoFollow( const EventType& eventIn ) { };
104};
105
106#include "lluictrl.h"
107#include "llframetimer.h"
108#include "lldynamictexture.h"
109#include "llmediaobserver.h"
110
111class LLViewBorder;
112class LLWebBrowserTexture;
113
114///////////////////////////////////////////////////////////////////////////////
115// manages the process of storing and emitting events that the consumer
116// of the embedding class can observe
117template< class T >
118class LLWebBrowserCtrlEventEmitter
119{
120 public:
121 LLWebBrowserCtrlEventEmitter() { };
122 ~LLWebBrowserCtrlEventEmitter() { };
123
124 typedef typename T::EventType EventType;
125 typedef std::list< T* > ObserverContainer;
126 typedef void( T::*observerMethod )( const EventType& );
127
128 ///////////////////////////////////////////////////////////////////////////////
129 //
130 bool addObserver( T* observerIn )
131 {
132 if ( ! observerIn )
133 return false;
134
135 if ( std::find( observers.begin(), observers.end(), observerIn ) != observers.end() )
136 return false;
137
138 observers.push_back( observerIn );
139
140 return true;
141 };
142
143 ///////////////////////////////////////////////////////////////////////////////
144 //
145 bool remObserver( T* observerIn )
146 {
147 if ( ! observerIn )
148 return false;
149
150 observers.remove( observerIn );
151
152 return true;
153 };
154
155 ///////////////////////////////////////////////////////////////////////////////
156 //
157 void update( observerMethod method, const EventType& msgIn )
158 {
159 typename std::list< T* >::iterator iter = observers.begin();
160
161 while( iter != observers.end() )
162 {
163 ( ( *iter )->*method )( msgIn );
164
165 ++iter;
166 };
167 };
168
169 protected:
170 ObserverContainer observers;
171};
172
173class LLUICtrlFactory;
174
175////////////////////////////////////////////////////////////////////////////////
176//
177class LLWebBrowserCtrl :
178 public LLUICtrl,
179 public LLMediaObserver
180{
181 public:
182 LLWebBrowserCtrl( const std::string& name, const LLRect& rect );
183 virtual ~LLWebBrowserCtrl();
184
185 void setBorderVisible( BOOL border_visible );
186
187 // For the tutorial window, we don't want to take focus on clicks,
188 // as the examples include how to move around with the arrow
189 // keys. Thus we keep focus on the app by setting this false.
190 // Defaults to true.
191 void setTakeFocusOnClick( bool take_focus );
192
193 virtual LLXMLNodePtr getXML(bool save_children = true) const;
194 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
195
196 // handle mouse related methods
197 virtual BOOL handleHover( S32 x, S32 y, MASK mask );
198 virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
199 virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
200 virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
201 virtual BOOL handleScrollWheel( S32 x, S32 y, S32 clicks );
202
203 // navigation
204 void navigateTo( std::string urlIn );
205 void navigateBack();
206 void navigateHome();
207 void navigateForward();
208 void navigateToLocalPage( const std::string& subdir, const std::string& filename_in );
209 bool canNavigateBack();
210 bool canNavigateForward();
211 void setOpenInExternalBrowser( bool valIn );
212 void setOpenInInternalBrowser( bool valIn );
213 std::string getCurrentNavUrl();
214
215 // By default, we do not handle "secondlife:///app/" SLURLs, because
216 // those can cause teleports, open windows, etc. We cannot be sure
217 // that each "click" is actually due to a user action, versus
218 // Javascript or some other mechanism. However, we need the search
219 // floater and login page to handle these URLs. Those are safe
220 // because we control the page content. See DEV-9530. JC.
221 void setTrusted( bool valIn );
222
223 void setHomePageUrl( const std::string urlIn );
224 std::string getHomePageUrl();
225
226 // set/clear URL to visit when a 404 page is reached
227 bool set404RedirectUrl( std::string redirect_url );
228 bool clr404RedirectUrl();
229
230 // accessor/mutator for flag that indicates if frequent updates to texture happen
231 bool getFrequentUpdates() { return mFrequentUpdates; };
232 void setFrequentUpdates( bool frequentUpdatesIn ) { mFrequentUpdates = frequentUpdatesIn; };
233
234 void setIgnoreUIScale(bool ignore) { mIgnoreUIScale = ignore; }
235 bool getIgnoreUIScale() { return mIgnoreUIScale; }
236
237 void setAlwaysRefresh(bool refresh) { mAlwaysRefresh = refresh; }
238 bool getAlwaysRefresh() { return mAlwaysRefresh; }
239
240 void setForceUpdate(bool force_update) { mForceUpdate = force_update; }
241 bool getForceUpdate() { return mForceUpdate; }
242
243 bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue );
244
245
246 // over-rides
247 virtual BOOL handleKeyHere( KEY key, MASK mask);
248 virtual BOOL handleUnicodeCharHere(llwchar uni_char);
249 virtual void reshape( S32 width, S32 height, BOOL called_from_parent = TRUE);
250 virtual void draw();
251 virtual void onVisibilityChange ( BOOL curVisibilityIn );
252
253 // focus overrides
254 void onFocusLost();
255 void onFocusReceived();
256
257 // observer interface
258 bool addObserver( LLWebBrowserCtrlObserver* subjectIn );
259 bool remObserver( LLWebBrowserCtrlObserver* subjectIn );
260
261 // LLMozlib observer overrides
262 virtual void onNavigateBegin( const EventType& eventIn );
263 virtual void onNavigateComplete( const EventType& eventIn );
264 virtual void onUpdateProgress( const EventType& eventIn );
265 virtual void onStatusTextChange( const EventType& eventIn );
266 virtual void onLocationChange( const EventType& eventIn );
267 virtual void onClickLinkHref( const EventType& eventIn );
268 virtual void onClickLinkNoFollow( const EventType& eventIn );
269 virtual void onMediaContentsChange( const EventType& event_in );
270
271 protected:
272 void convertInputCoords(S32& x, S32& y);
273
274 private:
275 static bool onClickLinkExternalTarget( const LLSD&, const LLSD& );
276
277 LLWebBrowserCtrlEventEmitter< LLWebBrowserCtrlObserver > mEventEmitter;
278 const S32 mTextureDepthBytes;
279 int mEmbeddedBrowserWindowId;
280 LLWebBrowserTexture* mWebBrowserImage;
281 LLViewBorder* mBorder;
282 bool mFrequentUpdates;
283 bool mForceUpdate;
284 bool mOpenLinksInExternalBrowser;
285 bool mOpenLinksInInternalBrowser;
286 bool mTrusted;
287 std::string mHomePageUrl;
288 std::string mExternalUrl;
289 std::string mCurrentNavUrl;
290 bool mIgnoreUIScale;
291 bool mAlwaysRefresh;
292 LLMediaBase* mMediaSource;
293 bool mTakeFocusOnClick;
294};
295
296////////////////////////////////////////////////////////////////////////////////
297//
298class LLWebBrowserTexture : public LLDynamicTexture
299{
300 public:
301 LLWebBrowserTexture( S32 width, S32 height, LLWebBrowserCtrl* browserCtrl, LLMediaBase *media_source );
302 virtual ~LLWebBrowserTexture();
303
304 virtual BOOL needsRender();
305 virtual void preRender( BOOL clear_depth = TRUE ) {};
306 virtual void postRender( BOOL success ) {};
307 virtual BOOL render();
308
309 S32 getBrowserWidth();
310 S32 getBrowserHeight();
311 void setNeedsUpdate();
312
313 void resize( S32 new_width, S32 new_height );
314
315 protected:
316 S32 mBrowserWidth;
317 S32 mBrowserHeight;
318 S32 mLastBrowserDepth;
319 bool mNeedsUpdate;
320 LLFrameTimer mElapsedTime;
321 LLWebBrowserCtrl* mWebBrowserCtrl;
322 LLMediaBase *mMediaSource;
323};
324
325#endif // LL_LLWEBBROWSERCTRL_H