summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_adapter.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-09-04 13:27:03 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-09-16 00:08:38 +0000
commit26e4b786e64cf8d147a8978b550f16b4421cd188 (patch)
tree3db51eaae37635372f321dd51abe445e5e222a75 /src/core/web_contents_adapter.cpp
parent5da7063b172b80f8d3cca9ce0b75756375c36b8e (diff)
Set custom drag data as Chrome does
Expose any custom data in the pickled form Chrome uses. Task-number: QTBUG-61503 Change-Id: Ie89bd04f35b1dba94b91e87960cde66238d738df Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r--src/core/web_contents_adapter.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 827349115..2b7ab03dd 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -82,6 +82,8 @@
#include "content/public/common/web_preferences.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
#include "printing/features/features.h"
+#include "ui/base/clipboard/clipboard.h"
+#include "ui/base/clipboard/custom_data_helper.h"
#include "ui/gfx/font_render_params.h"
#include <QDir>
@@ -1176,6 +1178,11 @@ static QMimeData *mimeDataFromDropData(const content::DropData &dropData)
mimeData->setHtml(toQt(dropData.html.string()));
if (dropData.url.is_valid())
mimeData->setUrls(QList<QUrl>() << toQt(dropData.url));
+ if (!dropData.custom_data.empty()) {
+ base::Pickle pickle;
+ ui::WriteCustomDataToPickle(dropData.custom_data, &pickle);
+ mimeData->setData(toQt(ui::Clipboard::GetWebCustomDataFormatType().ToString()), QByteArray((const char*)pickle.data(), pickle.size()));
+ }
return mimeData;
}
@@ -1291,6 +1298,10 @@ static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeDat
dropData->html = toNullableString16(mimeData->html());
if (mimeData->hasText())
dropData->text = toNullableString16(mimeData->text());
+ if (mimeData->hasFormat(toQt(ui::Clipboard::GetWebCustomDataFormatType().ToString()))) {
+ QByteArray customData = mimeData->data(toQt(ui::Clipboard::GetWebCustomDataFormatType().ToString()));
+ ui::ReadCustomDataIntoMap(customData.constData(), customData.length(), &dropData->custom_data);
+ }
}
void WebContentsAdapter::enterDrag(QDragEnterEvent *e, const QPoint &screenPos)