| Index: ui/base/clipboard/clipboard_mac.mm
|
| diff --git a/ui/base/clipboard/clipboard_mac.mm b/ui/base/clipboard/clipboard_mac.mm
|
| index ba9c74a5e5ec4c3bd55968e6c624715636287ce0..153f5e9225e0853c5b2876b7a58be18b94efc905 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,9 @@ NSString* const kUTTypeURLName = @"public.url-name";
|
| // actual data associated with this type.
|
| NSString* const kWebSmartPastePboardType = @"NeXT smart paste pasteboard type";
|
|
|
| +// TODO(dcheng): This name is temporary. See crbug.com/106449.
|
| +NSString* const kWebCustomDataType = @"org.chromium.web-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
|
| @@ -156,9 +160,10 @@ void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) {
|
| void Clipboard::WriteData(const char* format_name, size_t format_len,
|
| const char* data_data, size_t data_len) {
|
| NSPasteboard* pb = GetPasteboard();
|
| - NSString* format = [[NSString alloc] initWithBytes:format_name
|
| - length:format_len
|
| - encoding:NSUTF8StringEncoding];
|
| + scoped_nsobject<NSString> format(
|
| + [[NSString alloc] initWithBytes:format_name
|
| + length:format_len
|
| + encoding:NSUTF8StringEncoding]);
|
| [pb addTypes:[NSArray arrayWithObject:format] owner:nil];
|
| [pb setData:[NSData dataWithBytes:data_data length:data_len]
|
| forType:format];
|
| @@ -224,6 +229,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 {
|
| @@ -309,8 +321,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 {
|
| @@ -416,4 +434,9 @@ Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() {
|
| return base::SysNSStringToUTF8(kWebSmartPastePboardType);
|
| }
|
|
|
| +// static
|
| +Clipboard::FormatType Clipboard::GetWebCustomDataFormatType() {
|
| + return base::SysNSStringToUTF8(kWebCustomDataType);
|
| +}
|
| +
|
| } // namespace ui
|
|
|