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

Side by Side Diff: ui/base/dragdrop/os_exchange_data_provider_aurax11.cc

Issue 133053003: linux_aura: Fix dragging files into Dropbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify Created 6 years, 11 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 | ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc » ('j') | 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/message_loop/message_pump_x11.h" 9 #include "base/message_loop/message_pump_x11.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 std::vector<unsigned char> bytes; 169 std::vector<unsigned char> bytes;
170 bytes.insert(bytes.end(), data, data + pickle.size()); 170 bytes.insert(bytes.end(), data, data + pickle.size());
171 scoped_refptr<base::RefCountedMemory> mem( 171 scoped_refptr<base::RefCountedMemory> mem(
172 base::RefCountedBytes::TakeVector(&bytes)); 172 base::RefCountedBytes::TakeVector(&bytes));
173 173
174 format_map_.Insert(atom_cache_.GetAtom(format.ToString().c_str()), mem); 174 format_map_.Insert(atom_cache_.GetAtom(format.ToString().c_str()), mem);
175 } 175 }
176 176
177 bool OSExchangeDataProviderAuraX11::GetString(base::string16* result) const { 177 bool OSExchangeDataProviderAuraX11::GetString(base::string16* result) const {
178 if (HasFile()) {
179 // Various Linux file managers both pass a list of file:// URIs and set the
180 // string representation to the URI. We explicitly don't want to return use
181 // this representation.
182 return false;
183 }
184
178 std::vector< ::Atom> text_atoms = ui::GetTextAtomsFrom(&atom_cache_); 185 std::vector< ::Atom> text_atoms = ui::GetTextAtomsFrom(&atom_cache_);
179 std::vector< ::Atom> requested_types; 186 std::vector< ::Atom> requested_types;
180 ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types); 187 ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types);
181 188
182 ui::SelectionData data(format_map_.GetFirstOf(requested_types)); 189 ui::SelectionData data(format_map_.GetFirstOf(requested_types));
183 if (data.IsValid()) { 190 if (data.IsValid()) {
184 std::string text = data.GetText(); 191 std::string text = data.GetText();
185 *result = base::UTF8ToUTF16(text); 192 *result = base::UTF8ToUTF16(text);
186 return true; 193 return true;
187 } 194 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return true; 292 return true;
286 } 293 }
287 294
288 return false; 295 return false;
289 } 296 }
290 297
291 bool OSExchangeDataProviderAuraX11::HasString() const { 298 bool OSExchangeDataProviderAuraX11::HasString() const {
292 std::vector< ::Atom> text_atoms = ui::GetTextAtomsFrom(&atom_cache_); 299 std::vector< ::Atom> text_atoms = ui::GetTextAtomsFrom(&atom_cache_);
293 std::vector< ::Atom> requested_types; 300 std::vector< ::Atom> requested_types;
294 ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types); 301 ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types);
295 return !requested_types.empty(); 302 return !requested_types.empty() && !HasFile();
296 } 303 }
297 304
298 bool OSExchangeDataProviderAuraX11::HasURL() const { 305 bool OSExchangeDataProviderAuraX11::HasURL() const {
299 std::vector< ::Atom> url_atoms = ui::GetURLAtomsFrom(&atom_cache_); 306 std::vector< ::Atom> url_atoms = ui::GetURLAtomsFrom(&atom_cache_);
300 std::vector< ::Atom> requested_types; 307 std::vector< ::Atom> requested_types;
301 ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types); 308 ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types);
302 309
303 if (requested_types.empty()) 310 if (requested_types.empty())
304 return false; 311 return false;
305 312
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 456
450 /////////////////////////////////////////////////////////////////////////////// 457 ///////////////////////////////////////////////////////////////////////////////
451 // OSExchangeData, public: 458 // OSExchangeData, public:
452 459
453 // static 460 // static
454 OSExchangeData::Provider* OSExchangeData::CreateProvider() { 461 OSExchangeData::Provider* OSExchangeData::CreateProvider() {
455 return new OSExchangeDataProviderAuraX11(); 462 return new OSExchangeDataProviderAuraX11();
456 } 463 }
457 464
458 } // namespace ui 465 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698