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

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

Issue 16271006: Drag on linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for derat@ Created 7 years, 6 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
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 #ifndef UI_BASE_X_SELECTION_UTILS_H_ 5 #ifndef UI_BASE_X_SELECTION_UTILS_H_
6 #define UI_BASE_X_SELECTION_UTILS_H_ 6 #define UI_BASE_X_SELECTION_UTILS_H_
7 7
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
11 #undef RootWindow 11 #undef RootWindow
12 12
13 #include <map> 13 #include <map>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "ui/base/clipboard/clipboard.h" 16 #include "ui/base/clipboard/clipboard.h"
17 #include "ui/base/ui_export.h" 17 #include "ui/base/ui_export.h"
18 #include "ui/base/x/x11_atom_cache.h" 18 #include "ui/base/x/x11_atom_cache.h"
19 19
20 namespace ui { 20 namespace ui {
21 class SelectionData;
21 class X11AtomCache; 22 class X11AtomCache;
22 23
23 extern const char kMimeTypeMozillaURL[]; 24 extern const char kMimeTypeMozillaURL[];
24 extern const char kString[]; 25 extern const char kString[];
25 extern const char kText[]; 26 extern const char kText[];
26 extern const char kUtf8String[]; 27 extern const char kUtf8String[];
27 28
28 // Returns a list of all text atoms that we handle. 29 // Returns a list of all text atoms that we handle.
29 UI_EXPORT std::vector< ::Atom> GetTextAtomsFrom(const X11AtomCache* atom_cache); 30 UI_EXPORT std::vector< ::Atom> GetTextAtomsFrom(const X11AtomCache* atom_cache);
30 31
(...skipping 11 matching lines...) Expand all
42 class UI_EXPORT SelectionFormatMap { 43 class UI_EXPORT SelectionFormatMap {
43 public: 44 public:
44 // Our internal data store, which we only expose through iterators. 45 // Our internal data store, which we only expose through iterators.
45 typedef std::map< ::Atom, std::pair<char*, size_t> > InternalMap; 46 typedef std::map< ::Atom, std::pair<char*, size_t> > InternalMap;
46 typedef std::map< ::Atom, std::pair<char*, size_t> >::const_iterator 47 typedef std::map< ::Atom, std::pair<char*, size_t> >::const_iterator
47 const_iterator; 48 const_iterator;
48 49
49 SelectionFormatMap(); 50 SelectionFormatMap();
50 ~SelectionFormatMap(); 51 ~SelectionFormatMap();
51 52
52 // Adds the selection in the format |atom|. Ownership of |data| is passed to 53 // Adds the selection in the format |atom|. Ownership of |data| is passed to
sky 2013/06/18 14:09:45 The semantics you're adding here are confusing and
Elliot Glaysher 2013/06/18 20:28:17 These semantics date back in some way or another t
53 // us. 54 // us.
54 void Insert(::Atom atom, char* data, size_t size); 55 void Insert(::Atom atom, char* data, size_t size);
55 56
57 // Returns the first of the requested_types or NULL if missing.
58 ui::SelectionData* GetFirstOf(
59 const std::vector< ::Atom>& requested_types) const;
60
61 // Returns all the selected types.
62 std::vector< ::Atom> GetTypes() const;
63
64 // Creates a copy of the selection data.
65 scoped_ptr<SelectionFormatMap> Clone() const;
66
56 // Pass through to STL map. Only allow non-mutation access. 67 // Pass through to STL map. Only allow non-mutation access.
57 const_iterator begin() const { return data_.begin(); } 68 const_iterator begin() const { return data_.begin(); }
58 const_iterator end() const { return data_.end(); } 69 const_iterator end() const { return data_.end(); }
59 const_iterator find(::Atom atom) const { return data_.find(atom); } 70 const_iterator find(::Atom atom) const { return data_.find(atom); }
60 size_t size() const { return data_.size(); } 71 size_t size() const { return data_.size(); }
61 72
62 private: 73 private:
63 InternalMap data_; 74 InternalMap data_;
64 75
65 DISALLOW_COPY_AND_ASSIGN(SelectionFormatMap); 76 DISALLOW_COPY_AND_ASSIGN(SelectionFormatMap);
66 }; 77 };
67 78
68 /////////////////////////////////////////////////////////////////////////////// 79 ///////////////////////////////////////////////////////////////////////////////
69 80
70 // A holder for data with optional X11 deletion semantics. 81 // A holder for data with optional X11 deletion semantics.
71 class UI_EXPORT SelectionData { 82 class UI_EXPORT SelectionData {
72 public: 83 public:
73 // |atom_cache| is still owned by caller. 84 // |atom_cache| is still owned by caller.
74 explicit SelectionData(Display* x_display); 85 SelectionData();
75 ~SelectionData(); 86 ~SelectionData();
76 87
77 ::Atom type() const { return type_; } 88 ::Atom type() const { return type_; }
78 char* data() const { return data_; } 89 char* data() const { return data_; }
79 size_t size() const { return size_; } 90 size_t size() const { return size_; }
80 91
81 void Set(::Atom type, char* data, size_t size, bool owned); 92 void Set(::Atom type, char* data, size_t size, bool owned);
82 93
83 // If |type_| is a string type, convert the data to UTF8 and return it. 94 // If |type_| is a string type, convert the data to UTF8 and return it.
84 std::string GetText() const; 95 std::string GetText() const;
(...skipping 13 matching lines...) Expand all
98 bool owned_; 109 bool owned_;
99 110
100 X11AtomCache atom_cache_; 111 X11AtomCache atom_cache_;
101 112
102 DISALLOW_COPY_AND_ASSIGN(SelectionData); 113 DISALLOW_COPY_AND_ASSIGN(SelectionData);
103 }; 114 };
104 115
105 } // namespace ui 116 } // namespace ui
106 117
107 #endif // UI_BASE_X_SELECTION_UTILS_H_ 118 #endif // UI_BASE_X_SELECTION_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698