diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp
index d48f4ad0f5e3c99b1485442caeecce0156edf8f7..cb62e462713e7f4285ef25a1c76a0934362705f5 100644
--- a/indra/llplugin/llpluginclassmedia.cpp
+++ b/indra/llplugin/llpluginclassmedia.cpp
@@ -65,15 +65,19 @@ LLPluginClassMedia::~LLPluginClassMedia()
 	reset();
 }
 
-bool LLPluginClassMedia::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug, const std::string &user_data_path, const std::string &language_code)
+bool LLPluginClassMedia::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug)
 {	
 	LL_DEBUGS("Plugin") << "launcher: " << launcher_filename << LL_ENDL;
 	LL_DEBUGS("Plugin") << "plugin: " << plugin_filename << LL_ENDL;
-	LL_DEBUGS("Plugin") << "user_data_path: " << user_data_path << LL_ENDL;
 	
 	mPlugin = new LLPluginProcessParent(this);
 	mPlugin->setSleepTime(mSleepTime);
-	mPlugin->init(launcher_filename, plugin_filename, debug, user_data_path,language_code);
+	
+	// Queue up the media init message -- it will be sent after all the currently queued messages.
+	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "init");
+	sendMessage(message);
+	
+	mPlugin->init(launcher_filename, plugin_filename, debug);
 
 	return true;
 }
@@ -678,6 +682,20 @@ void LLPluginClassMedia::paste()
 	sendMessage(message);
 }
 
+void LLPluginClassMedia::setUserDataPath(const std::string &user_data_path)
+{
+	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "set_user_data_path");
+	message.setValue("path", user_data_path);
+	sendMessage(message);
+}
+
+void LLPluginClassMedia::setLanguageCode(const std::string &language_code)
+{
+	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "set_language_code");
+	message.setValue("language", language_code);
+	sendMessage(message);
+}
+
 LLPluginClassMedia::ETargetType getTargetTypeFromLLQtWebkit(int target_type)
 {
 	// convert a LinkTargetType value from llqtwebkit to an ETargetType
diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h
index ce49241e84f7dc91a9393a3cb68440560cb7e8cd..6318c67f12673bc84b87a5906c846833cc5cd373 100644
--- a/indra/llplugin/llpluginclassmedia.h
+++ b/indra/llplugin/llpluginclassmedia.h
@@ -51,9 +51,7 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner
 	// local initialization, called by the media manager when creating a source
 	virtual bool init(const std::string &launcher_filename, 
 					  const std::string &plugin_filename, 
-					  bool debug, 
-					  const std::string &user_data_path,
-					  const std::string &language_code);
+					  bool debug);
 
 	// undoes everything init() didm called by the media manager when destroying a source
 	virtual void reset();
@@ -177,6 +175,10 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner
 
 	void	paste();
 	bool	canPaste() const { return mCanPaste; };
+	
+	// These can be called before init(), and they will be queued and sent before the media init message.
+	void	setUserDataPath(const std::string &user_data_path);
+	void	setLanguageCode(const std::string &language_code);
 		
 	///////////////////////////////////
 	// media browser class functions
diff --git a/indra/llplugin/llpluginprocesschild.cpp b/indra/llplugin/llpluginprocesschild.cpp
index 9b43ec0e3eedee89e4a8caacbdc87fc2d48fd380..ccaf95b36ded8c072865cb1a954041650126dce1 100644
--- a/indra/llplugin/llpluginprocesschild.cpp
+++ b/indra/llplugin/llpluginprocesschild.cpp
@@ -155,8 +155,6 @@ void LLPluginProcessChild::idle(void)
 				{
 					setState(STATE_PLUGIN_INITIALIZING);
 					LLPluginMessage message("base", "init");
-					message.setValue("user_data_path", mUserDataPath);
-					message.setValue("language_code", mLanguageCode);
 					sendMessageToPlugin(message);
 				}
 			break;
