From 1d3c59f29c2845ae326830b75f5da5e96ca46139 Mon Sep 17 00:00:00 2001
From: andreykproductengine <akleshchev@productengine.com>
Date: Thu, 23 Jul 2015 19:15:07 +0300
Subject: [PATCH] MAINT-5398 FIXED [BetaBreakers] TOS additional policy links
 cannot be scrolled or closed once opened

---
 indra/llplugin/llpluginclassmedia.cpp | 8 ++++++++
 indra/llplugin/llpluginclassmedia.h   | 9 +++++++++
 indra/newview/llfloatertos.cpp        | 6 ++++++
 indra/newview/llmediactrl.cpp         | 4 ++--
 4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp
index 52626b0302f..4bfd0de81ee 100755
--- a/indra/llplugin/llpluginclassmedia.cpp
+++ b/indra/llplugin/llpluginclassmedia.cpp
@@ -146,6 +146,8 @@ void LLPluginClassMedia::reset()
 	mClickTarget.clear();
 	mClickUUID.clear();
 	mStatusCode = 0;
+
+	mClickEnforceTarget = false;
 	
 	// media_time class
 	mCurrentTime = 0.0f;
@@ -1358,6 +1360,12 @@ void LLPluginClassMedia::addCertificateFilePath(const std::string& path)
 	sendMessage(message);
 }
 
+void LLPluginClassMedia::setOverrideClickTarget(const std::string &target)
+{
+	mClickEnforceTarget = true;
+	mOverrideClickTarget = target;
+}
+
 void LLPluginClassMedia::crashPlugin()
 {
 	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "crash");
diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h
index 5fe8254331a..96d577f43c6 100755
--- a/indra/llplugin/llpluginclassmedia.h
+++ b/indra/llplugin/llpluginclassmedia.h
@@ -249,6 +249,13 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner
 	// This is valid during MEDIA_EVENT_CLICK_LINK_HREF and MEDIA_EVENT_GEOMETRY_CHANGE
 	std::string getClickUUID() const { return mClickUUID; };
 
+	// mClickTarget is received from message and governs how link will be opened
+	// use this to enforce your own way of opening links inside plugins
+	void setOverrideClickTarget(const std::string &target);
+	void resetOverrideClickTarget() { mClickEnforceTarget = false; };
+	bool isOverrideClickTarget() const { return mClickEnforceTarget; }
+	std::string getOverrideClickTarget() const { return mOverrideClickTarget; };
+
 	// These are valid during MEDIA_EVENT_DEBUG_MESSAGE
 	std::string getDebugMessageText() const { return mDebugMessageText; };
 	std::string getDebugMessageLevel() const { return mDebugMessageLevel; };
@@ -404,6 +411,8 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner
 	std::string		mClickNavType;
 	std::string		mClickTarget;
 	std::string		mClickUUID;
+	bool			mClickEnforceTarget;
+	std::string		mOverrideClickTarget;
 	std::string		mDebugMessageText;
 	std::string		mDebugMessageLevel;
 	S32				mGeometryX;
diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp
index c1c21c593e5..ae33acb8420 100755
--- a/indra/newview/llfloatertos.cpp
+++ b/indra/newview/llfloatertos.cpp
@@ -141,6 +141,12 @@ BOOL LLFloaterTOS::postBuild()
 		// Don't use the start_url parameter for this browser instance -- it may finish loading before we get to add our observer.
 		// Store the URL separately and navigate here instead.
 		web_browser->navigateTo( getString( "loading_url" ) );
+		LLPluginClassMedia* media_plugin = web_browser->getMediaPlugin();
+		if (media_plugin)
+		{
+			// All links from tos_html should be opened in external browser
+			media_plugin->setOverrideClickTarget("_external");
+		}
 	}
 
 	return TRUE;
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index cd3d0cdbf2c..73faed7ef50 100755
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -983,11 +983,11 @@ void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event)
 
 		case MEDIA_EVENT_CLICK_LINK_HREF:
 		{
-			LL_DEBUGS("Media") <<  "Media event:  MEDIA_EVENT_CLICK_LINK_HREF, target is \"" << self->getClickTarget() << "\", uri is " << self->getClickURL() << LL_ENDL;
 			// retrieve the event parameters
 			std::string url = self->getClickURL();
-			std::string target = self->getClickTarget();
+			std::string target = self->isOverrideClickTarget() ? self->getOverrideClickTarget() : self->getClickTarget();
 			std::string uuid = self->getClickUUID();
+			LL_DEBUGS("Media") << "Media event:  MEDIA_EVENT_CLICK_LINK_HREF, target is \"" << target << "\", uri is " << url << LL_ENDL;
 
 			LLNotification::Params notify_params;
 			notify_params.name = "PopupAttempt";
-- 
GitLab