meow-7.2.2
Richard Linden 2010-05-27 18:28:31 -07:00
commit 8ec4f45daa
3 changed files with 38 additions and 55 deletions

View File

@ -2795,42 +2795,6 @@ bool LLViewerMediaImpl::isPlayable() const
return false;
}
////////////////////////////////////////////////////////////////////////////////
// static
bool LLViewerMediaImpl::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 LLViewerMediaImpl::clickLinkWithTarget(const std::string& url, const S32& target_type )
{
if (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 LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginClassMediaOwner::EMediaEvent event)
{
@ -2851,21 +2815,23 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
std::string url = plugin->getClickURL();
U32 target_type = plugin->getClickTargetType();
// is there is a target specified for the link?
if (target_type == LLPluginClassMedia::TARGET_EXTERNAL ||
target_type == LLPluginClassMedia::TARGET_BLANK )
switch (target_type)
{
if (gSavedSettings.getBOOL("UseExternalBrowser"))
{
LLSD payload;
payload["url"] = url;
payload["target_type"] = LLSD::Integer(target_type);
LLNotificationsUtil::add( "WebLaunchExternalTarget", LLSD(), payload, onClickLinkExternalTarget);
}
else
{
clickLinkWithTarget(url, target_type);
}
case LLPluginClassMedia::TARGET_EXTERNAL:
// force url to external browser
LLWeb::loadURLExternal(url);
break;
case LLPluginClassMedia::TARGET_BLANK:
// open in SL media browser or external browser based on user pref
LLWeb::loadURL(url);
break;
case LLPluginClassMedia::TARGET_NONE:
// ignore this click and let media plugin handle it
break;
case LLPluginClassMedia::TARGET_OTHER:
LL_WARNS("LinkTarget") << "Unsupported link target type" << LL_ENDL;
break;
default: break;
}
};
break;

View File

@ -391,8 +391,6 @@ private:
bool shouldShowBasedOnClass() const;
static bool isObjectAttachedToAnotherAvatar(LLVOVolume *obj);
static bool isObjectInAgentParcel(LLVOVolume *obj);
static bool onClickLinkExternalTarget( const LLSD&, const LLSD& );
static void clickLinkWithTarget(const std::string& url, const S32& target_type );
private:
// a single media url with some data and an impl.

View File

@ -54,6 +54,10 @@
#include "llviewerparcelmgr.h"
#include "llviewerregion.h"
#include "llviewerwindow.h"
#include "llnotificationsutil.h"
bool on_load_url_external_response(const LLSD& notification, const LLSD& response, bool async );
class URLLoader : public LLToastAlertPanel::URLLoader
{
@ -110,11 +114,26 @@ void LLWeb::loadURLExternal(const std::string& url)
// static
void LLWeb::loadURLExternal(const std::string& url, bool async)
{
std::string escaped_url = escapeURL(url);
if (gViewerWindow)
LLSD payload;
payload["url"] = url;
LLNotificationsUtil::add( "WebLaunchExternalTarget", LLSD(), payload, boost::bind(on_load_url_external_response, _1, _2, async));
}
// static
bool on_load_url_external_response(const LLSD& notification, const LLSD& response, bool async )
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if ( 0 == option )
{
gViewerWindow->getWindow()->spawnWebBrowser(escaped_url, async);
LLSD payload = notification["payload"];
std::string url = payload["url"].asString();
std::string escaped_url = LLWeb::escapeURL(url);
if (gViewerWindow)
{
gViewerWindow->getWindow()->spawnWebBrowser(escaped_url, async);
}
}
return false;
}