Commit c57fd97c authored by Zach Reizner's avatar Zach Reizner Committed by Commit Bot

Attach UTF8_STRING type data to data offer

The version of GTK3 used in Debian stretch does not use clipboard data
marked as test/plain, but will use UTF8_STRING.

Bug: 793688
Test: Paste from Chrome into gedit
Change-Id: Id1b08e270fd385d287c729fe5594832753b845df
Reviewed-on: https://chromium-review.googlesource.com/1000523
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549074}
parent 7aaccf95
...@@ -21,6 +21,7 @@ namespace exo { ...@@ -21,6 +21,7 @@ namespace exo {
namespace { namespace {
constexpr char kTextMimeTypeUtf8[] = "text/plain;charset=utf-8"; constexpr char kTextMimeTypeUtf8[] = "text/plain;charset=utf-8";
constexpr char kUtf8String[] = "UTF8_STRING";
constexpr char kUriListSeparator[] = "\r\n"; constexpr char kUriListSeparator[] = "\r\n";
class RefCountedString16 : public base::RefCountedMemory { class RefCountedString16 : public base::RefCountedMemory {
...@@ -181,9 +182,12 @@ void DataOffer::SetClipboardData(FileHelper* file_helper, ...@@ -181,9 +182,12 @@ void DataOffer::SetClipboardData(FileHelper* file_helper,
base::string16 content; base::string16 content;
data.ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &content); data.ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &content);
std::string utf8_content = base::UTF16ToUTF8(content); std::string utf8_content = base::UTF16ToUTF8(content);
data_.emplace(std::string(kTextMimeTypeUtf8), scoped_refptr<base::RefCountedString> utf8_ref =
base::RefCountedString::TakeString(&utf8_content)); base::RefCountedString::TakeString(&utf8_content);
data_.emplace(std::string(kTextMimeTypeUtf8), utf8_ref);
data_.emplace(std::string(kUtf8String), utf8_ref);
delegate_->OnOffer(std::string(kTextMimeTypeUtf8)); delegate_->OnOffer(std::string(kTextMimeTypeUtf8));
delegate_->OnOffer(std::string(kUtf8String));
} }
} }
......
...@@ -359,8 +359,9 @@ TEST_F(DataOfferTest, SetClipboardData) { ...@@ -359,8 +359,9 @@ TEST_F(DataOfferTest, SetClipboardData) {
data_offer.SetClipboardData(&file_helper, data_offer.SetClipboardData(&file_helper,
*ui::Clipboard::GetForCurrentThread()); *ui::Clipboard::GetForCurrentThread());
EXPECT_EQ(1u, delegate.mime_types().size()); EXPECT_EQ(2u, delegate.mime_types().size());
EXPECT_EQ("text/plain;charset=utf-8", delegate.mime_types()[0]); EXPECT_EQ("text/plain;charset=utf-8", delegate.mime_types()[0]);
EXPECT_EQ("UTF8_STRING", delegate.mime_types()[1]);
base::ScopedFD read_pipe; base::ScopedFD read_pipe;
base::ScopedFD write_pipe; base::ScopedFD write_pipe;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment