diff options
Diffstat (limited to 'indra/media_plugins/webkit')
| -rw-r--r-- | indra/media_plugins/webkit/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | indra/media_plugins/webkit/media_plugin_webkit.cpp | 148 | 
2 files changed, 144 insertions, 8 deletions
| diff --git a/indra/media_plugins/webkit/CMakeLists.txt b/indra/media_plugins/webkit/CMakeLists.txt index 3b1f679540..b36291f0e8 100644 --- a/indra/media_plugins/webkit/CMakeLists.txt +++ b/indra/media_plugins/webkit/CMakeLists.txt @@ -121,8 +121,8 @@ if (DARWIN)    add_custom_command(      TARGET media_plugin_webkit POST_BUILD  #    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllqtwebkit.dylib -    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libllqtwebkit.dylib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ -    DEPENDS media_plugin_webkit ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libllqtwebkit.dylib +    COMMAND ${CMAKE_COMMAND} -E copy ${ARCH_PREBUILT_DIRS_RELEASE}/libllqtwebkit.dylib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ +    DEPENDS media_plugin_webkit ${ARCH_PREBUILT_DIRS_RELEASE}/libllqtwebkit.dylib      )  endif (DARWIN) diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp index d6f8ae3e16..0f74772e42 100644 --- a/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp @@ -90,6 +90,7 @@ private:  	bool mCookiesEnabled;  	bool mJavascriptEnabled;  	bool mPluginsEnabled; +	bool mEnableMediaPluginDebugging;  	enum  	{ @@ -119,6 +120,17 @@ private:  	VolumeCatcher mVolumeCatcher; +	void postDebugMessage( const std::string& msg ) +	{ +		if ( mEnableMediaPluginDebugging ) +		{ +			LLPluginMessage debug_message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "debug_message"); +			debug_message.setValue("message_text", "Media> " + msg); +			debug_message.setValue("message_level", "info"); +			sendMessage(debug_message); +		} +	} +	  	void setInitState(int state)  	{  //		std::cerr << "changing init state to " << state << std::endl; @@ -252,6 +264,9 @@ private:  		std::string component_dir = application_dir;  #endif +		// debug spam sent to viewer and displayed in the log as usual +		postDebugMessage( "Component dir set to: " + component_dir ); +  		// window handle - needed on Windows and must be app window.  #if LL_WINDOWS  		char window_title[ MAX_PATH ]; @@ -266,10 +281,16 @@ private:  		if ( result )  		{  			mInitState = INIT_STATE_INITIALIZED; -			 + +			// debug spam sent to viewer and displayed in the log as usual +			postDebugMessage( "browser initialized okay" ); +  			return true;  		}; +		// debug spam sent to viewer and displayed in the log as usual +		postDebugMessage( "browser nOT initialized." ); +  		return false;  	}; @@ -292,20 +313,30 @@ private:  		if(!mHostLanguage.empty())  		{  			LLQtWebKit::getInstance()->setHostLanguage(mHostLanguage); +			postDebugMessage( "Setting language to " + mHostLanguage );  		}  		// turn on/off cookies based on what host app tells us  		LLQtWebKit::getInstance()->enableCookies( mCookiesEnabled ); - +		  		// turn on/off plugins based on what host app tells us  		LLQtWebKit::getInstance()->enablePlugins( mPluginsEnabled );  		// turn on/off Javascript based on what host app tells us  		LLQtWebKit::getInstance()->enableJavascript( mJavascriptEnabled ); -		 + +		std::stringstream str; +		str << "Cookies enabled = " << mCookiesEnabled << ", plugins enabled = " << mPluginsEnabled << ", Javascript enabled = " << mJavascriptEnabled; +		postDebugMessage( str.str() ); +  		// create single browser window  		mBrowserWindowId = LLQtWebKit::getInstance()->createBrowserWindow( mWidth, mHeight, mTarget); +		str.str(""); +		str.clear(); +		str << "Setting browser window size to " << mWidth << " x " << mHeight; +		postDebugMessage( str.str() ); +  		// tell LLQtWebKit about the size of the browser window  		LLQtWebKit::getInstance()->setSize( mBrowserWindowId, mWidth, mHeight ); @@ -314,6 +345,7 @@ private:  		// append details to agent string  		LLQtWebKit::getInstance()->setBrowserAgentId( mUserAgent ); +		postDebugMessage( "Updating user agent with " + mUserAgent );  #if !LL_QTWEBKIT_USES_PIXMAPS  		// don't flip bitmap @@ -410,7 +442,10 @@ private:  			message.setValueBoolean("history_back_available", LLQtWebKit::getInstance()->userActionIsEnabled( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_BACK));  			message.setValueBoolean("history_forward_available", LLQtWebKit::getInstance()->userActionIsEnabled( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_FORWARD));  			sendMessage(message); -		 + +			// debug spam sent to viewer and displayed in the log as usual +			postDebugMessage( "Navigate begin event at: " + event.getEventUri() ); +  			setStatus(STATUS_LOADING);  		} @@ -452,6 +487,8 @@ private:  			setInitState(INIT_STATE_NAVIGATE_COMPLETE);  		} +		// debug spam sent to viewer and displayed in the log as usual +		postDebugMessage( "Navigate complete event at: " + event.getEventUri() );  	}  	//////////////////////////////////////////////////////////////////////////////// @@ -492,6 +529,15 @@ private:  	////////////////////////////////////////////////////////////////////////////////  	// virtual +	void onNavigateErrorPage(const EventType& event) +	{ +		LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_error_page"); +		message.setValueS32("status_code", event.getIntValue()); +		sendMessage(message); +	} +	 +	//////////////////////////////////////////////////////////////////////////////// +	// virtual  	void onLocationChange(const EventType& event)  	{  		if(mInitState >= INIT_STATE_NAVIGATE_COMPLETE) @@ -519,6 +565,11 @@ private:  	{  		LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "click_nofollow");  		message.setValue("uri", event.getEventUri()); +#if LLQTWEBKIT_API_VERSION >= 7 +		message.setValue("nav_type", event.getNavigationType()); +#else +		message.setValue("nav_type", "clicked"); +#endif  		sendMessage(message);  	} @@ -810,6 +861,7 @@ MediaPluginWebKit::MediaPluginWebKit(LLPluginInstance::sendMessageFunction host_  	mHostLanguage = "en";		// default to english  	mJavascriptEnabled = true;	// default to on  	mPluginsEnabled = true;		// default to on +	mEnableMediaPluginDebugging = false;  	mUserAgent = "LLPluginMedia Web Browser";  } @@ -1154,6 +1206,78 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)  				authResponse(message_in);  			}  			else +			if(message_name == "enable_media_plugin_debugging") +			{ +				mEnableMediaPluginDebugging = message_in.getValueBoolean( "enable" ); +			} + +			else +			if(message_name == "js_enable_object") +			{ +#if LLQTWEBKIT_API_VERSION >= 9 +				bool enable = message_in.getValueBoolean( "enable" ); +				LLQtWebKit::getInstance()->setSLObjectEnabled( enable ); +#endif +			} +			else +			if(message_name == "js_agent_location") +			{ +#if LLQTWEBKIT_API_VERSION >= 9 +				F32 x = message_in.getValueReal("x"); +				F32 y = message_in.getValueReal("y"); +				F32 z = message_in.getValueReal("z"); +				LLQtWebKit::getInstance()->setAgentLocation( x, y, z ); +				LLQtWebKit::getInstance()->emitLocation(); +#endif +			} +			else +			if(message_name == "js_agent_global_location") +			{ +#if LLQTWEBKIT_API_VERSION >= 9 +				F32 x = message_in.getValueReal("x"); +				F32 y = message_in.getValueReal("y"); +				F32 z = message_in.getValueReal("z"); +				LLQtWebKit::getInstance()->setAgentGlobalLocation( x, y, z ); +				LLQtWebKit::getInstance()->emitLocation(); +#endif +			} +			else			 +			if(message_name == "js_agent_orientation") +			{ +#if LLQTWEBKIT_API_VERSION >= 9 +				F32 angle = message_in.getValueReal("angle"); +				LLQtWebKit::getInstance()->setAgentOrientation( angle ); +				LLQtWebKit::getInstance()->emitLocation(); +#endif +			} +			else +			if(message_name == "js_agent_region") +			{ +#if LLQTWEBKIT_API_VERSION >= 9 +				const std::string& region = message_in.getValue("region"); +				LLQtWebKit::getInstance()->setAgentRegion( region ); +				LLQtWebKit::getInstance()->emitLocation(); +#endif +			} +			else +				if(message_name == "js_agent_maturity") +				{ +#if LLQTWEBKIT_API_VERSION >= 9 +					const std::string& maturity = message_in.getValue("maturity"); +					LLQtWebKit::getInstance()->setAgentMaturity( maturity ); +					LLQtWebKit::getInstance()->emitMaturity(); +#endif +				} +			else +			if(message_name == "js_agent_language") +			{ +#if LLQTWEBKIT_API_VERSION >= 9 +				const std::string& language = message_in.getValue("language"); +				LLQtWebKit::getInstance()->setAgentLanguage( language ); +				LLQtWebKit::getInstance()->emitLanguage(); +#endif +			} +			else  			{  //				std::cerr << "MediaPluginWebKit::receiveMessage: unknown media message: " << message_string << std::endl;  			} @@ -1231,7 +1355,9 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)  				std::string url = message_in.getValue("url");  				if ( 404 == code )	// browser lib only supports 404 right now  				{ -					LLQtWebKit::getInstance()->set404RedirectUrl( mBrowserWindowId, url ); +#if LLQTWEBKIT_API_VERSION < 8 +				 	LLQtWebKit::getInstance()->set404RedirectUrl( mBrowserWindowId, url ); +#endif  				};  			}  			else if(message_name == "set_user_agent") @@ -1239,6 +1365,15 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)  				mUserAgent = message_in.getValue("user_agent");  				LLQtWebKit::getInstance()->setBrowserAgentId( mUserAgent );  			} +			else if(message_name == "show_web_inspector") +			{ +#if LLQTWEBKIT_API_VERSION >= 10 +				bool val = message_in.getValueBoolean("show"); +				LLQtWebKit::getInstance()->showWebInspector( val ); +#else +				llwarns << "Ignoring showWebInspector message (llqtwebkit version is too old)." << llendl; +#endif +			}  			else if(message_name == "ignore_ssl_cert_errors")  			{  #if LLQTWEBKIT_API_VERSION >= 3 @@ -1250,7 +1385,7 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)  			else if(message_name == "add_certificate_file_path")  			{  #if LLQTWEBKIT_API_VERSION >= 6 -				LLQtWebKit::getInstance()->addCAFile( message_in.getValue("path") ); +				LLQtWebKit::getInstance()->setCAFile( message_in.getValue("path") );  #else  				llwarns << "Ignoring add_certificate_file_path message (llqtwebkit version is too old)." << llendl;  #endif @@ -1309,3 +1444,4 @@ int init_media_plugin(LLPluginInstance::sendMessageFunction host_send_func, void  	return 0;  } + | 
