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

Unified Diff: ui/base/dragdrop/os_exchange_data_provider_aurax11.cc

Issue 229763003: Skip _NETSCAPE_URL population for image drags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Now with more DCHECKs Created 6 years, 8 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: ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc b/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
index 6ebf9ca5d683a98ae8572d15363ae596f24a5662..0088b1d9fadcbffde2fee6ab0e984cc4ca95a73b 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
+++ b/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
@@ -154,9 +154,20 @@ void OSExchangeDataProviderAuraX11::SetURL(const GURL& url,
format_map_.Insert(atom_cache_.GetAtom(kMimeTypeMozillaURL), mem);
- // Set _NETSCAPE_URL as well, since some file managers like Nautilus use it
- // to create a link to the URL. Setting text/uri-list doesn't work as well,
- // because Nautilus tries to fetch the contents of the URL instead.
+ // Set a string fallback as well.
+ SetString(spec);
+
+ // Return early if this drag already contains file contents (this implies
+ // that file contents must be populated before URLs). Nautilus (and possibly
+ // other file managers) prefer _NETSCAPE_URL over the X Direct Save
+ // protocol, but we want to prioritize XDS in this case.
+ if (!file_contents_name_.empty())
+ return;
+
+ // Set _NETSCAPE_URL for file managers like Nautilus that use it as a hint
+ // to create a link to the URL. Setting text/uri-list doesn't work because
+ // Nautilus will fetch and copy the contents of the URL to the drop target
+ // instead of linking...
// Format is UTF8: URL + "\n" + title.
std::string netscape_url = url.spec();
netscape_url += "\n";
@@ -164,9 +175,6 @@ void OSExchangeDataProviderAuraX11::SetURL(const GURL& url,
format_map_.Insert(atom_cache_.GetAtom(kNetscapeURL),
scoped_refptr<base::RefCountedMemory>(
base::RefCountedString::TakeString(&netscape_url)));
-
- // And finally a string fallback as well.
- SetString(spec);
}
}
@@ -409,6 +417,8 @@ void OSExchangeDataProviderAuraX11::SetFileContents(
const base::FilePath& filename,
const std::string& file_contents) {
DCHECK(!filename.empty());
+ DCHECK(format_map_.end() ==
+ format_map_.find(atom_cache_.GetAtom(kMimeTypeMozillaURL)));
file_contents_name_ = filename;
« 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