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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" 5 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted_memory.h" 8 #include "base/memory/ref_counted_memory.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 std::vector<unsigned char> data; 148 std::vector<unsigned char> data;
149 ui::AddString16ToVector(spec, &data); 149 ui::AddString16ToVector(spec, &data);
150 ui::AddString16ToVector(base::ASCIIToUTF16("\n"), &data); 150 ui::AddString16ToVector(base::ASCIIToUTF16("\n"), &data);
151 ui::AddString16ToVector(title, &data); 151 ui::AddString16ToVector(title, &data);
152 scoped_refptr<base::RefCountedMemory> mem( 152 scoped_refptr<base::RefCountedMemory> mem(
153 base::RefCountedBytes::TakeVector(&data)); 153 base::RefCountedBytes::TakeVector(&data));
154 154
155 format_map_.Insert(atom_cache_.GetAtom(kMimeTypeMozillaURL), mem); 155 format_map_.Insert(atom_cache_.GetAtom(kMimeTypeMozillaURL), mem);
156 156
157 // Set _NETSCAPE_URL as well, since some file managers like Nautilus use it 157 // Set a string fallback as well.
158 // to create a link to the URL. Setting text/uri-list doesn't work as well, 158 SetString(spec);
159 // because Nautilus tries to fetch the contents of the URL instead. 159
160 // Return early if this drag already contains file contents (this implies
161 // that file contents must be populated before URLs). Nautilus (and possibly
162 // other file managers) prefer _NETSCAPE_URL over the X Direct Save
163 // protocol, but we want to prioritize XDS in this case.
164 if (!file_contents_name_.empty())
165 return;
166
167 // Set _NETSCAPE_URL for file managers like Nautilus that use it as a hint
168 // to create a link to the URL. Setting text/uri-list doesn't work because
169 // Nautilus will fetch and copy the contents of the URL to the drop target
170 // instead of linking...
160 // Format is UTF8: URL + "\n" + title. 171 // Format is UTF8: URL + "\n" + title.
161 std::string netscape_url = url.spec(); 172 std::string netscape_url = url.spec();
162 netscape_url += "\n"; 173 netscape_url += "\n";
163 netscape_url += base::UTF16ToUTF8(title); 174 netscape_url += base::UTF16ToUTF8(title);
164 format_map_.Insert(atom_cache_.GetAtom(kNetscapeURL), 175 format_map_.Insert(atom_cache_.GetAtom(kNetscapeURL),
165 scoped_refptr<base::RefCountedMemory>( 176 scoped_refptr<base::RefCountedMemory>(
166 base::RefCountedString::TakeString(&netscape_url))); 177 base::RefCountedString::TakeString(&netscape_url)));
167
168 // And finally a string fallback as well.
169 SetString(spec);
170 } 178 }
171 } 179 }
172 180
173 void OSExchangeDataProviderAuraX11::SetFilename(const base::FilePath& path) { 181 void OSExchangeDataProviderAuraX11::SetFilename(const base::FilePath& path) {
174 std::vector<FileInfo> data; 182 std::vector<FileInfo> data;
175 data.push_back(FileInfo(path, base::FilePath())); 183 data.push_back(FileInfo(path, base::FilePath()));
176 SetFilenames(data); 184 SetFilenames(data);
177 } 185 }
178 186
179 void OSExchangeDataProviderAuraX11::SetFilenames( 187 void OSExchangeDataProviderAuraX11::SetFilenames(
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 std::vector< ::Atom> requested_types; 410 std::vector< ::Atom> requested_types;
403 ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types); 411 ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types);
404 412
405 return !requested_types.empty(); 413 return !requested_types.empty();
406 } 414 }
407 415
408 void OSExchangeDataProviderAuraX11::SetFileContents( 416 void OSExchangeDataProviderAuraX11::SetFileContents(
409 const base::FilePath& filename, 417 const base::FilePath& filename,
410 const std::string& file_contents) { 418 const std::string& file_contents) {
411 DCHECK(!filename.empty()); 419 DCHECK(!filename.empty());
420 DCHECK(format_map_.end() ==
421 format_map_.find(atom_cache_.GetAtom(kMimeTypeMozillaURL)));
412 422
413 file_contents_name_ = filename; 423 file_contents_name_ = filename;
414 424
415 // Direct save handling is a complicated juggling affair between this class, 425 // Direct save handling is a complicated juggling affair between this class,
416 // SelectionFormat, and DesktopDragDropClientAuraX11. The general idea behind 426 // SelectionFormat, and DesktopDragDropClientAuraX11. The general idea behind
417 // the protocol is this: 427 // the protocol is this:
418 // - The source window sets its XdndDirectSave0 window property to the 428 // - The source window sets its XdndDirectSave0 window property to the
419 // proposed filename. 429 // proposed filename.
420 // - When a target window receives the drop, it updates the XdndDirectSave0 430 // - When a target window receives the drop, it updates the XdndDirectSave0
421 // property on the source window to the filename it would like the contents 431 // property on the source window to the filename it would like the contents
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 541
532 /////////////////////////////////////////////////////////////////////////////// 542 ///////////////////////////////////////////////////////////////////////////////
533 // OSExchangeData, public: 543 // OSExchangeData, public:
534 544
535 // static 545 // static
536 OSExchangeData::Provider* OSExchangeData::CreateProvider() { 546 OSExchangeData::Provider* OSExchangeData::CreateProvider() {
537 return new OSExchangeDataProviderAuraX11(); 547 return new OSExchangeDataProviderAuraX11();
538 } 548 }
539 549
540 } // namespace ui 550 } // namespace ui
OLDNEW
« 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