From 236b3b9f842c86e1f176068ab70b82f83874e2ab Mon Sep 17 00:00:00 2001
From: callum_linden <none@none>
Date: Thu, 3 Sep 2015 18:16:46 -0700
Subject: [PATCH] support for external links and location_changed messages

---
 autobuild.xml                                 | 10 ++---
 indra/llplugin/llpluginclassmedia.cpp         |  2 +-
 indra/media_plugins/cef/media_plugin_cef.cpp  | 37 ++++++++++---------
 indra/newview/llmediactrl.cpp                 | 30 ++++++++-------
 .../skins/default/xui/en/menu_login.xml       |  2 +-
 5 files changed, 44 insertions(+), 37 deletions(-)

diff --git a/autobuild.xml b/autobuild.xml
index e0963fecbe1..b9aa26229f5 100755
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -1536,11 +1536,11 @@
             <key>archive</key>
             <map>
               <key>hash</key>
-              <string>6b727137b63a321298cba87863db2147</string>
+              <string>da616a0e8f7ebf6de7ade8fe741e1998</string>
               <key>hash_algorithm</key>
               <string>md5</string>
               <key>url</key>
-              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/llceflib_3p-llceflib/rev/304772/arch/Darwin/installer/llceflib-1.0.1.304772-darwin-304772.tar.bz2</string>
+              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/llceflib_3p-llceflib/rev/304832/arch/Darwin/installer/llceflib-1.0.1.304832-darwin-304832.tar.bz2</string>
             </map>
             <key>name</key>
             <string>darwin</string>
@@ -1550,18 +1550,18 @@
             <key>archive</key>
             <map>
               <key>hash</key>
-              <string>fba9f44aa66b81d41a26df4eed116eb9</string>
+              <string>19d398a3e91eb30edbd9f3e85963210d</string>
               <key>hash_algorithm</key>
               <string>md5</string>
               <key>url</key>
-              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/llceflib_3p-llceflib/rev/304772/arch/CYGWIN/installer/llceflib-1.0.1.304772-windows-304772.tar.bz2</string>
+              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/llceflib_3p-llceflib/rev/304832/arch/CYGWIN/installer/llceflib-1.0.1.304832-windows-304832.tar.bz2</string>
             </map>
             <key>name</key>
             <string>windows</string>
           </map>
         </map>
         <key>version</key>
-        <string>1.0.1.304772</string>
+        <string>1.0.1.304832</string>
       </map>
       <key>llphysicsextensions_source</key>
       <map>
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp
index f0c547c8d1a..5e0902c84d9 100755
--- a/indra/llplugin/llpluginclassmedia.cpp
+++ b/indra/llplugin/llpluginclassmedia.cpp
@@ -1121,7 +1121,7 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)
 		{
 			mClickURL = message.getValue("uri");
 			mClickTarget = message.getValue("target");
-			mClickUUID = message.getValue("uuid");
+			//mClickUUID = message.getValue("uuid");
 			mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_CLICK_LINK_HREF);
 		}
 		else if(message_name == "click_nofollow")
diff --git a/indra/media_plugins/cef/media_plugin_cef.cpp b/indra/media_plugins/cef/media_plugin_cef.cpp
index f51a2715bb6..97364d949a8 100644
--- a/indra/media_plugins/cef/media_plugin_cef.cpp
+++ b/indra/media_plugins/cef/media_plugin_cef.cpp
@@ -63,8 +63,8 @@ class MediaPluginCEF :
 	void onTitleChangeCallback(std::string title);
 	void onLoadStartCallback();
 	void onLoadEndCallback(int httpStatusCode);
-	void onNavigateURLCallback(std::string url);
-	void onExternalTargetLinkCallback(std::string url);
+	void onAddressChangeCallback(std::string url);
+	void onNavigateURLCallback(std::string url, std::string target);
 	bool onHTTPAuthCallback(const std::string host, const std::string realm, std::string& username, std::string& password);
 
 	void postDebugMessage(const std::string& msg);
@@ -157,16 +157,6 @@ void MediaPluginCEF::onPageChangedCallback(unsigned char* pixels, int width, int
 	}
 }
 
-////////////////////////////////////////////////////////////////////////////////
-//
-void MediaPluginCEF::onCustomSchemeURLCallback(std::string url)
-{
-	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "click_nofollow");
-	message.setValue("uri", url);
-	message.setValue("nav_type", "clicked");	// TODO: differentiate between click and navigate to
-	sendMessage(message);
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 //
 void MediaPluginCEF::onConsoleMessageCallback(std::string message, std::string source, int line)
