From a57729b9260ce5e711bff47c02ca54ab65eade27 Mon Sep 17 00:00:00 2001
From: callum <none@none>
Date: Tue, 22 Mar 2011 13:58:27 -0700
Subject: [PATCH] SOCIAL-634 FIX Error condition content for Destination Guide,
 Avatar Picker,             and Help if S3 content or web content is not
 available

---
 indra/newview/app_settings/settings.xml |  4 ++--
 indra/newview/llfloaterwebcontent.cpp   |  6 ------
 indra/newview/llmediactrl.cpp           | 16 ++++++++++++++++
 indra/newview/llmediactrl.h             |  5 +++++
 indra/newview/llviewerwindow.cpp        |  2 ++
 5 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 888f9c9d7fb..b82c98fd601 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -12597,10 +12597,10 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
-    <key>WebContentFloaterErrorURL</key>
+    <key>GenericErrorPageURL</key>
     <map>
       <key>Comment</key>
-      <string>URL to navigate to if the Web content floater hits a page with a 400-499 HTTP status code</string>
+      <string>URL to set as a property on LLMediaControl to navigate to if the a page completes with a 400-499 HTTP status code</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp
index 76fb985b391..058567492be 100644
--- a/indra/newview/llfloaterwebcontent.cpp
+++ b/indra/newview/llfloaterwebcontent.cpp
@@ -328,12 +328,6 @@ void LLFloaterWebContent::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent
 		const std::string link = self->getHoverLink();
 		mStatusBarText->setText( link );
 	}
-	else if(event == MEDIA_EVENT_NAVIGATE_ERROR_PAGE )
-	{
-		std::string redirect_url = gSavedSettings.getString("WebContentFloaterErrorURL");
-		mWebBrowser->navigateTo(redirect_url, "text/html");
-		set_current_url(redirect_url);
-	}
 }
 
 void LLFloaterWebContent::set_current_url(const std::string& url)
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index 376e38ade3e..b8c61068c41 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -73,6 +73,7 @@ LLMediaCtrl::Params::Params()
 	texture_height("texture_height", 1024),
 	caret_color("caret_color"),
 	initial_mime_type("initial_mime_type"),
+	error_page_url("error_page_url"),
 	media_id("media_id"),
 	trusted_content("trusted_content", false),
 	focus_on_click("focus_on_click", true)
@@ -102,6 +103,7 @@ LLMediaCtrl::LLMediaCtrl( const Params& p) :
 	mTextureHeight ( 1024 ),
 	mClearCache(false),
 	mHomePageMimeType(p.initial_mime_type),
+	mErrorPageURL(p.error_page_url),
 	mTrusted(p.trusted_content),
 	mWindowShade(NULL),
 	mHoverTextChanged(false)
@@ -610,6 +612,16 @@ void LLMediaCtrl::setTarget(const std::string& target)
 	}
 }
 
+void LLMediaCtrl::setErrorPageURL(const std::string& url)
+{
+	mErrorPageURL = url;
+}
+
+const std::string& LLMediaCtrl::getErrorPageURL()
+{
+	return mErrorPageURL;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 //
 bool LLMediaCtrl::setCaretColor(unsigned int red, unsigned int green, unsigned int blue)
@@ -963,6 +975,10 @@ void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event)
 		case MEDIA_EVENT_NAVIGATE_ERROR_PAGE:
 		{
 			LL_DEBUGS("Media") <<  "Media event:  MEDIA_EVENT_NAVIGATE_ERROR_PAGE" << LL_ENDL;
+			if ( mErrorPageURL.length() > 0 )
+			{
+				navigateTo(mErrorPageURL, "text/html");
+			};
 		};
 		break;
 
diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h
index 7a28b0986de..53b98b7ec88 100644
--- a/indra/newview/llmediactrl.h
+++ b/indra/newview/llmediactrl.h
@@ -63,6 +63,7 @@ class LLMediaCtrl :
 
 		Optional<std::string>	initial_mime_type;
 		Optional<std::string>	media_id;
+		Optional<std::string>	error_page_url;
 		
 		Params();
 	};
@@ -113,6 +114,9 @@ class LLMediaCtrl :
 
 		void setTarget(const std::string& target);
 
+		void setErrorPageURL(const std::string& url);
+		const std::string& getErrorPageURL();
+
 		// Clear the browser cache when the instance gets loaded
 		void clearCache();
 
@@ -175,6 +179,7 @@ class LLMediaCtrl :
 		std::string mHomePageUrl;
 		std::string mHomePageMimeType;
 		std::string mCurrentNavUrl;
+		std::string mErrorPageURL;
 		std::string mTarget;
 		bool mIgnoreUIScale;
 		bool mAlwaysRefresh;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 6bf363bf687..b71eebc30f1 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1791,11 +1791,13 @@ void LLViewerWindow::initWorldUI()
 	LLMediaCtrl* avatar_picker = avatar_picker_destination_guide_container->findChild<LLMediaCtrl>("avatar_picker_contents");
 	if (destinations)
 	{
+		destinations->setErrorPageURL(gSavedSettings.getString("GenericErrorPageURL"));
 		destinations->navigateTo(gSavedSettings.getString("DestinationGuideURL"), "text/html");
 	}
 
 	if (avatar_picker)
 	{
+		avatar_picker->setErrorPageURL(gSavedSettings.getString("GenericErrorPageURL"));
 		avatar_picker->navigateTo(gSavedSettings.getString("AvatarPickerURL"), "text/html");
 	}
 
-- 
GitLab