Chromium Code Reviews| Index: ui/base/clipboard/clipboard_mac.mm |
| diff --git a/ui/base/clipboard/clipboard_mac.mm b/ui/base/clipboard/clipboard_mac.mm |
| index ebeb90752c08b968382e056d537aecd955976ea1..32bf52796c9adbfa18251c7a71fe6191da78af62 100644 |
| --- a/ui/base/clipboard/clipboard_mac.mm |
| +++ b/ui/base/clipboard/clipboard_mac.mm |
| @@ -15,6 +15,7 @@ |
| #include "base/utf_string_conversions.h" |
| #import "third_party/mozilla/NSPasteboard+Utils.h" |
| #include "third_party/skia/include/core/SkBitmap.h" |
| +#include "ui/base/clipboard/custom_data_helper.h" |
| #include "ui/gfx/canvas_skia.h" |
| #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| #include "ui/gfx/size.h" |
| @@ -30,6 +31,8 @@ NSString* const kUTTypeURLName = @"public.url-name"; |
| // actual data associated with this type. |
| NSString* const kWebSmartPastePboardType = @"NeXT smart paste pasteboard type"; |
| +NSString* const kWebCustomDataType = @"org.chromium.web-custom-data"; |
|
tony
2011/12/05 18:40:39
Ditto.
|
| + |
| 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 |
| @@ -202,6 +205,13 @@ void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer, |
| if ([NSImage canInitWithPasteboard:GetPasteboard()]) |
| types->push_back(UTF8ToUTF16(kMimeTypePNG)); |
| *contains_filenames = false; |
| + |
| + NSPasteboard* pb = GetPasteboard(); |
| + if ([[pb types] containsObject:kWebCustomDataType]) { |
| + NSData* data = [pb dataForType:kWebCustomDataType]; |
| + if ([data length]) |
| + ReadCustomDataTypes([data bytes], [data length], types); |
| + } |
| } |
| void Clipboard::ReadText(Clipboard::Buffer buffer, string16* result) const { |
| @@ -287,8 +297,14 @@ SkBitmap Clipboard::ReadImage(Buffer buffer) const { |
| void Clipboard::ReadCustomData(Buffer buffer, |
| const string16& type, |
| string16* result) const { |
| - // TODO(dcheng): Implement this. |
| - NOTIMPLEMENTED(); |
| + DCHECK_EQ(buffer, BUFFER_STANDARD); |
| + |
| + NSPasteboard* pb = GetPasteboard(); |
| + if ([[pb types] containsObject:kWebCustomDataType]) { |
| + NSData* data = [pb dataForType:kWebCustomDataType]; |
| + if ([data length]) |
| + ReadCustomDataForType([data bytes], [data length], type, result); |
| + } |
| } |
| void Clipboard::ReadBookmark(string16* title, std::string* url) const { |
| @@ -387,4 +403,9 @@ Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { |
| return base::SysNSStringToUTF8(kWebSmartPastePboardType); |
| } |
| +// static |
| +Clipboard::FormatType Clipboard::GetWebCustomDataFormatType() { |
| + return base::SysNSStringToUTF8(kWebCustomDataType); |
| +} |
| + |
| } // namespace ui |