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

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

Issue 2227083003: Fix crash in ui::ClipboardMac::ReadAvailableTypes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from dcheng. Created 4 years, 4 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..8c42c0b7bd99a252a7a6cf0cae6b56dfcfcb2ef6 100644
--- a/ui/base/clipboard/clipboard_mac.mm
+++ b/ui/base/clipboard/clipboard_mac.mm
@@ -39,11 +39,9 @@ NSString* const kPepperCustomDataPboardType =
@"org.chromium.pepper-custom-data";
NSPasteboard* GetPasteboard() {
- // The pasteboard should not be nil in a UI session, but this handy DCHECK
- // can help track down problems if someone tries using clipboard code outside
- // of a UI session.
+ // The pasteboard can always be nil, since there is a finite amount of storage
+ // that must be shared between all pasteboards.
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
- DCHECK(pasteboard);
return pasteboard;
}
@@ -227,11 +225,12 @@ void ClipboardMac::ReadAvailableTypes(ClipboardType type,
types->push_back(base::UTF8ToUTF16(kMimeTypeHTML));
if (IsFormatAvailable(Clipboard::GetRtfFormatType(), type))
types->push_back(base::UTF8ToUTF16(kMimeTypeRTF));
- if ([NSImage canInitWithPasteboard:GetPasteboard()])
+
+ NSPasteboard* pb = GetPasteboard();
+ if (pb && [NSImage canInitWithPasteboard:pb])
types->push_back(base::UTF8ToUTF16(kMimeTypePNG));
*contains_filenames = false;
- NSPasteboard* pb = GetPasteboard();
if ([[pb types] containsObject:kWebCustomDataPboardType]) {
NSData* data = [pb dataForType:kWebCustomDataPboardType];
if ([data length])
@@ -320,7 +319,8 @@ SkBitmap ClipboardMac::ReadImage(ClipboardType type) const {
initWithContentsOfURL:[NSURL fileURLWithPath:[paths lastObject]]]);
}
} else {
- image.reset([[NSImage alloc] initWithPasteboard:pb]);
+ if (pb)
+ image.reset([[NSImage alloc] initWithPasteboard:pb]);
}
} @catch (id exception) {
}
« 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