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

Side by Side Diff: ui/base/x/selection_utils.cc

Issue 129113004: linux_aura: Implement file drag and drop in content area. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « ui/base/x/selection_utils.h ('k') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/x/selection_utils.h" 5 #include "ui/base/x/selection_utils.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/i18n/icu_string_conversions.h" 9 #include "base/i18n/icu_string_conversions.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "ui/base/clipboard/clipboard.h" 13 #include "ui/base/clipboard/clipboard.h"
13 #include "ui/base/x/x11_util.h" 14 #include "ui/base/x/x11_util.h"
14 #include "ui/gfx/x/x11_atom_cache.h" 15 #include "ui/gfx/x/x11_atom_cache.h"
15 16
16 namespace ui { 17 namespace ui {
17 18
18 const char kMimeTypeMozillaURL[] = "text/x-moz-url"; 19 const char kMimeTypeMozillaURL[] = "text/x-moz-url";
19 const char kString[] = "STRING"; 20 const char kString[] = "STRING";
20 const char kText[] = "TEXT"; 21 const char kText[] = "TEXT";
(...skipping 15 matching lines...) Expand all
36 return atoms; 37 return atoms;
37 } 38 }
38 39
39 std::vector< ::Atom> GetURLAtomsFrom(const X11AtomCache* atom_cache) { 40 std::vector< ::Atom> GetURLAtomsFrom(const X11AtomCache* atom_cache) {
40 std::vector< ::Atom> atoms; 41 std::vector< ::Atom> atoms;
41 atoms.push_back(atom_cache->GetAtom(Clipboard::kMimeTypeURIList)); 42 atoms.push_back(atom_cache->GetAtom(Clipboard::kMimeTypeURIList));
42 atoms.push_back(atom_cache->GetAtom(kMimeTypeMozillaURL)); 43 atoms.push_back(atom_cache->GetAtom(kMimeTypeMozillaURL));
43 return atoms; 44 return atoms;
44 } 45 }
45 46
47 std::vector< ::Atom> GetURIListAtomsFrom(const X11AtomCache* atom_cache) {
48 std::vector< ::Atom> atoms;
49 atoms.push_back(atom_cache->GetAtom(Clipboard::kMimeTypeURIList));
50 return atoms;
51 }
52
46 void GetAtomIntersection(const std::vector< ::Atom>& desired, 53 void GetAtomIntersection(const std::vector< ::Atom>& desired,
47 const std::vector< ::Atom>& offered, 54 const std::vector< ::Atom>& offered,
48 std::vector< ::Atom>* output) { 55 std::vector< ::Atom>* output) {
49 for (std::vector< ::Atom>::const_iterator it = desired.begin(); 56 for (std::vector< ::Atom>::const_iterator it = desired.begin();
50 it != desired.end(); ++it) { 57 it != desired.end(); ++it) {
51 std::vector< ::Atom>::const_iterator jt = 58 std::vector< ::Atom>::const_iterator jt =
52 std::find(offered.begin(), offered.end(), *it); 59 std::find(offered.begin(), offered.end(), *it);
53 if (jt != offered.end()) 60 if (jt != offered.end())
54 output->push_back(*it); 61 output->push_back(*it);
55 } 62 }
56 } 63 }
57 64
58 void AddString16ToVector(const base::string16& str, 65 void AddString16ToVector(const base::string16& str,
59 std::vector<unsigned char>* bytes) { 66 std::vector<unsigned char>* bytes) {
60 const unsigned char* front = 67 const unsigned char* front =
61 reinterpret_cast<const unsigned char*>(str.data()); 68 reinterpret_cast<const unsigned char*>(str.data());
62 bytes->insert(bytes->end(), front, front + (str.size() * 2)); 69 bytes->insert(bytes->end(), front, front + (str.size() * 2));
63 } 70 }
64 71
72 std::vector<std::string> ParseURIList(const SelectionData& data) {
73 // uri-lists are newline separated file lists in URL encoding.
74 std::string unparsed;
75 data.AssignTo(&unparsed);
76
77 std::vector<std::string> tokens;
78 Tokenize(unparsed, "\n", &tokens);
79 return tokens;
80 }
81
65 std::string RefCountedMemoryToString( 82 std::string RefCountedMemoryToString(
66 const scoped_refptr<base::RefCountedMemory>& memory) { 83 const scoped_refptr<base::RefCountedMemory>& memory) {
67 if (!memory.get()) { 84 if (!memory.get()) {
68 NOTREACHED(); 85 NOTREACHED();
69 return std::string(); 86 return std::string();
70 } 87 }
71 88
72 size_t size = memory->size(); 89 size_t size = memory->size();
73 if (!size) 90 if (!size)
74 return std::string(); 91 return std::string();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 238
222 void SelectionData::AssignTo(std::string* result) const { 239 void SelectionData::AssignTo(std::string* result) const {
223 *result = RefCountedMemoryToString(memory_); 240 *result = RefCountedMemoryToString(memory_);
224 } 241 }
225 242
226 void SelectionData::AssignTo(base::string16* result) const { 243 void SelectionData::AssignTo(base::string16* result) const {
227 *result = RefCountedMemoryToString16(memory_); 244 *result = RefCountedMemoryToString16(memory_);
228 } 245 }
229 246
230 } // namespace ui 247 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/x/selection_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698