@@ -329,8 +327,6 @@ void LLPluginProcessChild::receiveMessageRaw(const std::string &message)
 			if(message_name == "load_plugin")
 			{
 				mPluginFile = parsed.getValue("file");
-				mUserDataPath = parsed.getValue("user_data_path");
-				mLanguageCode = parsed.getValue("language_code");
 			}
 			else if(message_name == "shm_add")
 			{
diff --git a/indra/llplugin/llpluginprocesschild.h b/indra/llplugin/llpluginprocesschild.h
index af76ec1fa53a0c848d2f225bb605ac59705cf3e4..0e5e85406a671fa00f0b33ac1357e5ca17695e8a 100644
--- a/indra/llplugin/llpluginprocesschild.h
+++ b/indra/llplugin/llpluginprocesschild.h
@@ -98,9 +98,6 @@ class LLPluginProcessChild: public LLPluginMessagePipeOwner, public LLPluginInst
 	
 	std::string mPluginFile;
 
-	std::string mUserDataPath;
-	std::string mLanguageCode;
-	
 	LLPluginInstance *mInstance;
 
 	typedef std::map<std::string, LLPluginSharedMemory*> sharedMemoryRegionsType;
diff --git a/indra/llplugin/llpluginprocessparent.cpp b/indra/llplugin/llpluginprocessparent.cpp
index 0ce2c759bace238aa0d9dbab26d64447e0faae67..895c858979026645dfc5632e6707ae2cc7fd773e 100644
--- a/indra/llplugin/llpluginprocessparent.cpp
+++ b/indra/llplugin/llpluginprocessparent.cpp
@@ -98,15 +98,12 @@ void LLPluginProcessParent::errorState(void)
 		setState(STATE_ERROR);
 }
 
-void LLPluginProcessParent::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug, const std::string &user_data_path, const std::string &language_code)
+void LLPluginProcessParent::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug)
 {	
 	mProcess.setExecutable(launcher_filename);
 	mPluginFile = plugin_filename;
 	mCPUUsage = 0.0f;
-	mDebug = debug;
-	mUserDataPath = user_data_path;
-	mLanguageCode = language_code;
-	
+	mDebug = debug;	
 	setState(STATE_INITIALIZED);
 }
 
@@ -363,8 +360,6 @@ void LLPluginProcessParent::idle(void)
 				{
 					LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "load_plugin");
 					message.setValue("file", mPluginFile);
-					message.setValue("user_data_path", mUserDataPath);
-					message.setValue("language_code", mLanguageCode);
 					sendMessage(message);
 				}
 
diff --git a/indra/llplugin/llpluginprocessparent.h b/indra/llplugin/llpluginprocessparent.h
index 23702814c8b9168e1a6804185b3d386d250c76ae..cc6c513615747283dfd71c9e504841168697ffb3 100644
--- a/indra/llplugin/llpluginprocessparent.h
+++ b/indra/llplugin/llpluginprocessparent.h
@@ -61,9 +61,7 @@ class LLPluginProcessParent : public LLPluginMessagePipeOwner
 		
 	void init(const std::string &launcher_filename, 
 			  const std::string &plugin_filename, 
-			  bool debug, 
-			  const std::string &user_data_path,
-			  const std::string &language_code);
+			  bool debug);
 
 	void idle(void);
 	
@@ -148,9 +146,6 @@ class LLPluginProcessParent : public LLPluginMessagePipeOwner
 	
 	std::string mPluginFile;
 
-	std::string mUserDataPath;
-	std::string mLanguageCode;
-
 	LLPluginProcessParentOwner *mOwner;
 	
 	typedef std::map<std::string, LLPluginSharedMemory*> sharedMemoryRegionsType;
diff --git a/indra/media_plugins/example/media_plugin_example.cpp b/indra/media_plugins/example/media_plugin_example.cpp
index f5b077fea037410a80d4643fb11328c8231aacad..8d79bb27f18b890297710d1b5d794e579e8982cb 100644
--- a/indra/media_plugins/example/media_plugin_example.cpp
+++ b/indra/media_plugins/example/media_plugin_example.cpp
@@ -119,17 +119,6 @@ void MediaPluginExample::receiveMessage( const char* message_string )
 				std::string plugin_version = "Example media plugin, Example Version 1.0.0.0";
 				message.setValue( "plugin_version", plugin_version );
 				sendMessage( message );
-
-				// Plugin gets to decide the texture parameters to use.
-				message.setMessage( LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params" );
-				message.setValueS32( "default_width", mWidth );
-				message.setValueS32( "default_height", mHeight );
-				message.setValueS32( "depth", mDepth );
-				message.setValueU32( "internalformat", GL_RGBA );
-				message.setValueU32( "format", GL_RGBA );
-				message.setValueU32( "type", GL_UNSIGNED_BYTE );
-				message.setValueBoolean( "coords_opengl", false );
-				sendMessage( message );
 			}
 			else
 			if ( message_name == "idle" )
