Index: ui/base/clipboard/clipboard_mac.mm |
diff --git a/ui/base/clipboard/clipboard_mac.mm b/ui/base/clipboard/clipboard_mac.mm |
index d249cb40e717bebaad53aaccce06953d0ae88b30..77a89b25fcc100f546067d9cc1a1222e2a3feec6 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 20:24:50
Same bug comment here (they can share a bug).
dcheng
2011/12/05 20:51:04
Done.
|
+ |
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 |
@@ -222,6 +225,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 { |
@@ -307,8 +317,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 { |
@@ -414,4 +430,9 @@ Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { |
return base::SysNSStringToUTF8(kWebSmartPastePboardType); |
} |
+// static |
+Clipboard::FormatType Clipboard::GetWebCustomDataFormatType() { |
+ return base::SysNSStringToUTF8(kWebCustomDataType); |
+} |
+ |
} // namespace ui |