Add support for copy/cut/paste into and out of browser

(Note - feature in LLQtWebKit (canPaste, canCut etc.) not present so right click menu always enables options
master
callum_linden 2015-09-02 17:31:40 -07:00
parent d44eeb48d3
commit 33da4d9d5d
2 changed files with 75 additions and 6 deletions

View File

@ -1536,11 +1536,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>66f0127fcb3b2169a15fb09ae0387977</string>
<string>6b727137b63a321298cba87863db2147</string>
<key>hash_algorithm</key>
<string>md5</string>
<key>url</key>
<string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/llceflib_3p-llceflib/rev/304745/arch/Darwin/installer/llceflib-1.0.1.304745-darwin-304745.tar.bz2</string>
<string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/llceflib_3p-llceflib/rev/304772/arch/Darwin/installer/llceflib-1.0.1.304772-darwin-304772.tar.bz2</string>
</map>
<key>name</key>
<string>darwin</string>
@ -1550,18 +1550,18 @@
<key>archive</key>
<map>
<key>hash</key>
<string>beff3d2db9cfac56e8e6c2ceabfa10f1</string>
<string>fba9f44aa66b81d41a26df4eed116eb9</string>
<key>hash_algorithm</key>
<string>md5</string>
<key>url</key>
<string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/llceflib_3p-llceflib/rev/304745/arch/CYGWIN/installer/llceflib-1.0.1.304745-windows-304745.tar.bz2</string>
<string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/llceflib_3p-llceflib/rev/304772/arch/CYGWIN/installer/llceflib-1.0.1.304772-windows-304772.tar.bz2</string>
</map>
<key>name</key>
<string>windows</string>
</map>
</map>
<key>version</key>
<string>1.0.1.304745</string>
<string>1.0.1.304772</string>
</map>
<key>llphysicsextensions_source</key>
<map>

View File

@ -64,6 +64,7 @@ private:
void onLoadStartCallback();
void onLoadEndCallback(int httpStatusCode);
void onNavigateURLCallback(std::string url);
void onExternalTargetLinkCallback(std::string url);
bool onHTTPAuthCallback(const std::string host, const std::string realm, std::string& username, std::string& password);
void postDebugMessage(const std::string& msg);
@ -74,6 +75,8 @@ private:
void keyEvent(EKeyEvent key_event, int key, EKeyboardModifier modifiers, LLSD native_key_data);
void unicodeInput(const std::string &utf8str, EKeyboardModifier modifiers, LLSD native_key_data);
void checkEditState();
bool mEnableMediaPluginDebugging;
std::string mHostLanguage;
bool mCookiesEnabled;
@ -83,6 +86,9 @@ private:
std::string mAuthUsername;
std::string mAuthPassword;
bool mAuthOK;
bool mCanCut;
bool mCanCopy;
bool mCanPaste;
std::string mCachePath;
std::string mCookiePath;
LLCEFLib* mLLCEFLib;
@ -106,6 +112,9 @@ MediaPluginBase(host_send_func, host_user_data)
mAuthUsername = "";
mAuthPassword = "";
mAuthOK = false;
mCanCut = false;
mCanCopy = false;
mCanPaste = false;
mCachePath = "";
mCookiePath = "";
mLLCEFLib = new LLCEFLib();
@ -217,6 +226,13 @@ void MediaPluginCEF::onNavigateURLCallback(std::string url)
sendMessage(message);
}
////////////////////////////////////////////////////////////////////////////////
// triggered when user clicks link with "external" attribute
void MediaPluginCEF::onExternalTargetLinkCallback(std::string url)
{
}
////////////////////////////////////////////////////////////////////////////////
//
bool MediaPluginCEF::onHTTPAuthCallback(const std::string host, const std::string realm, std::string& username, std::string& password)
@ -279,6 +295,11 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
else if (message_name == "idle")
{
mLLCEFLib->update();
// this seems bad but unless the state changes (it won't until we figure out
// how to get CEF to tell us if copy/cut/paste is available) then this function
// will return immediately
checkEditState();
}
else if (message_name == "cleanup")
{
@ -335,6 +356,7 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
mLLCEFLib->setOnLoadEndCallback(boost::bind(&MediaPluginCEF::onLoadEndCallback, this, _1));
mLLCEFLib->setOnNavigateURLCallback(boost::bind(&MediaPluginCEF::onNavigateURLCallback, this, _1));
mLLCEFLib->setOnHTTPAuthCallback(boost::bind(&MediaPluginCEF::onHTTPAuthCallback, this, _1, _2, _3, _4));
mLLCEFLib->setOnExternalTargetLinkCallback(boost::bind(&MediaPluginCEF::onExternalTargetLinkCallback, this, _1));
LLCEFLibSettings settings;
settings.inital_width = 1024;
@ -342,8 +364,9 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
settings.plugins_enabled = mPluginsEnabled;
settings.javascript_enabled = mJavascriptEnabled;
settings.cookies_enabled = mCookiesEnabled;
settings.cache_path = mCachePath;
settings.cookie_store_path = mCookiePath;
settings.cache_enabled = true;
settings.cache_path = mCachePath;
settings.accept_language_list = mHostLanguage;
settings.user_agent_substring = mUserAgentSubtring;
@ -513,6 +536,18 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
{
authResponse(message_in);
}
if (message_name == "edit_cut")
{
mLLCEFLib->editCut();
}
if (message_name == "edit_copy")
{
mLLCEFLib->editCopy();
}
if (message_name == "edit_paste")
{
mLLCEFLib->editPaste();
}
}
else if (message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER)
{
@ -653,6 +688,40 @@ void MediaPluginCEF::unicodeInput(const std::string &utf8str, EKeyboardModifier
#endif
};
////////////////////////////////////////////////////////////////////////////////
//
void MediaPluginCEF::checkEditState()
{
bool can_cut = mLLCEFLib->editCanCut();
bool can_copy = mLLCEFLib->editCanCopy();
bool can_paste = mLLCEFLib->editCanPaste();
if ((can_cut != mCanCut) || (can_copy != mCanCopy) || (can_paste != mCanPaste))
{
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "edit_state");
if (can_cut != mCanCut)
{
mCanCut = can_cut;
message.setValueBoolean("cut", can_cut);
}
if (can_copy != mCanCopy)
{
mCanCopy = can_copy;
message.setValueBoolean("copy", can_copy);
}
if (can_paste != mCanPaste)
{
mCanPaste = can_paste;
message.setValueBoolean("paste", can_paste);
}
sendMessage(message);
}
}
////////////////////////////////////////////////////////////////////////////////
//
bool MediaPluginCEF::init()