diff options
Diffstat (limited to 'indra/media_plugins/webkit/media_plugin_webkit.cpp')
-rw-r--r-- | indra/media_plugins/webkit/media_plugin_webkit.cpp | 107 |
1 files changed, 97 insertions, 10 deletions
diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp index fca071c628..47f8dcd545 100644 --- a/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp @@ -25,12 +25,11 @@ * $/LicenseInfo$ * @endcond */ - #include "llqtwebkit.h" - #include "linden_common.h" #include "indra_constants.h" // for indra keyboard codes +#include "lltimer.h" #include "llgl.h" #include "llplugininstance.h" @@ -90,6 +89,7 @@ private: bool mCookiesEnabled; bool mJavascriptEnabled; bool mPluginsEnabled; + bool mEnableMediaPluginDebugging; enum { @@ -116,9 +116,24 @@ private: F32 mBackgroundG; F32 mBackgroundB; std::string mTarget; - + LLTimer mElapsedTime; + VolumeCatcher mVolumeCatcher; + void postDebugMessage( const std::string& msg ) + { + if ( mEnableMediaPluginDebugging ) + { + std::stringstream str; + str << "@Media Msg> " << "[" << (double)mElapsedTime.getElapsedTimeF32() << "] -- " << msg; + + LLPluginMessage debug_message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "debug_message"); + debug_message.setValue("message_text", str.str()); + debug_message.setValue("message_level", "info"); + sendMessage(debug_message); + } + } + void setInitState(int state) { // std::cerr << "changing init state to " << state << std::endl; @@ -252,6 +267,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 +284,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 +316,34 @@ 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 +#if LLQTWEBKIT_API_VERSION >= 11 + LLQtWebKit::getInstance()->enableJavaScript( mJavascriptEnabled ); +#else LLQtWebKit::getInstance()->enableJavascript( mJavascriptEnabled ); - +#endif + + 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,7 +352,8 @@ 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 LLQtWebKit::getInstance()->flipWindow( mBrowserWindowId, true ); @@ -342,7 +381,17 @@ private: url << "%22%3E%3C/body%3E%3C/html%3E"; //lldebugs << "data url is: " << url.str() << llendl; - + + // always display loading overlay now +#if LLQTWEBKIT_API_VERSION >= 16 + LLQtWebKit::getInstance()->enableLoadingOverlay(mBrowserWindowId, true); +#else + llwarns << "Ignoring enableLoadingOverlay() call (llqtwebkit version is too old)." << llendl; +#endif + str.clear(); + str << "Loading overlay enabled = " << mEnableMediaPluginDebugging << " for mBrowserWindowId = " << mBrowserWindowId; + postDebugMessage( str.str() ); + LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, url.str() ); // LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, "about:blank" ); @@ -410,7 +459,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 +504,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() ); } //////////////////////////////////////////////////////////////////////////////// @@ -546,6 +600,10 @@ private: // These could be passed through as well, but aren't really needed. // message.setValue("uri", event.getEventUri()); // message.setValueBoolean("dead", (event.getIntValue() != 0)) + + // debug spam + postDebugMessage( "Sending cookie_set message from plugin: " + event.getStringValue() ); + sendMessage(message); } @@ -824,7 +882,10 @@ 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"; + + mElapsedTime.reset(); } MediaPluginWebKit::~MediaPluginWebKit() @@ -1168,6 +1229,11 @@ 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 @@ -1254,6 +1320,15 @@ void MediaPluginWebKit::receiveMessage(const char *message_string) mFirstFocus = false; } } + else if(message_name == "set_page_zoom_factor") + { +#if LLQTWEBKIT_API_VERSION >= 15 + F32 factor = message_in.getValueReal("factor"); + LLQtWebKit::getInstance()->setPageZoomFactor(factor); +#else + llwarns << "Ignoring setPageZoomFactor message (llqtwebkit version is too old)." << llendl; +#endif + } else if(message_name == "clear_cache") { LLQtWebKit::getInstance()->clearCache(); @@ -1280,6 +1355,9 @@ void MediaPluginWebKit::receiveMessage(const char *message_string) else if(message_name == "set_cookies") { LLQtWebKit::getInstance()->setCookies(message_in.getValue("cookies")); + + // debug spam + postDebugMessage( "Plugin setting cookie: " + message_in.getValue("cookies") ); } else if(message_name == "proxy_setup") { @@ -1321,6 +1399,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 @@ -1332,7 +1419,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 |