diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llwebbrowserctrl.cpp | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/linden/indra/newview/llwebbrowserctrl.cpp b/linden/indra/newview/llwebbrowserctrl.cpp index 7a9194c..89cb62b 100644 --- a/linden/indra/newview/llwebbrowserctrl.cpp +++ b/linden/indra/newview/llwebbrowserctrl.cpp | |||
@@ -17,7 +17,8 @@ | |||
17 | * There are special exceptions to the terms and conditions of the GPL as | 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 | 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 | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -35,7 +36,7 @@ | |||
35 | #include "llwebbrowserctrl.h" | 36 | #include "llwebbrowserctrl.h" |
36 | 37 | ||
37 | // viewer includes | 38 | // viewer includes |
38 | #include "llfloaterhtmlhelp.h" | 39 | #include "llfloaterhtml.h" |
39 | #include "llfloaterworldmap.h" | 40 | #include "llfloaterworldmap.h" |
40 | #include "lluictrlfactory.h" | 41 | #include "lluictrlfactory.h" |
41 | #include "llurldispatcher.h" | 42 | #include "llurldispatcher.h" |
@@ -43,7 +44,7 @@ | |||
43 | #include "llviewborder.h" | 44 | #include "llviewborder.h" |
44 | #include "llviewercontrol.h" | 45 | #include "llviewercontrol.h" |
45 | #include "llviewerwindow.h" | 46 | #include "llviewerwindow.h" |
46 | #include "llnotify.h" | 47 | #include "llnotifications.h" |
47 | #include "llweb.h" | 48 | #include "llweb.h" |
48 | #include "llrender.h" | 49 | #include "llrender.h" |
49 | 50 | ||
@@ -69,7 +70,7 @@ LLWebBrowserCtrl::LLWebBrowserCtrl( const std::string& name, const LLRect& rect | |||
69 | mForceUpdate( false ), | 70 | mForceUpdate( false ), |
70 | mOpenLinksInExternalBrowser( false ), | 71 | mOpenLinksInExternalBrowser( false ), |
71 | mOpenLinksInInternalBrowser( false ), | 72 | mOpenLinksInInternalBrowser( false ), |
72 | mOpenAppSLURLs( false ), | 73 | mTrusted( false ), |
73 | mHomePageUrl( "" ), | 74 | mHomePageUrl( "" ), |
74 | mIgnoreUIScale( true ), | 75 | mIgnoreUIScale( true ), |
75 | mAlwaysRefresh( false ), | 76 | mAlwaysRefresh( false ), |
@@ -187,10 +188,10 @@ void LLWebBrowserCtrl::setOpenInInternalBrowser( bool valIn ) | |||
187 | }; | 188 | }; |
188 | 189 | ||
189 | //////////////////////////////////////////////////////////////////////////////// | 190 | //////////////////////////////////////////////////////////////////////////////// |
190 | void LLWebBrowserCtrl::setOpenAppSLURLs( bool valIn ) | 191 | void LLWebBrowserCtrl::setTrusted( bool valIn ) |
191 | { | 192 | { |
192 | mOpenAppSLURLs = valIn; | 193 | mTrusted = valIn; |
193 | }; | 194 | } |
194 | 195 | ||
195 | //////////////////////////////////////////////////////////////////////////////// | 196 | //////////////////////////////////////////////////////////////////////////////// |
196 | // | 197 | // |
@@ -670,16 +671,6 @@ void LLWebBrowserCtrl::onStatusTextChange( const EventType& eventIn ) | |||
670 | // virtual | 671 | // virtual |
671 | void LLWebBrowserCtrl::onLocationChange( const EventType& eventIn ) | 672 | void LLWebBrowserCtrl::onLocationChange( const EventType& eventIn ) |
672 | { | 673 | { |
673 | const LLURI url(eventIn.getStringValue()); | ||
674 | LLSD queryMap(url.queryMap()); | ||
675 | std::string redirect_http_hack = queryMap["redirect-http-hack"].asString(); | ||
676 | if (!redirect_http_hack.empty()) | ||
677 | { | ||
678 | const bool from_external_browser = false; | ||
679 | LLURLDispatcher::dispatch(redirect_http_hack, from_external_browser); | ||
680 | return; | ||
681 | } | ||
682 | |||
683 | // chain this event on to observers of an instance of LLWebBrowserCtrl | 674 | // chain this event on to observers of an instance of LLWebBrowserCtrl |
684 | LLWebBrowserCtrlEvent event( eventIn.getStringValue() ); | 675 | LLWebBrowserCtrlEvent event( eventIn.getStringValue() ); |
685 | mEventEmitter.update( &LLWebBrowserCtrlObserver::onLocationChange, event ); | 676 | mEventEmitter.update( &LLWebBrowserCtrlObserver::onLocationChange, event ); |
@@ -698,14 +689,16 @@ void LLWebBrowserCtrl::onMediaContentsChange( const EventType& event_in ) | |||
698 | 689 | ||
699 | //////////////////////////////////////////////////////////////////////////////// | 690 | //////////////////////////////////////////////////////////////////////////////// |
700 | // static | 691 | // static |
701 | void LLWebBrowserCtrl::onClickLinkExternalTarget( S32 option, void* userdata ) | 692 | bool LLWebBrowserCtrl::onClickLinkExternalTarget(const LLSD& notification, const LLSD& response ) |
702 | { | 693 | { |
694 | S32 option = LLNotification::getSelectedOption(notification, response); | ||
703 | if ( 0 == option ) | 695 | if ( 0 == option ) |
704 | { | 696 | { |
705 | // open in external browser because we don't support | 697 | // open in external browser because we don't support |
706 | // creation of our own secondary browser windows | 698 | // creation of our own secondary browser windows |
707 | LLWeb::loadURLExternal( ((LLWebBrowserCtrl*)userdata)->mExternalUrl ); | 699 | LLWeb::loadURLExternal( notification["payload"]["external_url"].asString() ); |
708 | }; | 700 | } |
701 | return false; | ||
709 | } | 702 | } |
710 | 703 | ||
711 | //////////////////////////////////////////////////////////////////////////////// | 704 | //////////////////////////////////////////////////////////////////////////////// |
@@ -716,12 +709,15 @@ void LLWebBrowserCtrl::onClickLinkHref( const EventType& eventIn ) | |||
716 | if ( eventIn.getStringValueEx().length() ) | 709 | if ( eventIn.getStringValueEx().length() ) |
717 | { | 710 | { |
718 | // if the target = "_new" | 711 | // if the target = "_new" |
719 | if ( eventIn.getStringValueEx() == "_external" ) { | 712 | if ( eventIn.getStringValueEx() == "_external" ) |
713 | { | ||
720 | mExternalUrl = eventIn.getStringValue(); | 714 | mExternalUrl = eventIn.getStringValue(); |
721 | gViewerWindow->alertXml( "WebLaunchExternalTarget", onClickLinkExternalTarget, (void*)this ); | 715 | LLSD payload; |
716 | payload["external_url"] = mExternalUrl; | ||
717 | LLNotifications::instance().add( "WebLaunchExternalTarget", LLSD(), payload, onClickLinkExternalTarget); | ||
722 | return; | 718 | return; |
723 | }; | 719 | } |
724 | }; | 720 | } |
725 | 721 | ||
726 | const std::string protocol1( "http://" ); | 722 | const std::string protocol1( "http://" ); |
727 | const std::string protocol2( "https://" ); | 723 | const std::string protocol2( "https://" ); |
@@ -733,8 +729,8 @@ void LLWebBrowserCtrl::onClickLinkHref( const EventType& eventIn ) | |||
733 | LLStringUtil::compareInsensitive( eventIn.getStringValue().substr( 0, protocol2.length() ), protocol2 ) == 0 ) | 729 | LLStringUtil::compareInsensitive( eventIn.getStringValue().substr( 0, protocol2.length() ), protocol2 ) == 0 ) |
734 | { | 730 | { |
735 | LLWeb::loadURLExternal( eventIn.getStringValue() ); | 731 | LLWeb::loadURLExternal( eventIn.getStringValue() ); |
736 | }; | 732 | } |
737 | }; | 733 | } |
738 | } | 734 | } |
739 | else | 735 | else |
740 | if( mOpenLinksInInternalBrowser ) | 736 | if( mOpenLinksInInternalBrowser ) |
@@ -744,13 +740,18 @@ void LLWebBrowserCtrl::onClickLinkHref( const EventType& eventIn ) | |||
744 | if ( LLStringUtil::compareInsensitive( eventIn.getStringValue().substr( 0, protocol1.length() ), protocol1 ) == 0 || | 740 | if ( LLStringUtil::compareInsensitive( eventIn.getStringValue().substr( 0, protocol1.length() ), protocol1 ) == 0 || |
745 | LLStringUtil::compareInsensitive( eventIn.getStringValue().substr( 0, protocol2.length() ), protocol2 ) == 0 ) | 741 | LLStringUtil::compareInsensitive( eventIn.getStringValue().substr( 0, protocol2.length() ), protocol2 ) == 0 ) |
746 | { | 742 | { |
747 | // If we spawn a new LLFloaterMediaBrowser, assume we want it to | 743 | // If we spawn a new LLFloaterHTML, assume we want it to |
748 | // follow this LLWebBrowserCtrl's setting for whether or | 744 | // follow this LLWebBrowserCtrl's trust for whether or |
749 | // not to open secondlife:///app/ links. JC. | 745 | // not to open secondlife:///app/ links. JC. |
750 | LLFloaterMediaBrowser::showInstance(eventIn.getStringValue()); | 746 | const bool open_links_externally = false; |
751 | }; | 747 | LLFloaterHtml::getInstance()->show( |
752 | }; | 748 | eventIn.getStringValue(), |
753 | }; | 749 | "Second Life Browser", |
750 | open_links_externally, | ||
751 | mTrusted); | ||
752 | } | ||
753 | } | ||
754 | } | ||
754 | 755 | ||
755 | // chain this event on to observers of an instance of LLWebBrowserCtrl | 756 | // chain this event on to observers of an instance of LLWebBrowserCtrl |
756 | LLWebBrowserCtrlEvent event( eventIn.getStringValue(), eventIn.getStringValueEx() ); | 757 | LLWebBrowserCtrlEvent event( eventIn.getStringValue(), eventIn.getStringValueEx() ); |
@@ -763,16 +764,14 @@ void LLWebBrowserCtrl::onClickLinkNoFollow( const EventType& eventIn ) | |||
763 | { | 764 | { |
764 | std::string url = eventIn.getStringValue(); | 765 | std::string url = eventIn.getStringValue(); |
765 | if (LLURLDispatcher::isSLURLCommand(url) | 766 | if (LLURLDispatcher::isSLURLCommand(url) |
766 | && !mOpenAppSLURLs) | 767 | && !mTrusted) |
767 | { | 768 | { |
768 | // block handling of this secondlife:///app/ URL | 769 | // block handling of this secondlife:///app/ URL |
769 | LLNotifyBox::showXml("UnableToOpenCommandURL"); | 770 | LLNotifications::instance().add("UnableToOpenCommandURL"); |
770 | |||
771 | return; | 771 | return; |
772 | } | 772 | } |
773 | 773 | ||
774 | const bool from_external_browser = false; | 774 | LLURLDispatcher::dispatch(url, this, mTrusted); |
775 | LLURLDispatcher::dispatch(url, from_external_browser); | ||
776 | 775 | ||
777 | // chain this event on to observers of an instance of LLWebBrowserCtrl | 776 | // chain this event on to observers of an instance of LLWebBrowserCtrl |
778 | LLWebBrowserCtrlEvent event( eventIn.getStringValue() ); | 777 | LLWebBrowserCtrlEvent event( eventIn.getStringValue() ); |