Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2306)

Unified Diff: ui/base/clipboard/scoped_clipboard_writer.cc

Issue 574273002: Rewrite clipboard write IPC handling to be easier to understand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/base/clipboard/scoped_clipboard_writer.cc
diff --git a/ui/base/clipboard/scoped_clipboard_writer.cc b/ui/base/clipboard/scoped_clipboard_writer.cc
index 50a7ba39fec8544eec497a55c851387c578a3909..0dd10569bf0bb747439ad00b66c56b20af1883c5 100644
--- a/ui/base/clipboard/scoped_clipboard_writer.cc
+++ b/ui/base/clipboard/scoped_clipboard_writer.cc
@@ -86,6 +86,24 @@ void ScopedClipboardWriter::WriteWebSmartPaste() {
objects_[Clipboard::CBF_WEBKIT] = Clipboard::ObjectMapParams();
}
+void ScopedClipboardWriter::WriteImage(const SkBitmap& bitmap) {
+ if (bitmap.drawsNothing()) {
+ NOTREACHED();
+ return;
+ }
+ bitmap_ = bitmap;
+ // TODO(dcheng): This is slightly less horrible than what we used to do, but
+ // only very slightly less.
+ SkBitmap* bitmap_pointer = &bitmap_;
+ Clipboard::ObjectMapParam packed_pointer;
+ for (size_t i = 0; i < sizeof(bitmap_pointer); ++i) {
sky 2014/09/18 19:47:53 nit: no {}
dcheng 2014/09/18 21:06:00 Done.
+ packed_pointer.push_back(reinterpret_cast<uint8_t*>(&bitmap_pointer)[i]);
+ }
+ Clipboard::ObjectMapParams parameters;
+ parameters.push_back(packed_pointer);
+ objects_[Clipboard::CBF_SMBITMAP] = parameters;
+}
+
void ScopedClipboardWriter::WritePickledData(
const Pickle& pickle, const Clipboard::FormatType& format) {
std::string format_string = format.Serialize();
@@ -106,6 +124,7 @@ void ScopedClipboardWriter::WritePickledData(
void ScopedClipboardWriter::Reset() {
url_text_.clear();
objects_.clear();
+ bitmap_.reset();
}
void ScopedClipboardWriter::WriteTextOrURL(const base::string16& text,
« ui/base/clipboard/clipboard_unittest.cc ('K') | « ui/base/clipboard/scoped_clipboard_writer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698