Webkit plugin updates

Updated the webkit plugin with the latest features
Fixed SSL support in webkit
Other minor cleanup
This commit is contained in:
Drake Arconis
2012-07-06 11:35:07 +00:00
parent b40a9c7a06
commit 525e9d9a8e
21 changed files with 399 additions and 90 deletions

181
indra/plugins/webkit/media_plugin_webkit.cpp Executable file → Normal file
View File

@@ -90,6 +90,7 @@ private:
bool mCookiesEnabled;
bool mJavascriptEnabled;
bool mPluginsEnabled;
bool mEnableMediaPluginDebugging;
enum
{
@@ -116,9 +117,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;
@@ -144,7 +160,7 @@ private:
mVolumeCatcher.pump();
checkEditState();
if(mInitState == INIT_STATE_NAVIGATE_COMPLETE)
{
if(!mInitialNavigateURL.empty())
@@ -228,7 +244,7 @@ private:
#endif
#if LL_WINDOWS
// *NOTE:Mani - On windows, at least, the component path is the
//*NOTE:Mani - On windows, at least, the component path is the
// location of this dll's image file.
std::string component_dir;
char dll_path[_MAX_PATH];
@@ -252,6 +268,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 +285,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,6 +317,7 @@ private:
if(!mHostLanguage.empty())
{
LLQtWebKit::getInstance()->setHostLanguage(mHostLanguage);
postDebugMessage( "Setting language to " + mHostLanguage );
}
// turn on/off cookies based on what host app tells us
@@ -307,8 +333,17 @@ private:
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);
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 );
@@ -318,6 +353,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
@@ -345,8 +381,18 @@ private:
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;
//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" );
@@ -413,9 +459,11 @@ private:
message.setValue("uri", event.getEventUri());
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);
}
@@ -457,6 +505,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() );
}
////////////////////////////////////////////////////////////////////////////////
@@ -494,7 +544,7 @@ private:
sendMessage(message);
}
}
////////////////////////////////////////////////////////////////////////////////
// virtual
void onNavigateErrorPage(const EventType& event)
@@ -503,7 +553,7 @@ private:
message.setValueS32("status_code", event.getIntValue());
sendMessage(message);
}
////////////////////////////////////////////////////////////////////////////////
// virtual
void onLocationChange(const EventType& event)
@@ -540,6 +590,7 @@ private:
#endif
sendMessage(message);
}
////////////////////////////////////////////////////////////////////////////////
// virtual
@@ -550,10 +601,14 @@ 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);
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// virtual
void onWindowCloseRequested(const EventType& event)
{
@@ -581,7 +636,7 @@ private:
sendMessage(message);
}
}
std::string mAuthUsername;
std::string mAuthPassword;
bool mAuthOK;
@@ -632,7 +687,7 @@ private:
sendMessage(message);
}
}
LLQtWebKit::EKeyboardModifier decodeModifiers(std::string &modifiers)
{
int result = 0;
@@ -801,7 +856,10 @@ MediaPluginWebKit::MediaPluginWebKit(LLPluginInstance::sendMessageFunction send_
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()
@@ -828,8 +886,6 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)
{
if(message_name == "init")
{
mTarget = message_in.getValue("target");
LLPluginMessage message("base", "init_response");
LLSD versions = LLSD::emptyMap();
versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION;
@@ -909,7 +965,7 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)
{
if(message_name == "set_volume")
{
F32 volume = message_in.getValueReal("volume");
F32 volume = (F32)message_in.getValueReal("volume");
setVolume(volume);
}
}
@@ -917,6 +973,8 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)
{
if(message_name == "init")
{
mTarget = message_in.getValue("target");
// This is the media init message -- all necessary data for initialization should have been received.
if(initBrowser())
{
@@ -1139,7 +1197,78 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)
if(message_name == "auth_response")
{
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 = (F32)message_in.getValueReal("x");
F32 y = (F32)message_in.getValueReal("y");
F32 z = (F32)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 = (F32)message_in.getValueReal("x");
F32 y = (F32)message_in.getValueReal("y");
F32 z = (F32)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 = (F32)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;
@@ -1161,6 +1290,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 = (F32)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();
@@ -1187,6 +1325,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")
{
@@ -1248,7 +1389,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