diff options
-rw-r--r-- | app/gtk_dnd_util.cc | 10 | ||||
-rw-r--r-- | app/gtk_dnd_util.h | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/tab_contents_drag_source.cc | 16 |
3 files changed, 30 insertions, 2 deletions
diff --git a/app/gtk_dnd_util.cc b/app/gtk_dnd_util.cc index a7933ab..da4362dc 100644 --- a/app/gtk_dnd_util.cc +++ b/app/gtk_dnd_util.cc @@ -44,6 +44,11 @@ GdkAtom GtkDndUtil::GetAtomForTarget(int target) { const_cast<char*>("application/x-chrome-named-url"), false); return named_url; + case NETSCAPE_URL: + static GdkAtom netscape_url = gdk_atom_intern( + const_cast<char*>("_NETSCAPE_URL"), false); + return netscape_url; + default: NOTREACHED(); } @@ -101,6 +106,11 @@ void GtkDndUtil::AddTargetToList(GtkTargetList* targets, int target_code) { gtk_target_list_add(targets, GetAtomForTarget(TEXT_PLAIN), 0, TEXT_HTML); break; + case NETSCAPE_URL: + gtk_target_list_add(targets, GetAtomForTarget(NETSCAPE_URL), 0, + NETSCAPE_URL); + break; + case CHROME_TAB: case CHROME_BOOKMARK_ITEM: case CHROME_NAMED_URL: diff --git a/app/gtk_dnd_util.h b/app/gtk_dnd_util.h index 7365cec..4b6155e 100644 --- a/app/gtk_dnd_util.h +++ b/app/gtk_dnd_util.h @@ -27,7 +27,11 @@ class GtkDndUtil { TEXT_URI_LIST = 1 << 5, TEXT_HTML = 1 << 6, - INVALID_TARGET = 1 << 7, + // Other types. NETSCAPE_URL is provided for compatibility with other + // apps. + NETSCAPE_URL = 1 << 7, + + INVALID_TARGET = 1 << 8, }; // Get the atom for a given target (of the above enum type). Will return NULL 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, |