From 420430b8f59902a65cd1847ea8b596f82a283e6a Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Fri, 22 Jan 2010 14:00:34 -0800 Subject: PARTIAL FIX EXT-3491: only bring up "external browser"notification if target is external or pref is set Review #86 This changes the logic to bring up the notification "Do you want to open your Web browser to view this content?" only if either the target is _external, or the user pref says to. Otherwise it avoids the notification. --- indra/newview/llmediactrl.cpp | 109 ++++++++++++++++++++++-------------------- indra/newview/llmediactrl.h | 1 + 2 files changed, 59 insertions(+), 51 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index 87ebce1d34..d464862eed 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -869,38 +869,6 @@ void LLMediaCtrl::convertInputCoords(S32& x, S32& y) }; } -//////////////////////////////////////////////////////////////////////////////// -// static -bool LLMediaCtrl::onClickLinkExternalTarget(const LLSD& notification, const LLSD& response ) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if ( 0 == option ) - { - LLSD payload = notification["payload"]; - std::string url = payload["url"].asString(); - S32 target_type = payload["target_type"].asInteger(); - - switch (target_type) - { - case LLPluginClassMedia::TARGET_EXTERNAL: - // load target in an external browser - LLWeb::loadURLExternal(url); - break; - - case LLPluginClassMedia::TARGET_BLANK: - // load target in the user's preferred browser - LLWeb::loadURL(url); - break; - - default: - // unsupported link target - shouldn't happen - LL_WARNS("LinkTarget") << "Unsupported link target type" << LL_ENDL; - break; - } - } - return false; -} - //////////////////////////////////////////////////////////////////////////////// // inherited from LLViewerMediaObserver //virtual @@ -1014,43 +982,82 @@ void LLMediaCtrl::onClickLinkHref( LLPluginClassMedia* self ) U32 target_type = self->getClickTargetType(); // is there is a target specified for the link? - if (target_type == LLPluginClassMedia::TARGET_EXTERNAL || - target_type == LLPluginClassMedia::TARGET_BLANK) + if (gSavedSettings.getBOOL("UseExternalBrowser") || target_type == LLPluginClassMedia::TARGET_EXTERNAL) { LLSD payload; payload["url"] = url; payload["target_type"] = LLSD::Integer(target_type); LLNotificationsUtil::add( "WebLaunchExternalTarget", LLSD(), payload, onClickLinkExternalTarget); - return; } - - const std::string protocol1( "http://" ); - const std::string protocol2( "https://" ); - if( mOpenLinksInExternalBrowser ) + else if (target_type == LLPluginClassMedia::TARGET_BLANK) { - if ( !url.empty() ) + clickLinkWithTarget(url, target_type); + } + else { + const std::string protocol1( "http://" ); + const std::string protocol2( "https://" ); + if( mOpenLinksInExternalBrowser ) { - if ( LLStringUtil::compareInsensitive( url.substr( 0, protocol1.length() ), protocol1 ) == 0 || - LLStringUtil::compareInsensitive( url.substr( 0, protocol2.length() ), protocol2 ) == 0 ) + if ( !url.empty() ) { - LLWeb::loadURLExternal( url ); + if ( LLStringUtil::compareInsensitive( url.substr( 0, protocol1.length() ), protocol1 ) == 0 || + LLStringUtil::compareInsensitive( url.substr( 0, protocol2.length() ), protocol2 ) == 0 ) + { + LLWeb::loadURLExternal( url ); + } } } - } - else - if( mOpenLinksInInternalBrowser ) - { - if ( !url.empty() ) + else + if( mOpenLinksInInternalBrowser ) { - if ( LLStringUtil::compareInsensitive( url.substr( 0, protocol1.length() ), protocol1 ) == 0 || - LLStringUtil::compareInsensitive( url.substr( 0, protocol2.length() ), protocol2 ) == 0 ) + if ( !url.empty() ) { - llwarns << "Dead, unimplemented path that we used to send to the built-in browser long ago." << llendl; + if ( LLStringUtil::compareInsensitive( url.substr( 0, protocol1.length() ), protocol1 ) == 0 || + LLStringUtil::compareInsensitive( url.substr( 0, protocol2.length() ), protocol2 ) == 0 ) + { + llwarns << "Dead, unimplemented path that we used to send to the built-in browser long ago." << llendl; + } } } } } +//////////////////////////////////////////////////////////////////////////////// +// static +bool LLMediaCtrl::onClickLinkExternalTarget(const LLSD& notification, const LLSD& response ) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if ( 0 == option ) + { + LLSD payload = notification["payload"]; + std::string url = payload["url"].asString(); + S32 target_type = payload["target_type"].asInteger(); + clickLinkWithTarget(url, target_type); + } + return false; +} + + +//////////////////////////////////////////////////////////////////////////////// +// static +void LLMediaCtrl::clickLinkWithTarget(const std::string& url, const S32& target_type ) +{ + if (gSavedSettings.getBOOL("UseExternalBrowser") || target_type == LLPluginClassMedia::TARGET_EXTERNAL) + { + // load target in an external browser + LLWeb::loadURLExternal(url); + } + else if (target_type == LLPluginClassMedia::TARGET_BLANK) + { + // load target in the user's preferred browser + LLWeb::loadURL(url); + } + else { + // unsupported link target - shouldn't happen + LL_WARNS("LinkTarget") << "Unsupported link target type" << LL_ENDL; + } +} + //////////////////////////////////////////////////////////////////////////////// // void LLMediaCtrl::onClickLinkNoFollow( LLPluginClassMedia* self ) diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h index b0aca3cfa4..60e0c4073b 100644 --- a/indra/newview/llmediactrl.h +++ b/indra/newview/llmediactrl.h @@ -172,6 +172,7 @@ public: private: void onVisibilityChange ( const LLSD& new_visibility ); static bool onClickLinkExternalTarget( const LLSD&, const LLSD& ); + static void clickLinkWithTarget(const std::string& url, const S32& target_type ); const S32 mTextureDepthBytes; LLUUID mMediaTextureID; -- cgit v1.2.3 From 5a83247f038e327465bf88127f60750306507ed3 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Fri, 22 Jan 2010 14:03:13 -0800 Subject: Fix assert in lldictionary as used by llfoldertype Review #88 This assert might be valid in general, but LLFolderType has a valid reason for getting "not found" --- indra/llcommon/lldictionary.h | 9 +++++++-- indra/llcommon/llfoldertype.cpp | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/lldictionary.h b/indra/llcommon/lldictionary.h index 95178b41e7..4a2bfb9f3f 100644 --- a/indra/llcommon/lldictionary.h +++ b/indra/llcommon/lldictionary.h @@ -76,11 +76,16 @@ public: return dictionary_iter->first; } } - llassert(false); - return Index(-1); + return notFound(); } protected: + virtual Index notFound() const + { + // default is to assert + llassert(false); + return Index(-1); + } void addEntry(Index index, Entry *entry) { if (lookup(index)) diff --git a/indra/llcommon/llfoldertype.cpp b/indra/llcommon/llfoldertype.cpp index 079e670b1a..2610fe9e6a 100644 --- a/indra/llcommon/llfoldertype.cpp +++ b/indra/llcommon/llfoldertype.cpp @@ -59,6 +59,11 @@ class LLFolderDictionary : public LLSingleton, { public: LLFolderDictionary(); +protected: + virtual LLFolderType::EType notFound() const + { + return LLFolderType::FT_NONE; + } }; LLFolderDictionary::LLFolderDictionary() -- cgit v1.2.3