From c5c86ad1471abfa6b080756aa5258815781c57d5 Mon Sep 17 00:00:00 2001 From: "dcheng@chromium.org" Date: Fri, 8 Apr 2011 23:50:54 +0000 Subject: Implement Clipboard::ReadAvailableTypes for Mac. BUG=75237 TEST=Local testing. Review URL: http://codereview.chromium.org/6823019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81015 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/base/clipboard/clipboard.cc | 4 ++++ ui/base/clipboard/clipboard.h | 5 +++++ ui/base/clipboard/clipboard_mac.mm | 7 ++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ui/base/clipboard/clipboard.cc b/ui/base/clipboard/clipboard.cc index f16bb92..c8389da 100644 --- a/ui/base/clipboard/clipboard.cc +++ b/ui/base/clipboard/clipboard.cc @@ -74,6 +74,10 @@ bool ValidateAndMapSharedBitmap(const Clipboard::ObjectMapParams& params, } // namespace +const char Clipboard::kMimeTypeText[] = "text/plain"; +const char Clipboard::kMimeTypeHTML[] = "text/html"; +const char Clipboard::kMimeTypePNG[] = "image/png"; + void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) { // All types apart from CBF_WEBKIT need at least 1 non-empty param. if (type != CBF_WEBKIT && (params.empty() || params[0].empty())) diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h index 2d040c8..bc8b950 100644 --- a/ui/base/clipboard/clipboard.h +++ b/ui/base/clipboard/clipboard.h @@ -275,6 +275,11 @@ class Clipboard { GtkClipboard* primary_selection_; #endif + // MIME type constants. + static const char kMimeTypeText[]; + static const char kMimeTypeHTML[]; + static const char kMimeTypePNG[]; + DISALLOW_COPY_AND_ASSIGN(Clipboard); }; diff --git a/ui/base/clipboard/clipboard_mac.mm b/ui/base/clipboard/clipboard_mac.mm index e9dff9b..74b73f9 100644 --- a/ui/base/clipboard/clipboard_mac.mm +++ b/ui/base/clipboard/clipboard_mac.mm @@ -185,8 +185,13 @@ void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer, return; } - // TODO(dcheng): Implement me. types->clear(); + if (IsFormatAvailable(Clipboard::GetPlainTextFormatType(), buffer)) + types->push_back(UTF8ToUTF16(kMimeTypeText)); + if (IsFormatAvailable(Clipboard::GetHtmlFormatType(), buffer)) + types->push_back(UTF8ToUTF16(kMimeTypeHTML)); + if ([NSImage canInitWithPasteboard:GetPasteboard()]) + types->push_back(UTF8ToUTF16(kMimeTypePNG)); *contains_filenames = false; } -- cgit v1.1