aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llwebbrowserctrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llwebbrowserctrl.cpp')
-rw-r--r--linden/indra/newview/llwebbrowserctrl.cpp83
1 files changed, 48 insertions, 35 deletions
diff --git a/linden/indra/newview/llwebbrowserctrl.cpp b/linden/indra/newview/llwebbrowserctrl.cpp
index 79f5a21..a9c1ec8 100644
--- a/linden/indra/newview/llwebbrowserctrl.cpp
+++ b/linden/indra/newview/llwebbrowserctrl.cpp
@@ -54,6 +54,8 @@
54const S32 MAX_DIMENSION = 2000; 54const S32 MAX_DIMENSION = 2000;
55const S32 MAX_TEXTURE_DIMENSION = 2048; 55const S32 MAX_TEXTURE_DIMENSION = 2048;
56 56
57static LLRegisterWidget<LLWebBrowserCtrl> r("web_browser");
58
57LLWebBrowserCtrl::LLWebBrowserCtrl( const std::string& name, const LLRect& rect ) : 59LLWebBrowserCtrl::LLWebBrowserCtrl( const std::string& name, const LLRect& rect ) :
58 LLUICtrl( name, rect, FALSE, NULL, NULL ), 60 LLUICtrl( name, rect, FALSE, NULL, NULL ),
59 mTextureDepthBytes( 4 ), 61 mTextureDepthBytes( 4 ),
@@ -68,6 +70,7 @@ LLWebBrowserCtrl::LLWebBrowserCtrl( const std::string& name, const LLRect& rect
68 mHomePageUrl( "" ), 70 mHomePageUrl( "" ),
69 mIgnoreUIScale( true ), 71 mIgnoreUIScale( true ),
70 mAlwaysRefresh( false ), 72 mAlwaysRefresh( false ),
73 mExternalUrl( "" ),
71 mMediaSource( 0 ) 74 mMediaSource( 0 )
72{ 75{
73 S32 screen_width = mIgnoreUIScale ? 76 S32 screen_width = mIgnoreUIScale ?
@@ -270,7 +273,7 @@ void LLWebBrowserCtrl::onFocusLost()
270 273
271//////////////////////////////////////////////////////////////////////////////// 274////////////////////////////////////////////////////////////////////////////////
272// 275//
273BOOL LLWebBrowserCtrl::handleKey( KEY key, MASK mask, BOOL called_from_parent ) 276BOOL LLWebBrowserCtrl::handleKeyHere( KEY key, MASK mask )
274{ 277{
275 unsigned long media_key; 278 unsigned long media_key;
276 279
@@ -325,7 +328,7 @@ BOOL LLWebBrowserCtrl::handleKey( KEY key, MASK mask, BOOL called_from_parent )
325 return TRUE; 328 return TRUE;
326} 329}
327 330
328BOOL LLWebBrowserCtrl::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent) 331BOOL LLWebBrowserCtrl::handleUnicodeCharHere(llwchar uni_char)
329{ 332{
330 // only accept 'printable' characters, sigh... 333 // only accept 'printable' characters, sigh...
331 if (uni_char >= 32 // discard 'control' characters 334 if (uni_char >= 32 // discard 'control' characters
@@ -409,8 +412,7 @@ bool LLWebBrowserCtrl::canNavigateForward()
409 412
410//////////////////////////////////////////////////////////////////////////////// 413////////////////////////////////////////////////////////////////////////////////
411// 414//
412 415bool LLWebBrowserCtrl::set404RedirectUrl( std::string redirect_url )
413bool LLWebBrowserCtrl::set404RedirectUrl( std::string redirect_url )
414{ 416{
415 if(mMediaSource) 417 if(mMediaSource)
416 return mMediaSource->set404RedirectUrl( redirect_url ); 418 return mMediaSource->set404RedirectUrl( redirect_url );
@@ -432,31 +434,19 @@ bool LLWebBrowserCtrl::clr404RedirectUrl()
432// 434//
433void LLWebBrowserCtrl::navigateTo( std::string urlIn ) 435void LLWebBrowserCtrl::navigateTo( std::string urlIn )
434{ 436{
435 const std::string protocol( "secondlife://" ); 437 // don't browse to anything that starts with secondlife:// or sl://
436 const std::string protocol2( "sl://" ); 438 const std::string protocol1 = "secondlife://";
437 439 const std::string protocol2 = "sl://";
438 // don't browse to anything that starts with secondlife:// 440 if ((LLString::compareInsensitive(urlIn.substr(0, protocol1.length()).c_str(), protocol1.c_str()) == 0) ||
439 if ( urlIn.length() >= protocol.length() ) 441 (LLString::compareInsensitive(urlIn.substr(0, protocol2.length()).c_str(), protocol2.c_str()) == 0))
440 {
441 if ( LLString::compareInsensitive( urlIn.substr( 0, protocol.length() ).c_str(), protocol.c_str() ) != 0 )
442 {
443 if (mMediaSource)
444 mMediaSource->navigateTo(urlIn);
445 }
446 }
447 else if ( urlIn.length() >= protocol2.length() )
448 {
449 if ( LLString::compareInsensitive( urlIn.substr( 0, protocol2.length() ).c_str(), protocol2.c_str() ) != 0 )
450 {
451 if (mMediaSource)
452 mMediaSource->navigateTo(urlIn);
453 }
454 }
455 else
456 { 442 {
457 if (mMediaSource) 443 // TODO: Print out/log this attempt?
458 mMediaSource->navigateTo(urlIn); 444 // llinfos << "Rejecting attempt to load restricted website :" << urlIn << llendl;
445 return;
459 } 446 }
447
448 if (mMediaSource)
449 mMediaSource->navigateTo(urlIn);
460} 450}
461 451
462 452
@@ -535,9 +525,6 @@ std::string LLWebBrowserCtrl::getHomePageUrl()
535// 525//
536void LLWebBrowserCtrl::draw() 526void LLWebBrowserCtrl::draw()
537{ 527{
538 if ( ! getVisible() )
539 return;
540
541 if ( ! mWebBrowserImage ) 528 if ( ! mWebBrowserImage )
542 return; 529 return;
543 530
@@ -601,7 +588,7 @@ void LLWebBrowserCtrl::draw()
601 if ( mBorder->getVisible() ) 588 if ( mBorder->getVisible() )
602 mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus( this ) ); 589 mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus( this ) );
603 590
604 591
605 LLUICtrl::draw(); 592 LLUICtrl::draw();
606} 593}
607 594
@@ -677,9 +664,32 @@ void LLWebBrowserCtrl::onMediaContentsChange( const EventType& event_in )
677} 664}
678 665
679//////////////////////////////////////////////////////////////////////////////// 666////////////////////////////////////////////////////////////////////////////////
667// static
668void LLWebBrowserCtrl::onClickLinkExternalTarget( S32 option, void* userdata )
669{
670 if ( 0 == option )
671 {
672 // open in external browser because we don't support
673 // creation of our own secondary browser windows
674 LLWeb::loadURLExternal( ((LLWebBrowserCtrl*)userdata)->mExternalUrl );
675 };
676}
677
678////////////////////////////////////////////////////////////////////////////////
680// virtual 679// virtual
681void LLWebBrowserCtrl::onClickLinkHref( const EventType& eventIn ) 680void LLWebBrowserCtrl::onClickLinkHref( const EventType& eventIn )
682{ 681{
682 // if there is a value for the target (passed in stringValueEx)
683 if ( eventIn.getStringValueEx().length() )
684 {
685 // if the target = "_new"
686 if ( eventIn.getStringValueEx() == "_external" ) {
687 mExternalUrl = eventIn.getStringValue();
688 gViewerWindow->alertXml( "WebLaunchExternalTarget", onClickLinkExternalTarget, (void*)this );
689 return;
690 };
691 };
692
683 const std::string protocol1( "http://" ); 693 const std::string protocol1( "http://" );
684 const std::string protocol2( "https://" ); 694 const std::string protocol2( "https://" );
685 if( mOpenLinksInExternalBrowser ) 695 if( mOpenLinksInExternalBrowser )
@@ -704,14 +714,18 @@ void LLWebBrowserCtrl::onClickLinkHref( const EventType& eventIn )
704 // If we spawn a new LLFloaterHTML, assume we want it to 714 // If we spawn a new LLFloaterHTML, assume we want it to
705 // follow this LLWebBrowserCtrl's setting for whether or 715 // follow this LLWebBrowserCtrl's setting for whether or
706 // not to open secondlife:///app/ links. JC. 716 // not to open secondlife:///app/ links. JC.
707 bool open_links_externally = false; 717 const bool open_links_externally = false;
708 LLFloaterHtml::getInstance()->show( eventIn.getStringValue(), "Second Life Browser", mOpenAppSLURLs, open_links_externally); 718 LLFloaterHtml::getInstance()->show(
719 eventIn.getStringValue(),
720 "Second Life Browser",
721 open_links_externally,
722 mOpenAppSLURLs);
709 }; 723 };
710 }; 724 };
711 }; 725 };
712 726
713 // chain this event on to observers of an instance of LLWebBrowserCtrl 727 // chain this event on to observers of an instance of LLWebBrowserCtrl
714 LLWebBrowserCtrlEvent event( eventIn.getStringValue() ); 728 LLWebBrowserCtrlEvent event( eventIn.getStringValue(), eventIn.getStringValueEx() );
715 mEventEmitter.update( &LLWebBrowserCtrlObserver::onClickLinkHref, event ); 729 mEventEmitter.update( &LLWebBrowserCtrlObserver::onClickLinkHref, event );
716} 730}
717 731
@@ -735,7 +749,6 @@ void LLWebBrowserCtrl::onClickLinkNoFollow( const EventType& eventIn )
735 mEventEmitter.update( &LLWebBrowserCtrlObserver::onClickLinkNoFollow, event ); 749 mEventEmitter.update( &LLWebBrowserCtrlObserver::onClickLinkNoFollow, event );
736} 750}
737 751
738
739//////////////////////////////////////////////////////////////////////////////// 752////////////////////////////////////////////////////////////////////////////////
740// 753//
741LLWebBrowserTexture::LLWebBrowserTexture( S32 width, S32 height, LLWebBrowserCtrl* browserCtrl, LLMediaBase *media_source ) : 754LLWebBrowserTexture::LLWebBrowserTexture( S32 width, S32 height, LLWebBrowserCtrl* browserCtrl, LLMediaBase *media_source ) :