From be623b0f2ec23b3032fc6c8b61d6062accf51bb7 Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Thu, 10 Sep 2009 02:00:50 +0000 Subject: Clipboard: - Move link construction logic to scoped_clipboard_writer.cc - Make callers use EscapeForHTML on the anchor text - Make WriteHyperlink just write html, and not a bookmark as well (only affects one caller, which I updated) - implement WriteBookmark for gtk BUG=18034,18035 Review URL: http://codereview.chromium.org/194052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25833 0039d316-1c4b-4281-b951-d872f2087c98 --- base/clipboard_linux.cc | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'base/clipboard_linux.cc') diff --git a/base/clipboard_linux.cc b/base/clipboard_linux.cc index 5d8d353..9a04d1c 100644 --- a/base/clipboard_linux.cc +++ b/base/clipboard_linux.cc @@ -21,6 +21,7 @@ namespace { const char kMimeBmp[] = "image/bmp"; const char kMimeHtml[] = "text/html"; const char kMimeText[] = "text/plain"; +const char kMimeURI[] = "text/uri-list"; const char kMimeWebkitSmartPaste[] = "chromium/x-webkit-paste"; std::string GdkAtomToString(const GdkAtom& atom) { @@ -52,6 +53,11 @@ void GetData(GtkClipboard* clipboard, if (target_string == kMimeBmp) { gtk_selection_data_set_pixbuf(selection_data, reinterpret_cast(iter->second.first)); + } else if (target_string == kMimeURI) { + gchar* uri_list[2]; + uri_list[0] = reinterpret_cast(iter->second.first); + uri_list[1] = NULL; + gtk_selection_data_set_uris(selection_data, uri_list); } else { gtk_selection_data_set(selection_data, selection_data->target, 8, reinterpret_cast(iter->second.first), @@ -77,8 +83,9 @@ void ClearData(GtkClipboard* clipboard, } for (std::set::iterator iter = ptrs.begin(); - iter != ptrs.end(); ++iter) + iter != ptrs.end(); ++iter) { delete[] *iter; + } delete map; } @@ -183,14 +190,14 @@ void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { void Clipboard::WriteBookmark(const char* title_data, size_t title_len, const char* url_data, size_t url_len) { - // TODO(estade): implement this, but for now fail silently so we do not - // write error output during layout tests. - // NOTIMPLEMENTED(); -} - -void Clipboard::WriteHyperlink(const char* title_data, size_t title_len, - const char* url_data, size_t url_len) { - NOTIMPLEMENTED(); + // Write as plain text. + WriteText(url_data, url_len); + + // Write as a URI. + char* data = new char[url_len + 1]; + memcpy(data, url_data, url_len); + data[url_len] = NULL; + InsertMapping(kMimeURI, data, url_len + 1); } void Clipboard::WriteFiles(const char* file_data, size_t file_len) { @@ -393,4 +400,3 @@ GtkClipboard* Clipboard::LookupBackingClipboard(Buffer clipboard) const { } return result; } - -- cgit v1.1