summaryrefslogtreecommitdiff
path: root/indra/media_plugins/cef/media_plugin_cef.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/media_plugins/cef/media_plugin_cef.cpp')
-rw-r--r--indra/media_plugins/cef/media_plugin_cef.cpp129
1 files changed, 97 insertions, 32 deletions
diff --git a/indra/media_plugins/cef/media_plugin_cef.cpp b/indra/media_plugins/cef/media_plugin_cef.cpp
index f3d7762a08..2ac43accc5 100644
--- a/indra/media_plugins/cef/media_plugin_cef.cpp
+++ b/indra/media_plugins/cef/media_plugin_cef.cpp
@@ -38,6 +38,7 @@
#include "media_plugin_base.h"
#include <functional>
+#include <chrono>
#include "dullahan.h"
@@ -64,12 +65,12 @@ private:
void onLoadStartCallback();
void onRequestExitCallback();
void onLoadEndCallback(int httpStatusCode);
+ void onLoadError(int status, const std::string error_text);
void onAddressChangeCallback(std::string url);
- void onNavigateURLCallback(std::string url, std::string target);
+ void onOpenPopupCallback(std::string url, std::string target);
bool onHTTPAuthCallback(const std::string host, const std::string realm, std::string& username, std::string& password);
void onCursorChangedCallback(dullahan::ECursorType type);
- void onFileDownloadCallback(std::string filename);
- const std::string onFileDialogCallback();
+ const std::vector<std::string> onFileDialog(dullahan::EFileDialogType dialog_type, const std::string dialog_title, const std::string default_file, const std::string dialog_accept_filter, bool& use_default);
void postDebugMessage(const std::string& msg);
void authResponse(LLPluginMessage &message);
@@ -95,7 +96,9 @@ private:
bool mCanPaste;
std::string mCachePath;
std::string mCookiePath;
- std::string mPickedFile;
+ std::string mCefLogFile;
+ bool mCefLogVerbose;
+ std::vector<std::string> mPickedFiles;
VolumeCatcher mVolumeCatcher;
F32 mCurVolume;
dullahan* mCEFLib;
@@ -115,7 +118,7 @@ MediaPluginBase(host_send_func, host_user_data)
mCookiesEnabled = true;
mPluginsEnabled = false;
mJavascriptEnabled = true;
- mDisableGPU = true;
+ mDisableGPU = false;
mUserAgentSubtring = "";
mAuthUsername = "";
mAuthPassword = "";
@@ -125,7 +128,9 @@ MediaPluginBase(host_send_func, host_user_data)
mCanPaste = false;
mCachePath = "";
mCookiePath = "";
- mPickedFile = "";
+ mCefLogFile = "";
+ mCefLogVerbose = false;
+ mPickedFiles.clear();
mCurVolume = 0.0;
mCEFLib = new dullahan();
@@ -166,6 +171,10 @@ void MediaPluginCEF::onPageChangedCallback(const unsigned char* pixels, int x, i
{
memcpy(mPixels, pixels, mWidth * mHeight * mDepth);
}
+ else
+ {
+ mCEFLib->setSize(mWidth, mHeight);
+ }
setDirty(0, 0, mWidth, mHeight);
}
}
@@ -194,6 +203,8 @@ void MediaPluginCEF::onTitleChangeCallback(std::string title)
{
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "name_text");
message.setValue("name", title);
+ message.setValueBoolean("history_back_available", mCEFLib->canGoBack());
+ message.setValueBoolean("history_forward_available", mCEFLib->canGoForward());
sendMessage(message);
}
@@ -208,6 +219,21 @@ void MediaPluginCEF::onLoadStartCallback()
sendMessage(message);
}
+/////////////////////////////////////////////////////////////////////////////////
+//
+void MediaPluginCEF::onLoadError(int status, const std::string error_text)
+{
+ std::stringstream msg;
+
+ msg << "<b>Loading error!</b>";
+ msg << "<p>";
+ msg << "Message: " << error_text;
+ msg << "<br>";
+ msg << "Code: " << status;
+
+ mCEFLib->showBrowserMessage(msg.str());
+}
+
////////////////////////////////////////////////////////////////////////////////
//
void MediaPluginCEF::onRequestExitCallback()
@@ -241,12 +267,11 @@ void MediaPluginCEF::onAddressChangeCallback(std::string url)
////////////////////////////////////////////////////////////////////////////////
//
-void MediaPluginCEF::onNavigateURLCallback(std::string url, std::string target)
+void MediaPluginCEF::onOpenPopupCallback(std::string url, std::string target)
{
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "click_href");
message.setValue("uri", url);
message.setValue("target", target);
- message.setValue("uuid", ""); // not used right now
sendMessage(message);
}
@@ -285,30 +310,52 @@ bool MediaPluginCEF::onHTTPAuthCallback(const std::string host, const std::strin
////////////////////////////////////////////////////////////////////////////////
//
-void MediaPluginCEF::onFileDownloadCallback(const std::string filename)
+const std::vector<std::string> MediaPluginCEF::onFileDialog(dullahan::EFileDialogType dialog_type, const std::string dialog_title, const std::string default_file, std::string dialog_accept_filter, bool& use_default)
{
- mAuthOK = false;
+ // do not use the default CEF file picker
+ use_default = false;
- LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "file_download");
- message.setValue("filename", filename);
+ if (dialog_type == dullahan::FD_OPEN_FILE)
+ {
+ mPickedFiles.clear();
- sendMessage(message);
-}
+ LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "pick_file");
+ message.setValueBoolean("blocking_request", true);
+ message.setValueBoolean("multiple_files", false);
-////////////////////////////////////////////////////////////////////////////////
-//
-const std::string MediaPluginCEF::onFileDialogCallback()
-{
- mPickedFile.clear();
+ sendMessage(message);
- LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "pick_file");
- message.setValueBoolean("blocking_request", true);
+ return mPickedFiles;
+ }
+ else if (dialog_type == dullahan::FD_OPEN_MULTIPLE_FILES)
+ {
+ mPickedFiles.clear();
- sendMessage(message);
+ LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "pick_file");
+ message.setValueBoolean("blocking_request", true);
+ message.setValueBoolean("multiple_files", true);
- return mPickedFile;
+ sendMessage(message);
+
+ return mPickedFiles;
+ }
+ else if (dialog_type == dullahan::FD_SAVE_FILE)
+ {
+ mAuthOK = false;
+
+ LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "file_download");
+ message.setValue("filename", default_file);
+
+ sendMessage(message);
+
+ return std::vector<std::string>();
+ }
+
+ return std::vector<std::string>();
}
+////////////////////////////////////////////////////////////////////////////////
+//
void MediaPluginCEF::onCursorChangedCallback(dullahan::ECursorType type)
{
std::string name = "";
@@ -341,6 +388,8 @@ void MediaPluginCEF::onCursorChangedCallback(dullahan::ECursorType type)
sendMessage(message);
}
+////////////////////////////////////////////////////////////////////////////////
+//
void MediaPluginCEF::authResponse(LLPluginMessage &message)
{
mAuthOK = message.getValueBoolean("ok");
@@ -373,7 +422,7 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER] = LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER_VERSION;
message.setValueLLSD("versions", versions);
- std::string plugin_version = "CEF plugin 1.1.3";
+ std::string plugin_version = "CEF plugin 1.1.412";
message.setValue("plugin_version", plugin_version);
sendMessage(message);
}
@@ -439,17 +488,17 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
mCEFLib->setOnTitleChangeCallback(std::bind(&MediaPluginCEF::onTitleChangeCallback, this, std::placeholders::_1));
mCEFLib->setOnLoadStartCallback(std::bind(&MediaPluginCEF::onLoadStartCallback, this));
mCEFLib->setOnLoadEndCallback(std::bind(&MediaPluginCEF::onLoadEndCallback, this, std::placeholders::_1));
+ mCEFLib->setOnLoadErrorCallback(std::bind(&MediaPluginCEF::onLoadError, this, std::placeholders::_1, std::placeholders::_2));
mCEFLib->setOnAddressChangeCallback(std::bind(&MediaPluginCEF::onAddressChangeCallback, this, std::placeholders::_1));
- mCEFLib->setOnNavigateURLCallback(std::bind(&MediaPluginCEF::onNavigateURLCallback, this, std::placeholders::_1, std::placeholders::_2));
+ mCEFLib->setOnOpenPopupCallback(std::bind(&MediaPluginCEF::onOpenPopupCallback, this, std::placeholders::_1, std::placeholders::_2));
mCEFLib->setOnHTTPAuthCallback(std::bind(&MediaPluginCEF::onHTTPAuthCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
- mCEFLib->setOnFileDownloadCallback(std::bind(&MediaPluginCEF::onFileDownloadCallback, this, std::placeholders::_1));
- mCEFLib->setOnFileDialogCallback(std::bind(&MediaPluginCEF::onFileDialogCallback, this));
+ mCEFLib->setOnFileDialogCallback(std::bind(&MediaPluginCEF::onFileDialog, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
mCEFLib->setOnCursorChangedCallback(std::bind(&MediaPluginCEF::onCursorChangedCallback, this, std::placeholders::_1));
mCEFLib->setOnRequestExitCallback(std::bind(&MediaPluginCEF::onRequestExitCallback, this));
dullahan::dullahan_settings settings;
settings.accept_language_list = mHostLanguage;
- settings.background_color = 0xffffffff;
+ settings.background_color = 0xff282828;
settings.cache_enabled = true;
settings.cache_path = mCachePath;
settings.cookie_store_path = mCookiePath;
@@ -468,6 +517,8 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
settings.plugins_enabled = mPluginsEnabled;
settings.user_agent_substring = mCEFLib->makeCompatibleUserAgentString(mUserAgentSubtring);
settings.webgl_enabled = true;
+ settings.log_file = mCefLogFile;
+ settings.log_verbose = mCefLogVerbose;
std::vector<std::string> custom_schemes(1, "secondlife");
mCEFLib->setCustomSchemes(custom_schemes);
@@ -497,8 +548,11 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
{
std::string user_data_path_cache = message_in.getValue("cache_path");
std::string user_data_path_cookies = message_in.getValue("cookies_path");
+
mCachePath = user_data_path_cache + "cef_cache";
mCookiePath = user_data_path_cookies + "cef_cookies";
+ mCefLogFile = message_in.getValue("cef_log_file");
+ mCefLogVerbose = message_in.getValueBoolean("cef_verbose_log");
}
else if (message_name == "size_change")
{
@@ -520,11 +574,11 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
mTextureWidth = texture_width;
mTextureHeight = texture_height;
+
+ mCEFLib->setSize(mWidth, mHeight);
};
};
- mCEFLib->setSize(mWidth, mHeight);
-
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response");
message.setValue("name", name);
message.setValueS32("width", width);
@@ -650,7 +704,14 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
}
if (message_name == "pick_file_response")
{
- mPickedFile = message_in.getValue("file");
+ LLSD file_list_llsd = message_in.getValueLLSD("file_list");
+
+ LLSD::array_const_iterator iter = file_list_llsd.beginArray();
+ LLSD::array_const_iterator end = file_list_llsd.endArray();
+ for (; iter != end; ++iter)
+ {
+ mPickedFiles.push_back(((*iter).asString()));
+ }
}
if (message_name == "auth_response")
{
@@ -697,6 +758,10 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
{
mCookiesEnabled = message_in.getValueBoolean("enable");
}
+ else if (message_name == "clear_cookies")
+ {
+ mCEFLib->deleteAllCookies();
+ }
else if (message_name == "set_user_agent")
{
mUserAgentSubtring = message_in.getValue("user_agent");
@@ -746,7 +811,7 @@ void MediaPluginCEF::keyEvent(dullahan::EKeyEvent key_event, LLSD native_key_dat
// adding new code below in unicodeInput means we don't send ascii chars
// here too or we get double key presses on a mac.
- if (((unsigned char)event_chars < 0x20 || (unsigned char)event_chars >= 0x7f ))
+ if (((unsigned char)event_chars < 0x10 || (unsigned char)event_chars >= 0x7f ))
{
mCEFLib->nativeKeyboardEventOSX(key_event, event_modifiers,
event_keycode, event_chars,