From 311b376ab50bacf2bf113616af2a5bbedfcd5ee5 Mon Sep 17 00:00:00 2001
From: callum_linden <none@none>
Date: Mon, 16 Nov 2015 16:09:40 -0800
Subject: [PATCH] Update SetCookie code for new LLCEFLib API and add support
 for shoing/hising developer console (Inspector)

---
 autobuild.xml                                | 10 +++++-----
 indra/llplugin/llpluginclassmedia.cpp        |  4 +++-
 indra/llplugin/llpluginclassmedia.h          |  2 +-
 indra/media_plugins/cef/media_plugin_cef.cpp |  8 +++++++-
 indra/newview/llviewermedia.cpp              | 11 ++++++++---
 indra/newview/llviewermedia.h                |  2 +-
 6 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/autobuild.xml b/autobuild.xml
index 98978ef06c7..c1401599999 100755
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -1536,11 +1536,11 @@
             <key>archive</key>
             <map>
               <key>hash</key>
-              <string>2d45b5e3157984fc38d9c57c0dacf89f</string>
+              <string>db32cc2c0d898d69d01ef61df81424e8</string>
               <key>hash_algorithm</key>
               <string>md5</string>
               <key>url</key>
-              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-llceflib_3p-llceflib/rev/307799/arch/Darwin/installer/llceflib-1.4.0.307799-darwin-307799.tar.bz2</string>
+              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-llceflib_3p-llceflib/rev/307893/arch/Darwin/installer/llceflib-1.4.0.307893-darwin-307893.tar.bz2</string>
             </map>
             <key>name</key>
             <string>darwin</string>
@@ -1550,18 +1550,18 @@
             <key>archive</key>
             <map>
               <key>hash</key>
-              <string>aa27060c311bf6e9e0f86fa5c5b25129</string>
+              <string>3c7f10479a6c4e0910df91b195be393f</string>
               <key>hash_algorithm</key>
               <string>md5</string>
               <key>url</key>
-              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-llceflib_3p-llceflib/rev/307799/arch/CYGWIN/installer/llceflib-1.4.0.307799-windows-307799.tar.bz2</string>
+              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-llceflib_3p-llceflib/rev/307893/arch/CYGWIN/installer/llceflib-1.4.0.307893-windows-307893.tar.bz2</string>
             </map>
             <key>name</key>
             <string>windows</string>
           </map>
         </map>
         <key>version</key>
-        <string>1.4.0.307799</string>
+        <string>1.4.0.307893</string>
       </map>
       <key>llphysicsextensions_source</key>
       <map>
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp
index 85653a0fccc..23c5cd87946 100755
--- a/indra/llplugin/llpluginclassmedia.cpp
+++ b/indra/llplugin/llpluginclassmedia.cpp
@@ -669,7 +669,7 @@ bool LLPluginClassMedia::textInput(const std::string &text, MASK modifiers, LLSD
 	return true;
 }
 
-void LLPluginClassMedia::setCookie(std::string uri, std::string name, std::string value, std::string domain, std::string path)
+void LLPluginClassMedia::setCookie(std::string uri, std::string name, std::string value, std::string domain, std::string path, bool httponly, bool secure)
 {
 	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "set_cookie");
 
@@ -678,6 +678,8 @@ void LLPluginClassMedia::setCookie(std::string uri, std::string name, std::strin
 	message.setValue("value", value);
 	message.setValue("domain", domain);
 	message.setValue("path", path);
+	message.setValueBoolean("httponly", httponly);
+	message.setValueBoolean("secure", secure);
 
 	sendMessage(message);
 }
diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h
index fe026960848..62652da9bce 100755
--- a/indra/llplugin/llpluginclassmedia.h
+++ b/indra/llplugin/llpluginclassmedia.h
@@ -133,7 +133,7 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner
 	// Text may be unicode (utf8 encoded)
 	bool textInput(const std::string &text, MASK modifiers, LLSD native_key_data);
 	
