From 4d1a2ef2d1d521ccdf5150f76ef5ce7597aded28 Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Thu, 29 Oct 2009 16:09:27 -0700
Subject: Fix for DEV-41978 (media controls URL is incorrect after whitelist
 bounces webpage back).

Added LLViewerMediaImpl::getCurrentMediaURL(), which reflects the most recent url either set with navigateTo or received from the plugin via locationChanged/navigateComplete.  LLViewerMediaImpl now uses this when reload() is called.

LLPanelPrimMediaControls now uses getCurrentMediaURL() to get the url it displays in the URL input bar and opens with the pop-out control.
---
 indra/newview/llpanelprimmediacontrols.cpp | 16 +++-------------
 indra/newview/llviewermedia.cpp            | 19 ++++++++++++++++++-
 indra/newview/llviewermedia.h              |  4 +++-
 3 files changed, 24 insertions(+), 15 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp
index cbff13a20f..fb0b5dff1f 100644
--- a/indra/newview/llpanelprimmediacontrols.cpp
+++ b/indra/newview/llpanelprimmediacontrols.cpp
@@ -291,7 +291,7 @@ void LLPanelPrimMediaControls::updateShape()
 		// Disable zoom if HUD
 		zoom_ctrl->setEnabled(!objectp->isHUDAttachment());
 		secure_lock_icon->setVisible(false);
-		mCurrentURL = media_impl->getMediaURL();
+		mCurrentURL = media_impl->getCurrentMediaURL();
 		
 		back_ctrl->setEnabled((media_impl != NULL) && media_impl->canNavigateBack() && can_navigate);
 		fwd_ctrl->setEnabled((media_impl != NULL) && media_impl->canNavigateForward() && can_navigate);
@@ -758,20 +758,10 @@ void LLPanelPrimMediaControls::onClickHome()
 
 void LLPanelPrimMediaControls::onClickOpen()
 {
-	LLViewerMediaImpl* impl =getTargetMediaImpl();
+	LLViewerMediaImpl* impl = getTargetMediaImpl();
 	if(impl)
 	{
-		if(impl->getMediaPlugin())
-		{	
-			if(impl->getMediaPlugin()->getLocation().empty())
-			{
-				LLWeb::loadURL(impl->getMediaURL());
-			}
-			else
-			{
-				LLWeb::loadURL( impl->getMediaPlugin()->getLocation());
-			}
-		}
+		LLWeb::loadURL(impl->getCurrentMediaURL());
 	}	
 }
 
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 8bd74dcb04..20e9208a4e 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -1023,6 +1023,16 @@ bool LLViewerMediaImpl::hasFocus() const
 	return mHasFocus;
 }
 
+std::string LLViewerMediaImpl::getCurrentMediaURL()
+{
+	if(!mCurrentMediaURL.empty())
+	{
+		return mCurrentMediaURL;
+	}
+	
+	return mMediaURL;
+}
+
 //////////////////////////////////////////////////////////////////////////////////////////
 void LLViewerMediaImpl::mouseDown(S32 x, S32 y, MASK mask, S32 button)
 {
@@ -1181,7 +1191,7 @@ void LLViewerMediaImpl::navigateForward()
 //////////////////////////////////////////////////////////////////////////////////////////
 void LLViewerMediaImpl::navigateReload()
 {
-	navigateTo(mMediaURL, "", true, false);
+	navigateTo(getCurrentMediaURL(), "", true, false);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -1203,6 +1213,9 @@ void LLViewerMediaImpl::navigateTo(const std::string& url, const std::string& mi
 	mMediaURL = url;
 	mMimeType = mime_type;
 	
+	// Clear the current media URL, since it will no longer be correct.
+	mCurrentMediaURL.clear();
+	
 	// if mime type discovery was requested, we'll need to do it when the media loads
 	mNavigateRediscoverType = rediscover_type;
 	
@@ -1702,10 +1715,12 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
 
 			if(getNavState() == MEDIANAVSTATE_BEGUN)
 			{
+				mCurrentMediaURL = plugin->getNavigateURI();
 				setNavState(MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED);
 			}
 			else if(getNavState() == MEDIANAVSTATE_SERVER_BEGUN)
 			{
+				mCurrentMediaURL = plugin->getNavigateURI();
 				setNavState(MEDIANAVSTATE_SERVER_COMPLETE_BEFORE_LOCATION_CHANGED);
 			}
 			else
@@ -1721,10 +1736,12 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
 
 			if(getNavState() == MEDIANAVSTATE_BEGUN)
 			{
+				mCurrentMediaURL = plugin->getLocation();
 				setNavState(MEDIANAVSTATE_FIRST_LOCATION_CHANGED);
 			}
 			else if(getNavState() == MEDIANAVSTATE_SERVER_BEGUN)
 			{
+				mCurrentMediaURL = plugin->getLocation();
 				setNavState(MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED);
 			}
 			else
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index 4f0d39dd80..76606be685 100644
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -159,6 +159,7 @@ public:
 	bool canNavigateForward();
 	bool canNavigateBack();
 	std::string getMediaURL() { return mMediaURL; }
+	std::string getCurrentMediaURL();
 	std::string getHomeURL() { return mHomeURL; }
     void setHomeURL(const std::string& home_url) { mHomeURL = home_url; };
 	std::string getMimeType() { return mMimeType; }
@@ -272,9 +273,10 @@ public:
 	LLPluginClassMedia* mMediaSource;
 	LLUUID mTextureId;
 	bool  mMovieImageHasMips;
-	std::string mMediaURL;
+	std::string mMediaURL;			// The last media url set with NavigateTo
 	std::string mHomeURL;
 	std::string mMimeType;
+	std::string mCurrentMediaURL;	// The most current media url from the plugin (via the "location changed" or "navigate complete" events).
 	S32 mLastMouseX;	// save the last mouse coord we get, so when we lose capture we can simulate a mouseup at that point.
 	S32 mLastMouseY;
 	S32 mMediaWidth;
-- 
cgit v1.2.3