2021-11-04 13:19:30 -05: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
|
2025-02-21 14:46:51 -08:00
|
|
|
index fd162a607424bd4d0b324ccc7270522eb3b6a991..df1d5564a52ef67b447bbc222ceb1f864eb3dd81 100644
|
2021-11-04 13:19:30 -05:00
|
|
|
--- a/ui/base/clipboard/scoped_clipboard_writer.cc
|
|
|
|
+++ b/ui/base/clipboard/scoped_clipboard_writer.cc
|
2025-02-21 14:46:51 -08:00
|
|
|
@@ -230,6 +230,16 @@ void ScopedClipboardWriter::WriteData(std::u16string_view format,
|
2024-10-20 19:02:21 -05:00
|
|
|
}
|
2021-11-04 13:19:30 -05: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();
|
2025-01-23 23:07:43 -05:00
|
|
|
raw_objects_.clear();
|
2021-11-04 13:19:30 -05:00
|
|
|
diff --git a/ui/base/clipboard/scoped_clipboard_writer.h b/ui/base/clipboard/scoped_clipboard_writer.h
|
2025-02-21 14:46:51 -08:00
|
|
|
index d8fd611e88c22f2c1319da769dcd14cc218f9c90..f17304e1e9fd202dc4e1b7724031dc4c333a4baf 100644
|
2021-11-04 13:19:30 -05:00
|
|
|
--- a/ui/base/clipboard/scoped_clipboard_writer.h
|
|
|
|
+++ b/ui/base/clipboard/scoped_clipboard_writer.h
|
2025-02-21 14:46:51 -08:00
|
|
|
@@ -87,6 +87,10 @@ class COMPONENT_EXPORT(UI_BASE_CLIPBOARD) ScopedClipboardWriter {
|
2021-11-04 13:19:30 -05:00
|
|
|
// This is only used to write custom format data.
|
2025-02-21 14:46:51 -08:00
|
|
|
void WriteData(std::u16string_view format, mojo_base::BigBuffer data);
|
2021-11-04 13:19:30 -05:00
|
|
|
|
|
|
|
+ // write raw (non-pickled) data to the clipboard
|
|
|
|
+ void WriteUnsafeRawData(const std::u16string& format,
|
|
|
|
+ mojo_base::BigBuffer data);
|
|
|
|
+
|
|
|
|
void WriteImage(const SkBitmap& bitmap);
|
|
|
|
|
2024-10-20 19:02:21 -05:00
|
|
|
// Mark the data to be written as confidential.
|