Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1332)

Unified Diff: chrome/browser/tab_contents/tab_contents_view_gtk.cc

Issue 155900: When a web contents drag has a URL but no title, make up a title for it.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698