From c033cbe94c504d2346c5e99c1ac12fda41f3f46a Mon Sep 17 00:00:00 2001 From: "avi@chromium.org" Date: Tue, 10 Mar 2009 22:01:15 +0000 Subject: This changes the base clipboard class, as accomplishing paste requires that Clipboard::FormatType be IPC-able. The lowest-common denominator of unsigned int, NSString*, and GdkAtom is string, so string it is. (Linux changes by estade.) Review URL: http://codereview.chromium.org/41012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11383 0039d316-1c4b-4281-b951-d872f2087c98 --- base/clipboard_mac.mm | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'base/clipboard_mac.mm') diff --git a/base/clipboard_mac.mm b/base/clipboard_mac.mm index f2b6294..8363ffb 100644 --- a/base/clipboard_mac.mm +++ b/base/clipboard_mac.mm @@ -129,15 +129,18 @@ void Clipboard::WriteFiles(const char* file_data, size_t file_len) { // pasteboard. This flavor has no data. void Clipboard::WriteWebSmartPaste() { NSPasteboard* pb = GetPasteboard(); - [pb addTypes:[NSArray arrayWithObject:GetWebKitSmartPasteFormatType()] owner:nil]; - [pb setData:nil forType:GetWebKitSmartPasteFormatType()]; + NSString* format = base::SysUTF8ToNSString(GetWebKitSmartPasteFormatType()); + [pb addTypes:[NSArray arrayWithObject:format] owner:nil]; + [pb setData:nil forType:format]; } -bool Clipboard::IsFormatAvailable(NSString* format) const { +bool Clipboard::IsFormatAvailable(const Clipboard::FormatType& format) const { + NSString* format_ns = base::SysUTF8ToNSString(format); + NSPasteboard* pb = GetPasteboard(); NSArray* types = [pb types]; - return [types containsObject:format]; + return [types containsObject:format_ns]; } void Clipboard::ReadText(string16* result) const { @@ -230,40 +233,51 @@ void Clipboard::ReadFiles(std::vector* files) const { // static Clipboard::FormatType Clipboard::GetUrlFormatType() { - return NSURLPboardType; + static const std::string type = base::SysNSStringToUTF8(NSURLPboardType); + return type; } // static Clipboard::FormatType Clipboard::GetUrlWFormatType() { - return NSURLPboardType; + static const std::string type = base::SysNSStringToUTF8(NSURLPboardType); + return type; } // static Clipboard::FormatType Clipboard::GetPlainTextFormatType() { - return NSStringPboardType; + static const std::string type = base::SysNSStringToUTF8(NSStringPboardType); + return type; } // static Clipboard::FormatType Clipboard::GetPlainTextWFormatType() { - return NSStringPboardType; + static const std::string type = base::SysNSStringToUTF8(NSStringPboardType); + return type; } // static Clipboard::FormatType Clipboard::GetFilenameFormatType() { - return NSFilenamesPboardType; + static const std::string type = + base::SysNSStringToUTF8(NSFilenamesPboardType); + return type; } // static Clipboard::FormatType Clipboard::GetFilenameWFormatType() { - return NSFilenamesPboardType; + static const std::string type = + base::SysNSStringToUTF8(NSFilenamesPboardType); + return type; } // static Clipboard::FormatType Clipboard::GetHtmlFormatType() { - return NSHTMLPboardType; + static const std::string type = base::SysNSStringToUTF8(NSHTMLPboardType); + return type; } // static Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { - return kWebSmartPastePboardType; + static const std::string type = + base::SysNSStringToUTF8(kWebSmartPastePboardType); + return type; } -- cgit v1.1