From 26e4b786e64cf8d147a8978b550f16b4421cd188 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 4 Sep 2017 13:27:03 +0200 Subject: 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 --- src/core/web_contents_adapter.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/core') 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 @@ -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() << 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) -- cgit v1.2.3