123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: Henri Torgemane <[email protected]>
- Date: Thu, 23 Sep 2021 21:30:33 -0500
- Subject: add ui::ScopedCliboardWriter::WriteUnsafeRawData
- This restores some ability to write to the clipboard using raw formats, which
- was removed as part of the Raw Clipboard API scrubbing.
- https://bugs.chromium.org/p/chromium/issues/detail?id=1217643
- diff --git a/ui/base/clipboard/scoped_clipboard_writer.cc b/ui/base/clipboard/scoped_clipboard_writer.cc
- index 48f0b7a7812a073c31ac1d7af156470efbb1b051..296ee0b51e3bdd68ceb63df4fbe5813a91669b7c 100644
- --- a/ui/base/clipboard/scoped_clipboard_writer.cc
- +++ b/ui/base/clipboard/scoped_clipboard_writer.cc
- @@ -227,6 +227,16 @@ void ScopedClipboardWriter::WriteData(const std::u16string& format,
- }
- }
-
- +void ScopedClipboardWriter::WriteUnsafeRawData(const std::u16string& format,
- + mojo_base::BigBuffer data) {
- + static constexpr int kMaxRegisteredFormats = 100;
- + if (counter_ >= kMaxRegisteredFormats)
- + return;
- + counter_++;
- + platform_representations_.push_back(
- + {base::UTF16ToUTF8(format), std::move(data)});
- +}
- +
- void ScopedClipboardWriter::Reset() {
- objects_.clear();
- raw_objects_.clear();
- diff --git a/ui/base/clipboard/scoped_clipboard_writer.h b/ui/base/clipboard/scoped_clipboard_writer.h
- index e63c08b06c00dc0b1bd9c8339d3c6375e952e4f7..9e35ab7e6512c749fdea75fa863a97318541d350 100644
- --- a/ui/base/clipboard/scoped_clipboard_writer.h
- +++ b/ui/base/clipboard/scoped_clipboard_writer.h
- @@ -88,6 +88,10 @@ class COMPONENT_EXPORT(UI_BASE_CLIPBOARD) ScopedClipboardWriter {
- // This is only used to write custom format data.
- void WriteData(const std::u16string& format, mojo_base::BigBuffer data);
-
- + // write raw (non-pickled) data to the clipboard
- + void WriteUnsafeRawData(const std::u16string& format,
- + mojo_base::BigBuffer data);
- +
- void WriteImage(const SkBitmap& bitmap);
-
- // Mark the data to be written as confidential.
|