@@ -219,7 +209,7 @@ void MediaPluginCEF::onLoadEndCallback(int httpStatusCode)
 
 ////////////////////////////////////////////////////////////////////////////////
 //
-void MediaPluginCEF::onNavigateURLCallback(std::string url)
+void MediaPluginCEF::onAddressChangeCallback(std::string url)
 {
 	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "location_changed");
 	message.setValue("uri", url);
@@ -227,10 +217,24 @@ void MediaPluginCEF::onNavigateURLCallback(std::string url)
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// triggered when user clicks link with "external" attribute
-void MediaPluginCEF::onExternalTargetLinkCallback(std::string url) 
+//
+void MediaPluginCEF::onNavigateURLCallback(std::string url, std::string target)
 {
+	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "click_href");
+	message.setValue("uri", url);
+	message.setValue("target", target);
+	message.setValue("uuid", "");	// not used right now
+	sendMessage(message);
+}
 
+////////////////////////////////////////////////////////////////////////////////
+//
+void MediaPluginCEF::onCustomSchemeURLCallback(std::string url)
+{
+	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "click_nofollow");
+	message.setValue("uri", url);
+	message.setValue("nav_type", "clicked");	// TODO: differentiate between click and navigate to
+	sendMessage(message);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -354,9 +358,8 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
 				mLLCEFLib->setOnTitleChangeCallback(boost::bind(&MediaPluginCEF::onTitleChangeCallback, this, _1));
 				mLLCEFLib->setOnLoadStartCallback(boost::bind(&MediaPluginCEF::onLoadStartCallback, this));
 				mLLCEFLib->setOnLoadEndCallback(boost::bind(&MediaPluginCEF::onLoadEndCallback, this, _1));
-				mLLCEFLib->setOnNavigateURLCallback(boost::bind(&MediaPluginCEF::onNavigateURLCallback, this, _1));
+				mLLCEFLib->setOnNavigateURLCallback(boost::bind(&MediaPluginCEF::onNavigateURLCallback, this, _1, _2));
 				mLLCEFLib->setOnHTTPAuthCallback(boost::bind(&MediaPluginCEF::onHTTPAuthCallback, this, _1, _2, _3, _4));
-				mLLCEFLib->setOnExternalTargetLinkCallback(boost::bind(&MediaPluginCEF::onExternalTargetLinkCallback, this, _1));
 
 				LLCEFLibSettings settings;
 				settings.inital_width = 1024;
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index d1bb7990158..40d352f9b7e 100755
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -993,19 +993,23 @@ void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event)
 			std::string target = self->getClickTarget();
 			std::string uuid = self->getClickUUID();
 
-			LLNotification::Params notify_params;
-			notify_params.name = "PopupAttempt";
-			notify_params.payload = LLSD().with("target", target).with("url", url).with("uuid", uuid).with("media_id", mMediaTextureID);
-			notify_params.functor.function = boost::bind(&LLMediaCtrl::onPopup, this, _1, _2);
-
-			if (mTrusted)
-			{
-				LLNotifications::instance().forceResponse(notify_params, 0);
-			}
-			else
-			{
-				LLNotifications::instance().add(notify_params);
-			}
+			LLWeb::loadURL(url, target, std::string());
+
+			// CP: removing this code because we no longer support popups so this breaks the flow.
+			//     replaced with a bare call to LLWeb::LoadURL(...)
+			//LLNotification::Params notify_params;
+			//notify_params.name = "PopupAttempt";
+			//notify_params.payload = LLSD().with("target", target).with("url", url).with("uuid", uuid).with("media_id", mMediaTextureID);
+			//notify_params.functor.function = boost::bind(&LLMediaCtrl::onPopup, this, _1, _2);
+
+			//if (mTrusted)
+			//{
+			//	LLNotifications::instance().forceResponse(notify_params, 0);
+			//}
+			//else
+			//{
+			//	LLNotifications::instance().add(notify_params);
+			//}
 			break;
 		};
 
diff --git a/indra/newview/skins/default/xui/en/menu_login.xml b/indra/newview/skins/default/xui/en/menu_login.xml
index e91eea04d13..f59c5e35a6f 100755
--- a/indra/newview/skins/default/xui/en/menu_login.xml
+++ b/indra/newview/skins/default/xui/en/menu_login.xml
@@ -230,7 +230,7 @@
        name="Web Content Floater Debug Test">
         <menu_item_call.on_click
          function="Advanced.WebContentTest"
-         parameter="http://google.com"/>
+         parameter="https://callum-linden.s3.amazonaws.com/ceftests.html"/>
       </menu_item_call>
       <menu
        create_jump_keys="true"
-- 
GitLab