summaryrefslogtreecommitdiffstats
path: root/base/clipboard_linux.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 02:00:50 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 02:00:50 +0000
commitbe623b0f2ec23b3032fc6c8b61d6062accf51bb7 (patch)
tree2ffa24729ec7c5a0c1d9d92d200ec66fa675feef /base/clipboard_linux.cc
parent956d5aecbbf21ab3f84c87a8aec7d3a47eefbd34 (diff)
downloadchromium_src-be623b0f2ec23b3032fc6c8b61d6062accf51bb7.zip
chromium_src-be623b0f2ec23b3032fc6c8b61d6062accf51bb7.tar.gz
chromium_src-be623b0f2ec23b3032fc6c8b61d6062accf51bb7.tar.bz2
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
Diffstat (limited to 'base/clipboard_linux.cc')
-rw-r--r--base/clipboard_linux.cc26
1 files changed, 16 insertions, 10 deletions
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<GdkPixbuf*>(iter->second.first));
+ } else if (target_string == kMimeURI) {
+ gchar* uri_list[2];
+ uri_list[0] = reinterpret_cast<gchar*>(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<guchar*>(iter->second.first),
@@ -77,8 +83,9 @@ void ClearData(GtkClipboard* clipboard,
}
for (std::set<char*>::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;
}
-