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

Unified Diff: ui/base/clipboard/clipboard_mac.mm

Issue 1921713004: mac: Use more modern API for writing images to the pasteboard. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bleh Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/clipboard/clipboard_mac.mm
diff --git a/ui/base/clipboard/clipboard_mac.mm b/ui/base/clipboard/clipboard_mac.mm
index f3a4c434704ca60926ab0cce3d0cf378cd9f347b..d45bcf2cc098f2e0c86a04ba3f1ca7e0bd51ced9 100644
--- a/ui/base/clipboard/clipboard_mac.mm
+++ b/ui/base/clipboard/clipboard_mac.mm
@@ -430,17 +430,11 @@ void ClipboardMac::WriteBookmark(const char* title_data,
}
void ClipboardMac::WriteBitmap(const SkBitmap& bitmap) {
+ NSPasteboard* pb = GetPasteboard();
+ [pb clearContents];
NSImage* image = skia::SkBitmapToNSImageWithColorSpace(
bitmap, base::mac::GetSystemColorSpace());
- // An API to ask the NSImage to write itself to the clipboard comes in 10.6 :(
- // For now, spit out the image as a TIFF.
- NSPasteboard* pb = GetPasteboard();
- [pb addTypes:[NSArray arrayWithObject:NSTIFFPboardType] owner:nil];
- NSData* tiff_data = [image TIFFRepresentation];
- LOG_IF(ERROR, tiff_data == NULL) << "Failed to allocate image for clipboard";
- if (tiff_data) {
- [pb setData:tiff_data forType:NSTIFFPboardType];
- }
+ [pb writeObjects:@[ image ]];
}
void ClipboardMac::WriteData(const FormatType& format,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698