summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/tab_contents_drag_source.cc
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-15 01:27:13 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-15 01:27:13 +0000
commitc114d071107fd3997bb1feb66767156f9b85f84d (patch)
tree75997b4cb378933b109193e69ff16e51e129dff0 /chrome/browser/gtk/tab_contents_drag_source.cc
parent46fc912073cc67de0e21ac4e3bc7db33980d2376 (diff)
downloadchromium_src-c114d071107fd3997bb1feb66767156f9b85f84d.zip
chromium_src-c114d071107fd3997bb1feb66767156f9b85f84d.tar.gz
chromium_src-c114d071107fd3997bb1feb66767156f9b85f84d.tar.bz2
Allow link drags from Chrome to create a shortcut on the desktop.
This required adding the netscape link+title format to the drag data (we were already doing this on windows) and adding GDK_ACTION_LINK to the GdkDragAction passed into gtk_drag_begin. BUG=27337 TEST=Drag a link to the desktop, it should create a shortcut (.desktop file). Review URL: http://codereview.chromium.org/542072 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/tab_contents_drag_source.cc')
-rw-r--r--chrome/browser/gtk/tab_contents_drag_source.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/chrome/browser/gtk/tab_contents_drag_source.cc b/chrome/browser/gtk/tab_contents_drag_source.cc
index dfaad61..b9883cc 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.cc
+++ b/chrome/browser/gtk/tab_contents_drag_source.cc
@@ -64,6 +64,7 @@ void TabContentsDragSource::StartDragging(const WebDropData& drop_data,
if (drop_data.url.is_valid()) {
targets_mask |= GtkDndUtil::TEXT_URI_LIST;
targets_mask |= GtkDndUtil::CHROME_NAMED_URL;
+ targets_mask |= GtkDndUtil::NETSCAPE_URL;
}
if (!drop_data.text_html.empty())
targets_mask |= GtkDndUtil::TEXT_HTML;
@@ -95,7 +96,8 @@ void TabContentsDragSource::StartDragging(const WebDropData& drop_data,
// and holds and doesn't start dragging for a long time. I doubt it matters
// much, but we should probably look into the possibility of getting the
// initiating event from webkit.
- gtk_drag_begin(drag_widget_, list, GDK_ACTION_COPY,
+ gtk_drag_begin(drag_widget_, list,
+ static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_LINK),
1, // Drags are always initiated by the left button.
reinterpret_cast<GdkEvent*>(last_mouse_down));
MessageLoopForUI::current()->AddObserver(this);
@@ -155,6 +157,18 @@ void TabContentsDragSource::OnDragDataGet(
break;
}
+ case GtkDndUtil::NETSCAPE_URL: {
+ // _NETSCAPE_URL format is URL + \n + title.
+ std::string utf8_text = drop_data_->url.spec() + "\n" + UTF16ToUTF8(
+ drop_data_->url_title);
+ gtk_selection_data_set(selection_data,
+ selection_data->target,
+ bits_per_byte,
+ reinterpret_cast<const guchar*>(utf8_text.c_str()),
+ utf8_text.length());
+ break;
+ }
+
case GtkDndUtil::CHROME_WEBDROP_FILE_CONTENTS: {
gtk_selection_data_set(
selection_data,