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, |