Index: chrome/browser/tab_contents/tab_contents_view_gtk.cc |
=================================================================== |
--- chrome/browser/tab_contents/tab_contents_view_gtk.cc (revision 21217) |
+++ chrome/browser/tab_contents/tab_contents_view_gtk.cc (working copy) |
@@ -8,6 +8,7 @@ |
#include <gdk/gdkkeysyms.h> |
#include <gtk/gtk.h> |
+#include "app/l10n_util.h" |
#include "base/mime_util.h" |
#include "base/gfx/point.h" |
#include "base/gfx/rect.h" |
@@ -33,6 +34,8 @@ |
#include "chrome/common/notification_service.h" |
#include "chrome/common/notification_source.h" |
#include "chrome/common/notification_type.h" |
+#include "grit/app_strings.h" |
+#include "net/base/net_util.h" |
#include "webkit/glue/webdropdata.h" |
namespace { |
@@ -790,6 +793,8 @@ |
// it in the switch statement. |
std::string utf8_text; |
Pickle pickle; |
+ std::string name; |
tony
2009/07/22 00:51:08
Nit: If you add {} around the case block, you can
Evan Stade
2009/07/22 00:54:55
oh, sweet. This has rather annoyed me.
|
+ const GURL& url = view->drop_data_->url; |
switch (target_type) { |
case GtkDndUtil::TEXT_PLAIN: |
@@ -818,8 +823,17 @@ |
break; |
case GtkDndUtil::CHROME_NAMED_URL: |
- pickle.WriteString(UTF16ToUTF8(view->drop_data_->url_title)); |
- pickle.WriteString(view->drop_data_->url.spec()); |
+ if (!view->drop_data_->url_title.empty()) { |
+ name = UTF16ToUTF8(view->drop_data_->url_title); |
+ } else if (url.is_valid()) { |
+ name = WideToUTF8(net::GetSuggestedFilename( |
+ url, std::string(), std::string(), std::wstring())); |
+ } else { |
+ // Nothing else can be done, just use a default. |
+ name = l10n_util::GetStringUTF8(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME); |
+ } |
+ pickle.WriteString(name); |
+ pickle.WriteString(url.spec()); |
gtk_selection_data_set(selection_data, |
GtkDndUtil::GetAtomForTarget(GtkDndUtil::CHROME_NAMED_URL), |
bits_per_byte, |