electron/patches/common/chromium/scoped_clipboard_writer.patch
Jeremy Apthorp 76c5f5cc8a
build: move libcc patches to electron repo (#14104)
In the GN build, libchromiumcontent is no longer a distinct library, but
merely a container for a set of scripts and patches. Maintaining those
patches in a separate repository is tedious and error-prone, so merge
them into the main repo.

Once this is merged and GN is the default way to build Electron, the
libchromiumcontent repository can be archived.
2018-09-13 22:02:16 -07:00

57 lines
2.4 KiB
Diff

diff --git a/ui/base/clipboard/scoped_clipboard_writer.cc b/ui/base/clipboard/scoped_clipboard_writer.cc
index 6850cd460b1d..6d652cca59b4 100644
--- a/ui/base/clipboard/scoped_clipboard_writer.cc
+++ b/ui/base/clipboard/scoped_clipboard_writer.cc
@@ -102,17 +102,16 @@ void ScopedClipboardWriter::WriteImage(const SkBitmap& bitmap) {
objects_[Clipboard::CBF_SMBITMAP] = parameters;
}
-void ScopedClipboardWriter::WritePickledData(
- const base::Pickle& pickle,
- const Clipboard::FormatType& format) {
+void ScopedClipboardWriter::WriteData(const char* data,
+ int size,
+ const Clipboard::FormatType& format) {
std::string format_string = format.Serialize();
Clipboard::ObjectMapParam format_parameter(format_string.begin(),
format_string.end());
Clipboard::ObjectMapParam data_parameter;
- data_parameter.resize(pickle.size());
- memcpy(const_cast<char*>(&data_parameter.front()),
- pickle.data(), pickle.size());
+ data_parameter.resize(size);
+ memcpy(const_cast<char*>(&data_parameter.front()), data, size);
Clipboard::ObjectMapParams parameters;
parameters.push_back(format_parameter);
@@ -121,6 +121,13 @@ void ScopedClipboardWriter::WritePickledData(
objects_[Clipboard::CBF_DATA] = parameters;
}
+void ScopedClipboardWriter::WritePickledData(
+ const base::Pickle& pickle,
+ const Clipboard::FormatType& format) {
+ WriteData(reinterpret_cast<const char*>(pickle.data()), pickle.size(),
+ format);
+}
+
void ScopedClipboardWriter::Reset() {
objects_.clear();
bitmap_.reset();
diff --git a/ui/base/clipboard/scoped_clipboard_writer.h b/ui/base/clipboard/scoped_clipboard_writer.h
index a7e064561ca9..d5a1b76bc6a7 100644
--- a/ui/base/clipboard/scoped_clipboard_writer.h
+++ b/ui/base/clipboard/scoped_clipboard_writer.h
@@ -61,6 +61,11 @@ class UI_BASE_EXPORT ScopedClipboardWriter {
// Used by WebKit to determine whether WebKit wrote the clipboard last
void WriteWebSmartPaste();
+ // Adds arbitrary data to clipboard.
+ void WriteData(const char* data,
+ int size,
+ const Clipboard::FormatType& format);
+
// Adds arbitrary pickled data to clipboard.
void WritePickledData(const base::Pickle& pickle,
const Clipboard::FormatType& format);