@@ -191,7 +180,20 @@ void MediaPluginExample::receiveMessage( const char* message_string )
 		else
 		if ( message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA )
 		{
-			if ( message_name == "size_change" )
+			if ( message_name == "init" )
+			{
+				// Plugin gets to decide the texture parameters to use.
+				message.setMessage( LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params" );
+				message.setValueS32( "default_width", mWidth );
+				message.setValueS32( "default_height", mHeight );
+				message.setValueS32( "depth", mDepth );
+				message.setValueU32( "internalformat", GL_RGBA );
+				message.setValueU32( "format", GL_RGBA );
+				message.setValueU32( "type", GL_UNSIGNED_BYTE );
+				message.setValueBoolean( "coords_opengl", false );
+				sendMessage( message );
+			}
+			else if ( message_name == "size_change" )
 			{
 				std::string name = message_in.getValue( "name" );
 				S32 width = message_in.getValueS32( "width" );
diff --git a/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp b/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp
index 26173314a7f8ea52d2802291ea0a0fcb1873b549..a69da3ff5aa83c5bde0c67d973872d72ec20af0e 100644
--- a/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp
+++ b/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp
@@ -946,33 +946,6 @@ void MediaPluginGStreamer010::receiveMessage(const char *message_string)
 
 				message.setValue("plugin_version", getVersion());
 				sendMessage(message);
-
-				// Plugin gets to decide the texture parameters to use.
-				message.setMessage(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params");
-				// lame to have to decide this now, it depends on the movie.  Oh well.
-				mDepth = 4;
-
-				mCurrentWidth = 1;
-				mCurrentHeight = 1;
-				mPreviousWidth = 1;
-				mPreviousHeight = 1;
-				mNaturalWidth = 1;
-				mNaturalHeight = 1;
-				mWidth = 1;
-				mHeight = 1;
-				mTextureWidth = 1;
-				mTextureHeight = 1;
-
-				message.setValueU32("format", GL_RGBA);
-				message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV);
-
-				message.setValueS32("depth", mDepth);
-				message.setValueS32("default_width", mWidth);
-				message.setValueS32("default_height", mHeight);
-				message.setValueU32("internalformat", GL_RGBA8);
-				message.setValueBoolean("coords_opengl", true);	// true == use OpenGL-style coordinates, false == (0,0) is upper left.
-				message.setValueBoolean("allow_downsample", true); // we respond with grace and performance if asked to downscale
-				sendMessage(message);
 			}
 			else if(message_name == "idle")
 			{
@@ -1037,7 +1010,36 @@ void MediaPluginGStreamer010::receiveMessage(const char *message_string)
 		}
 		else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA)
 		{
-			if(message_name == "size_change")
+			if(message_name == "init")
+			{
+				// Plugin gets to decide the texture parameters to use.
+				LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params");
+				// lame to have to decide this now, it depends on the movie.  Oh well.
+				mDepth = 4;
+
+				mCurrentWidth = 1;
+				mCurrentHeight = 1;
+				mPreviousWidth = 1;
+				mPreviousHeight = 1;
+				mNaturalWidth = 1;
+				mNaturalHeight = 1;
+				mWidth = 1;
+				mHeight = 1;
+				mTextureWidth = 1;
+				mTextureHeight = 1;
+
+				message.setValueU32("format", GL_RGBA);
+				message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV);
+
+				message.setValueS32("depth", mDepth);
+				message.setValueS32("default_width", mWidth);
+				message.setValueS32("default_height", mHeight);
+				message.setValueU32("internalformat", GL_RGBA8);
+				message.setValueBoolean("coords_opengl", true);	// true == use OpenGL-style coordinates, false == (0,0) is upper left.
+				message.setValueBoolean("allow_downsample", true); // we respond with grace and performance if asked to downscale
+				sendMessage(message);
+			}
+			else if(message_name == "size_change")
 			{
 				std::string name = message_in.getValue("name");
 				S32 width = message_in.getValueS32("width");
diff --git a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp
index e230fcc280e2cbd6e4bc335ca671cc0caab69395..1f88301ca7fb3f666f261474a3e9e8a46e204ce7 100644
--- a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp
+++ b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp
@@ -859,36 +859,6 @@ void MediaPluginQuickTime::receiveMessage(const char *message_string)
 				plugin_version += codec.str();
 				message.setValue("plugin_version", plugin_version);
 				sendMessage(message);
-
-				// Plugin gets to decide the texture parameters to use.
-				message.setMessage(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params");
-				#if defined(LL_WINDOWS)
-					// Values for Windows
-					mDepth = 3;
-					message.setValueU32("format", GL_RGB);
-					message.setValueU32("type", GL_UNSIGNED_BYTE);
-
-					// We really want to pad the texture width to a multiple of 32 bytes, but since we're using 3-byte pixels, it doesn't come out even.
-					// Padding to a multiple of 3*32 guarantees it'll divide out properly.
-					message.setValueU32("padding", 32 * 3);
-				#else
-					// Values for Mac
-					mDepth = 4;
-					message.setValueU32("format", GL_BGRA_EXT);
-					#ifdef __BIG_ENDIAN__
-						message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV );
-					#else
-						message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8);
-					#endif
-
-					// Pad texture width to a multiple of 32 bytes, to line up with cache lines.
-					message.setValueU32("padding", 32);
-				#endif
-				message.setValueS32("depth", mDepth);
-				message.setValueU32("internalformat", GL_RGB);
-				message.setValueBoolean("coords_opengl", true);	// true == use OpenGL-style coordinates, false == (0,0) is upper left.
-				message.setValueBoolean("allow_downsample", true);
-				sendMessage(message);
 			}
 			else if(message_name == "idle")
 			{
@@ -953,7 +923,41 @@ void MediaPluginQuickTime::receiveMessage(const char *message_string)
 		}
 		else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA)
 		{
-			if(message_name == "size_change")
+			if(message_name == "init")
+			{
+				// This is the media init message -- all necessary data for initialization should have been received.
+
+				// Plugin gets to decide the texture parameters to use.
+				LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params");
+				#if defined(LL_WINDOWS)
+					// Values for Windows
+					mDepth = 3;
+					message.setValueU32("format", GL_RGB);
+					message.setValueU32("type", GL_UNSIGNED_BYTE);
+
+					// We really want to pad the texture width to a multiple of 32 bytes, but since we're using 3-byte pixels, it doesn't come out even.
+					// Padding to a multiple of 3*32 guarantees it'll divide out properly.
+					message.setValueU32("padding", 32 * 3);
+				#else
+					// Values for Mac
+					mDepth = 4;
+					message.setValueU32("format", GL_BGRA_EXT);
+					#ifdef __BIG_ENDIAN__
+						message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV );
+					#else
+						message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8);
+					#endif
+
+					// Pad texture width to a multiple of 32 bytes, to line up with cache lines.
+					message.setValueU32("padding", 32);
+				#endif
+				message.setValueS32("depth", mDepth);
+				message.setValueU32("internalformat", GL_RGB);
+				message.setValueBoolean("coords_opengl", true);	// true == use OpenGL-style coordinates, false == (0,0) is upper left.
+				message.setValueBoolean("allow_downsample", true);
+				sendMessage(message);
+			}
+			else if(message_name == "size_change")
 			{
 				std::string name = message_in.getValue("name");
 				S32 width = message_in.getValueS32("width");
diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp
index afde904be652804a3446f7ee60afc6f0631efb61..24c53638d2bd07744e0beb1b5e12b3e3b33d4d35 100644
--- a/indra/media_plugins/webkit/media_plugin_webkit.cpp
+++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp
@@ -88,10 +88,12 @@ class MediaPluginWebKit :
 private:
 
 	std::string mProfileDir;
+	std::string mHostLanguage;
 
 	enum
 	{
-		INIT_STATE_UNINITIALIZED,		// Browser instance hasn't been set up yet
+		INIT_STATE_UNINITIALIZED,		// LLQtWebkit hasn't been set up yet
+		INIT_STATE_INITIALIZED,			// LLQtWebkit has been set up, but no browser window has been created yet.
 		INIT_STATE_NAVIGATING,			// Browser instance has been set up and initial navigate to about:blank has been issued
 		INIT_STATE_NAVIGATE_COMPLETE,	// initial navigate to about:blank has completed
 		INIT_STATE_WAIT_REDRAW,			// First real navigate begin has been received, waiting for page changed event to start handling redraws
@@ -191,13 +193,6 @@ class MediaPluginWebKit :
 		if ( mInitState > INIT_STATE_UNINITIALIZED )
 			return true;
 
-		// not enough information to initialize the browser yet.
-		if ( mWidth < 0 || mHeight < 0 || mDepth < 0 || 
-				mTextureWidth < 0 || mTextureHeight < 0 )
-		{
-			return false;
-		};
-
 		// set up directories
 		char cwd[ FILENAME_MAX ];	// I *think* this is defined on all platforms we use
 		if (NULL == getcwd( cwd, FILENAME_MAX - 1 ))
@@ -208,12 +203,12 @@ class MediaPluginWebKit :
 		std::string application_dir = std::string( cwd );
 
 #if LL_DARWIN
-	// When running under the Xcode debugger, there's a setting called "Break on Debugger()/DebugStr()" which defaults to being turned on.
-	// This causes the environment variable USERBREAK to be set to 1, which causes these legacy calls to break into the debugger.
-	// This wouldn't cause any problems except for the fact that the current release version of the Flash plugin has a call to Debugger() in it
-	// which gets hit when the plugin is probed by webkit.
-	// Unsetting the environment variable here works around this issue.
-	unsetenv("USERBREAK");
+		// When running under the Xcode debugger, there's a setting called "Break on Debugger()/DebugStr()" which defaults to being turned on.
+		// This causes the environment variable USERBREAK to be set to 1, which causes these legacy calls to break into the debugger.
+		// This wouldn't cause any problems except for the fact that the current release version of the Flash plugin has a call to Debugger() in it
+		// which gets hit when the plugin is probed by webkit.
+		// Unsetting the environment variable here works around this issue.
+		unsetenv("USERBREAK");
 #endif
 
 #if LL_WINDOWS
@@ -254,66 +249,92 @@ class MediaPluginWebKit :
 		bool result = LLQtWebKit::getInstance()->init( application_dir, component_dir, mProfileDir, native_window_handle );
 		if ( result )
 		{
-			// create single browser window
-			mBrowserWindowId = LLQtWebKit::getInstance()->createBrowserWindow( mWidth, mHeight );
+			mInitState = INIT_STATE_INITIALIZED;
+			
+			return true;
+		};
+
+		return false;
+	};
+
+	////////////////////////////////////////////////////////////////////////////////
+	//
+	bool initBrowserWindow()
+	{
+		// already initialized
+		if ( mInitState > INIT_STATE_INITIALIZED )
+			return true;
+
+		// not enough information to initialize the browser yet.
+		if ( mWidth < 0 || mHeight < 0 || mDepth < 0 || 
+				mTextureWidth < 0 || mTextureHeight < 0 )
+		{
+			return false;
+		};
+		
+		// Set up host language before creating browser window
+		if(!mHostLanguage.empty())
+		{
+			LLQtWebKit::getInstance()->setHostLanguage(mHostLanguage);
+		}
+		
+		// create single browser window
+		mBrowserWindowId = LLQtWebKit::getInstance()->createBrowserWindow( mWidth, mHeight );
 #if LL_WINDOWS
-			// Enable plugins
-			LLQtWebKit::getInstance()->enablePlugins(true);
+		// Enable plugins
+		LLQtWebKit::getInstance()->enablePlugins(true);
 #elif LL_DARWIN
-			// Enable plugins
-			LLQtWebKit::getInstance()->enablePlugins(true);
+		// Enable plugins
+		LLQtWebKit::getInstance()->enablePlugins(true);
 #elif LL_LINUX
-			// Enable plugins
-			LLQtWebKit::getInstance()->enablePlugins(true);
+		// Enable plugins
+		LLQtWebKit::getInstance()->enablePlugins(true);
 #endif
-			// Enable cookies
-			LLQtWebKit::getInstance()->enableCookies( true );
+		// Enable cookies
+		LLQtWebKit::getInstance()->enableCookies( true );
 
-			// tell LLQtWebKit about the size of the browser window
-			LLQtWebKit::getInstance()->setSize( mBrowserWindowId, mWidth, mHeight );
+		// tell LLQtWebKit about the size of the browser window
+		LLQtWebKit::getInstance()->setSize( mBrowserWindowId, mWidth, mHeight );
 
-			// observer events that LLQtWebKit emits
-			LLQtWebKit::getInstance()->addObserver( mBrowserWindowId, this );
+		// observer events that LLQtWebKit emits
+		LLQtWebKit::getInstance()->addObserver( mBrowserWindowId, this );
 
-			// append details to agent string
-			LLQtWebKit::getInstance()->setBrowserAgentId( "LLPluginMedia Web Browser" );
+		// append details to agent string
+		LLQtWebKit::getInstance()->setBrowserAgentId( "LLPluginMedia Web Browser" );
 
 #if !LL_QTWEBKIT_USES_PIXMAPS
-			// don't flip bitmap
-			LLQtWebKit::getInstance()->flipWindow( mBrowserWindowId, true );
+		// don't flip bitmap
+		LLQtWebKit::getInstance()->flipWindow( mBrowserWindowId, true );
 #endif // !LL_QTWEBKIT_USES_PIXMAPS
-			
-			// set background color
-			// convert background color channels from [0.0, 1.0] to [0, 255];
-			LLQtWebKit::getInstance()->setBackgroundColor( mBrowserWindowId, int(mBackgroundR * 255.0f), int(mBackgroundG * 255.0f), int(mBackgroundB * 255.0f) );
-
-			// Set state _before_ starting the navigate, since onNavigateBegin might get called before this call returns.
-			setInitState(INIT_STATE_NAVIGATING);
-
-			// Don't do this here -- it causes the dreaded "white flash" when loading a browser instance.
-			// FIXME: Re-added this because navigating to a "page" initializes things correctly - especially
-			// for the HTTP AUTH dialog issues (DEV-41731). Will fix at a later date.
-			// Build a data URL like this: "data:text/html,%3Chtml%3E%3Cbody bgcolor=%22#RRGGBB%22%3E%3C/body%3E%3C/html%3E"
-			// where RRGGBB is the background color in HTML style
-			std::stringstream url;
-			
-			url << "data:text/html,%3Chtml%3E%3Cbody%20bgcolor=%22#";
-			// convert background color channels from [0.0, 1.0] to [0, 255];
-			url << std::setfill('0') << std::setw(2) << std::hex << int(mBackgroundR * 255.0f);
-			url << std::setfill('0') << std::setw(2) << std::hex << int(mBackgroundG * 255.0f);
-			url << std::setfill('0') << std::setw(2) << std::hex << int(mBackgroundB * 255.0f);
-			url << "%22%3E%3C/body%3E%3C/html%3E";
-			
-			lldebugs << "data url is: " << url.str() << llendl;
-						
-			LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, url.str() );
-//			LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, "about:blank" );
-
-			return true;
-		};
+		
+		// set background color
+		// convert background color channels from [0.0, 1.0] to [0, 255];
+		LLQtWebKit::getInstance()->setBackgroundColor( mBrowserWindowId, int(mBackgroundR * 255.0f), int(mBackgroundG * 255.0f), int(mBackgroundB * 255.0f) );
+
+		// Set state _before_ starting the navigate, since onNavigateBegin might get called before this call returns.
+		setInitState(INIT_STATE_NAVIGATING);
+
+		// Don't do this here -- it causes the dreaded "white flash" when loading a browser instance.
+		// FIXME: Re-added this because navigating to a "page" initializes things correctly - especially
+		// for the HTTP AUTH dialog issues (DEV-41731). Will fix at a later date.
+		// Build a data URL like this: "data:text/html,%3Chtml%3E%3Cbody bgcolor=%22#RRGGBB%22%3E%3C/body%3E%3C/html%3E"
+		// where RRGGBB is the background color in HTML style
+		std::stringstream url;
+		
+		url << "data:text/html,%3Chtml%3E%3Cbody%20bgcolor=%22#";
+		// convert background color channels from [0.0, 1.0] to [0, 255];
+		url << std::setfill('0') << std::setw(2) << std::hex << int(mBackgroundR * 255.0f);
+		url << std::setfill('0') << std::setw(2) << std::hex << int(mBackgroundG * 255.0f);
+		url << std::setfill('0') << std::setw(2) << std::hex << int(mBackgroundB * 255.0f);
+		url << "%22%3E%3C/body%3E%3C/html%3E";
+		
+		lldebugs << "data url is: " << url.str() << llendl;
+					
+		LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, url.str() );
+//		LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, "about:blank" );
 
