2021-11-04 18:19:30 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Henri Torgemane <henrit@gmail.com>
|
|
|
|
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
|
2023-01-06 02:35:34 +00:00
|
|
|
index e1f7acfa42b8dd377f67a1fdda0c375f239f1189..50a84d348217a136cac4f63639d45e564baa3afe 100644
|
2021-11-04 18:19:30 +00:00
|
|
|
--- a/ui/base/clipboard/scoped_clipboard_writer.cc
|
|
|
|
+++ b/ui/base/clipboard/scoped_clipboard_writer.cc
|
2022-02-10 02:58:52 +00:00
|
|
|
@@ -227,6 +227,16 @@ void ScopedClipboardWriter::WriteEncodedDataTransferEndpointForTesting(
|
2021-11-04 18:19:30 +00:00
|
|
|
}
|
2022-02-10 02:58:52 +00:00
|
|
|
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
2021-11-04 18:19:30 +00:00
|
|
|
|
|
|
|
+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();
|
|
|
|
platform_representations_.clear();
|
|
|
|
diff --git a/ui/base/clipboard/scoped_clipboard_writer.h b/ui/base/clipboard/scoped_clipboard_writer.h
|
2022-10-03 20:21:00 +00:00
|
|
|
index 5ac38344f1221ce402ad2c0e2954c442f3955318..49e22a89d823649f4c62bbae7323a055dcc47934 100644
|
2021-11-04 18:19:30 +00:00
|
|
|
--- a/ui/base/clipboard/scoped_clipboard_writer.h
|
|
|
|
+++ b/ui/base/clipboard/scoped_clipboard_writer.h
|
2022-02-10 02:58:52 +00:00
|
|
|
@@ -84,6 +84,10 @@ class COMPONENT_EXPORT(UI_BASE_CLIPBOARD) ScopedClipboardWriter {
|
2021-11-04 18:19:30 +00:00
|
|
|
// 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);
|
|
|
|
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_CHROMEOS_LACROS)
|