-	void setCookie(std::string uri, std::string name, std::string value, std::string domain, std::string path);
+	void setCookie(std::string uri, std::string name, std::string value, std::string domain, std::string path, bool httponly, bool secure);
 
 	void loadURI(const std::string &uri);
 	
diff --git a/indra/media_plugins/cef/media_plugin_cef.cpp b/indra/media_plugins/cef/media_plugin_cef.cpp
index 60f6264db48..a53b453b3ec 100644
--- a/indra/media_plugins/cef/media_plugin_cef.cpp
+++ b/indra/media_plugins/cef/media_plugin_cef.cpp
@@ -499,7 +499,9 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
 				std::string value = message_in.getValue("value");
 				std::string domain = message_in.getValue("domain");
 				std::string path = message_in.getValue("path");
-				mLLCEFLib->setCookie(uri, name, value, domain, path);
+				bool httponly = message_in.getValueBoolean("httponly");
+				bool secure = message_in.getValueBoolean("secure");
+				mLLCEFLib->setCookie(uri, name, value, domain, path, httponly, secure);
 			}
 			else if (message_name == "mouse_event")
 			{
@@ -666,6 +668,10 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
 			{
 				mUserAgentSubtring = message_in.getValue("user_agent");
 			}
+			else if (message_name == "show_web_inspector")
+			{
+				mLLCEFLib->showDevTools(true);
+			}
 			else if (message_name == "plugins_enabled")
 			{
 				mPluginsEnabled = message_in.getValueBoolean("enable");
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 626938f7b5c..cc56a9db8db 100755
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -1390,7 +1390,7 @@ LLSD LLViewerMedia::getHeaders()
 
  /////////////////////////////////////////////////////////////////////////////////////////
  // static
-bool LLViewerMedia::parseRawCookie(const std::string raw_cookie, std::string& name, std::string& value, std::string& path)
+bool LLViewerMedia::parseRawCookie(const std::string raw_cookie, std::string& name, std::string& value, std::string& path, bool& httponly, bool& secure)
 {
 	std::size_t name_pos = raw_cookie.find_first_of("=");
 	if (name_pos != std::string::npos)
@@ -1402,6 +1402,9 @@ bool LLViewerMedia::parseRawCookie(const std::string raw_cookie, std::string& na
 			value = raw_cookie.substr(name_pos + 1, value_pos - name_pos - 1);
 			path = "/";	// assume root path for now
 
+			httponly = true;	// hard coded for now
+			secure = true;
+
 			return true;
 		}
 	}
@@ -1450,10 +1453,12 @@ void LLViewerMedia::setOpenIDCookie(const std::string& url)
 				std::string cookie_name = "";
 				std::string cookie_value = "";
 				std::string cookie_path = "";
-				if (parseRawCookie(sOpenIDCookie, cookie_name, cookie_value, cookie_path) &&
+				bool httponly = true;
+				bool secure = true;
+				if (parseRawCookie(sOpenIDCookie, cookie_name, cookie_value, cookie_path, httponly, secure) &&
                     media_instance->getMediaPlugin())
 				{
-					media_instance->getMediaPlugin()->setCookie(url, cookie_name, cookie_value, cookie_host, cookie_path);
+					media_instance->getMediaPlugin()->setCookie(url, cookie_name, cookie_value, cookie_host, cookie_path, httponly, secure);
 				}
 			}
 		}
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index 4ee1b56a2a8..01d4b0786ff 100755
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -163,7 +163,7 @@ class LLViewerMedia
 	static LLSD getHeaders();
 	
 private:
-	static bool parseRawCookie(const std::string raw_cookie, std::string& name, std::string& value, std::string& path);
+	static bool parseRawCookie(const std::string raw_cookie, std::string& name, std::string& value, std::string& path, bool& httponly, bool& secure);
 	static void setOpenIDCookie(const std::string& url);
 	static void onTeleportFinished();
 	
-- 
GitLab