-		return false;
-	};
+		return true;	
+	}
 
 	void setVolume(F32 vol);
 
@@ -676,9 +697,6 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)
 		{
 			if(message_name == "init")
 			{
-				std::string user_data_path = message_in.getValue("user_data_path"); // n.b. always has trailing platform-specific dir-delimiter
-				mProfileDir = user_data_path + "browser_profile";
-
 				LLPluginMessage message("base", "init_response");
 				LLSD versions = LLSD::emptyMap();
 				versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION;
@@ -690,23 +708,6 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)
 				plugin_version += LLQtWebKit::getInstance()->getVersion();
 				message.setValue("plugin_version", plugin_version);
 				sendMessage(message);
-				
-				// Plugin gets to decide the texture parameters to use.
-				mDepth = 4;
-
-				message.setMessage(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params");
-				message.setValueS32("default_width", 1024);
-				message.setValueS32("default_height", 1024);
-				message.setValueS32("depth", mDepth);
-				message.setValueU32("internalformat", GL_RGBA);
-#if LL_QTWEBKIT_USES_PIXMAPS
-				message.setValueU32("format", GL_BGRA_EXT); // I hope this isn't system-dependant... is it?  If so, we'll have to check the root window's pixel layout or something... yuck.
-#else
-				message.setValueU32("format", GL_RGBA);
-#endif // LL_QTWEBKIT_USES_PIXMAPS
-				message.setValueU32("type", GL_UNSIGNED_BYTE);
-				message.setValueBoolean("coords_opengl", true);
-				sendMessage(message);
 			}
 			else if(message_name == "idle")
 			{
@@ -771,7 +772,7 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)
 //				std::cerr << "MediaPluginWebKit::receiveMessage: unknown base message: " << message_name << std::endl;
 			}
 		}
-                else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME)
+		else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME)
 		{
 			if(message_name == "set_volume")
 			{
@@ -781,7 +782,50 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)
 		}
 		else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA)
 		{
-			if(message_name == "size_change")
+			if(message_name == "init")
+			{
+				// This is the media init message -- all necessary data for initialization should have been received.
+				if(initBrowser())
+				{
+					
+					// Plugin gets to decide the texture parameters to use.
+					mDepth = 4;
+
+					LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params");
+					message.setValueS32("default_width", 1024);
+					message.setValueS32("default_height", 1024);
+					message.setValueS32("depth", mDepth);
+					message.setValueU32("internalformat", GL_RGBA);
+	#if LL_QTWEBKIT_USES_PIXMAPS
+					message.setValueU32("format", GL_BGRA_EXT); // I hope this isn't system-dependant... is it?  If so, we'll have to check the root window's pixel layout or something... yuck.
+	#else
+					message.setValueU32("format", GL_RGBA);
+	#endif // LL_QTWEBKIT_USES_PIXMAPS
+					message.setValueU32("type", GL_UNSIGNED_BYTE);
+					message.setValueBoolean("coords_opengl", true);
+					sendMessage(message);
+				}
+				else
+				{
+					// if initialization failed, we're done.
+					mDeleteMe = true;
+				}
+
+			}
+			else if(message_name == "set_user_data_path")
+			{
+				std::string user_data_path = message_in.getValue("path"); // n.b. always has trailing platform-specific dir-delimiter
+				mProfileDir = user_data_path + "browser_profile";
+
+				// FIXME: Should we do anything with this if it comes in after the browser has been initialized?
+			}
+			else if(message_name == "set_language_code")
+			{
+				mHostLanguage = message_in.getValue("language");
+
+				// FIXME: Should we do anything with this if it comes in after the browser has been initialized?
+			}
+			else if(message_name == "size_change")
 			{
 				std::string name = message_in.getValue("name");
 				S32 width = message_in.getValueS32("width");
@@ -803,29 +847,36 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)
 						mWidth = width;
 						mHeight = height;
 
-						// initialize (only gets called once)
-						initBrowser();
-
-						// size changed so tell the browser
-						LLQtWebKit::getInstance()->setSize( mBrowserWindowId, mWidth, mHeight );
-						
-//						std::cerr << "webkit plugin: set size to " << mWidth << " x " << mHeight 
-//								<< ", rowspan is " << LLQtWebKit::getInstance()->getBrowserRowSpan(mBrowserWindowId) << std::endl;
-								
-						S32 real_width = LLQtWebKit::getInstance()->getBrowserRowSpan(mBrowserWindowId) / LLQtWebKit::getInstance()->getBrowserDepth(mBrowserWindowId); 
-						
-						// The actual width the browser will be drawing to is probably smaller... let the host know by modifying texture_width in the response.
-						if(real_width <= texture_width)
+						if(initBrowserWindow())
 						{
-							texture_width = real_width;
+
+							// size changed so tell the browser
+							LLQtWebKit::getInstance()->setSize( mBrowserWindowId, mWidth, mHeight );
+							
+	//						std::cerr << "webkit plugin: set size to " << mWidth << " x " << mHeight 
+	//								<< ", rowspan is " << LLQtWebKit::getInstance()->getBrowserRowSpan(mBrowserWindowId) << std::endl;
+									
+							S32 real_width = LLQtWebKit::getInstance()->getBrowserRowSpan(mBrowserWindowId) / LLQtWebKit::getInstance()->getBrowserDepth(mBrowserWindowId); 
+							
+							// The actual width the browser will be drawing to is probably smaller... let the host know by modifying texture_width in the response.
+							if(real_width <= texture_width)
+							{
+								texture_width = real_width;
+							}
+							else
+							{
+								// This won't work -- it'll be bigger than the allocated memory.  This is a fatal error.
+	//							std::cerr << "Fatal error: browser rowbytes greater than texture width" << std::endl;
+								mDeleteMe = true;
+								return;
+							}
 						}
 						else
 						{
-							// This won't work -- it'll be bigger than the allocated memory.  This is a fatal error.
-//							std::cerr << "Fatal error: browser rowbytes greater than texture width" << std::endl;
+							// Setting up the browser window failed.  This is a fatal error.
 							mDeleteMe = true;
-							return;
 						}
+
 						
 						mTextureWidth = texture_width;
 						mTextureHeight = texture_height;
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 64dcd62a6a0e1f260036c9e01004334193e48578..b9509a98f5052b01f40f00f65389effad31bc0d4 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -1258,8 +1258,9 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_
 		{
 			LLPluginClassMedia* media_source = new LLPluginClassMedia(owner);
 			media_source->setSize(default_width, default_height);
-			std::string language_code = LLUI::getLanguage();
-			if (media_source->init(launcher_name, plugin_name, gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins"), user_data_path, language_code))
+			media_source->setUserDataPath(user_data_path);
+			media_source->setLanguageCode(LLUI::getLanguage());
+			if (media_source->init(launcher_name, plugin_name, gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins")))
 			{
 				return media_source;
 			}
diff --git a/indra/test_apps/llplugintest/llmediaplugintest.cpp b/indra/test_apps/llplugintest/llmediaplugintest.cpp
index e5a846f15a110e882d31aa0465225fc4939de3c7..5677308fb0bf2b135fe50f18e235f1e2f12414cf 100644
--- a/indra/test_apps/llplugintest/llmediaplugintest.cpp
+++ b/indra/test_apps/llplugintest/llmediaplugintest.cpp
@@ -1593,8 +1593,8 @@ void LLMediaPluginTest::addMediaPanel( std::string url )
 	}
 	std::string user_data_path = std::string( cwd ) + "/";
 #endif
-
-	media_source->init( launcher_name, plugin_name, false, user_data_path );
+	media_source->setUserDataPath(user_data_path);
+	media_source->init( launcher_name, plugin_name, false );
 	media_source->setDisableTimeout(mDisableTimeout);
 
 	// make a new panel and save parameters
@@ -1831,7 +1831,8 @@ void LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
 	std::string user_data_path = std::string( cwd ) + "/";
 #endif
 
-	media_source->init( launcher_name, plugin_name, false, user_data_path );
+	media_source->setUserDataPath(user_data_path);
+	media_source->init( launcher_name, plugin_name, false );
 	media_source->setDisableTimeout(mDisableTimeout);
 
 	// make a new panel and save parameters