OLD | NEW |
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 "base/memory/ref_counted_memory.h" | 16 #include "base/memory/ref_counted_memory.h" |
17 #include "ui/base/clipboard/clipboard.h" | 17 #include "ui/base/clipboard/clipboard.h" |
18 #include "ui/base/ui_export.h" | 18 #include "ui/base/ui_base_export.h" |
19 #include "ui/gfx/x/x11_atom_cache.h" | 19 #include "ui/gfx/x/x11_atom_cache.h" |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
22 class SelectionData; | 22 class SelectionData; |
23 class X11AtomCache; | 23 class X11AtomCache; |
24 | 24 |
25 extern const char kMimeTypeMozillaURL[]; | 25 extern const char kMimeTypeMozillaURL[]; |
26 extern const char kString[]; | 26 extern const char kString[]; |
27 extern const char kText[]; | 27 extern const char kText[]; |
28 extern const char kUtf8String[]; | 28 extern const char kUtf8String[]; |
29 | 29 |
30 // Returns a list of all text atoms that we handle. | 30 // Returns a list of all text atoms that we handle. |
31 UI_EXPORT std::vector< ::Atom> GetTextAtomsFrom(const X11AtomCache* atom_cache); | 31 UI_BASE_EXPORT std::vector< ::Atom> GetTextAtomsFrom( |
| 32 const X11AtomCache* atom_cache); |
32 | 33 |
33 UI_EXPORT std::vector< ::Atom> GetURLAtomsFrom(const X11AtomCache* atom_cache); | 34 UI_BASE_EXPORT std::vector< ::Atom> GetURLAtomsFrom( |
| 35 const X11AtomCache* atom_cache); |
34 | 36 |
35 // Places the intersection of |desired| and |offered| into |output|. | 37 // Places the intersection of |desired| and |offered| into |output|. |
36 UI_EXPORT void GetAtomIntersection(const std::vector< ::Atom>& desired, | 38 UI_BASE_EXPORT void GetAtomIntersection(const std::vector< ::Atom>& desired, |
37 const std::vector< ::Atom>& offered, | 39 const std::vector< ::Atom>& offered, |
38 std::vector< ::Atom>* output); | 40 std::vector< ::Atom>* output); |
39 | 41 |
40 // Takes the raw bytes of the base::string16 and copies them into |bytes|. | 42 // Takes the raw bytes of the base::string16 and copies them into |bytes|. |
41 UI_EXPORT void AddString16ToVector(const base::string16& str, | 43 UI_BASE_EXPORT void AddString16ToVector(const base::string16& str, |
42 std::vector<unsigned char>* bytes); | 44 std::vector<unsigned char>* bytes); |
43 | 45 |
44 UI_EXPORT std::string RefCountedMemoryToString( | 46 UI_BASE_EXPORT std::string RefCountedMemoryToString( |
45 const scoped_refptr<base::RefCountedMemory>& memory); | 47 const scoped_refptr<base::RefCountedMemory>& memory); |
46 | 48 |
47 UI_EXPORT base::string16 RefCountedMemoryToString16( | 49 UI_BASE_EXPORT base::string16 RefCountedMemoryToString16( |
48 const scoped_refptr<base::RefCountedMemory>& memory); | 50 const scoped_refptr<base::RefCountedMemory>& memory); |
49 | 51 |
50 /////////////////////////////////////////////////////////////////////////////// | 52 /////////////////////////////////////////////////////////////////////////////// |
51 | 53 |
52 // Represents the selection in different data formats. Binary data passed in is | 54 // Represents the selection in different data formats. Binary data passed in is |
53 // assumed to be allocated with new char[], and is owned by SelectionFormatMap. | 55 // assumed to be allocated with new char[], and is owned by SelectionFormatMap. |
54 class UI_EXPORT SelectionFormatMap { | 56 class UI_BASE_EXPORT SelectionFormatMap { |
55 public: | 57 public: |
56 // Our internal data store, which we only expose through iterators. | 58 // Our internal data store, which we only expose through iterators. |
57 typedef std::map< ::Atom, scoped_refptr<base::RefCountedMemory> > InternalMap; | 59 typedef std::map< ::Atom, scoped_refptr<base::RefCountedMemory> > InternalMap; |
58 typedef InternalMap::const_iterator const_iterator; | 60 typedef InternalMap::const_iterator const_iterator; |
59 | 61 |
60 SelectionFormatMap(); | 62 SelectionFormatMap(); |
61 ~SelectionFormatMap(); | 63 ~SelectionFormatMap(); |
62 // Copy and assignment deliberately open. | 64 // Copy and assignment deliberately open. |
63 | 65 |
64 // Adds the selection in the format |atom|. Ownership of |data| is passed to | 66 // Adds the selection in the format |atom|. Ownership of |data| is passed to |
(...skipping 13 matching lines...) Expand all Loading... |
78 const_iterator find(::Atom atom) const { return data_.find(atom); } | 80 const_iterator find(::Atom atom) const { return data_.find(atom); } |
79 size_t size() const { return data_.size(); } | 81 size_t size() const { return data_.size(); } |
80 | 82 |
81 private: | 83 private: |
82 InternalMap data_; | 84 InternalMap data_; |
83 }; | 85 }; |
84 | 86 |
85 /////////////////////////////////////////////////////////////////////////////// | 87 /////////////////////////////////////////////////////////////////////////////// |
86 | 88 |
87 // A holder for data with optional X11 deletion semantics. | 89 // A holder for data with optional X11 deletion semantics. |
88 class UI_EXPORT SelectionData { | 90 class UI_BASE_EXPORT SelectionData { |
89 public: | 91 public: |
90 // |atom_cache| is still owned by caller. | 92 // |atom_cache| is still owned by caller. |
91 SelectionData(); | 93 SelectionData(); |
92 SelectionData(::Atom type, | 94 SelectionData(::Atom type, |
93 const scoped_refptr<base::RefCountedMemory>& memory); | 95 const scoped_refptr<base::RefCountedMemory>& memory); |
94 SelectionData(const SelectionData& rhs); | 96 SelectionData(const SelectionData& rhs); |
95 ~SelectionData(); | 97 ~SelectionData(); |
96 SelectionData& operator=(const SelectionData& rhs); | 98 SelectionData& operator=(const SelectionData& rhs); |
97 | 99 |
98 bool IsValid() const; | 100 bool IsValid() const; |
(...skipping 15 matching lines...) Expand all Loading... |
114 private: | 116 private: |
115 ::Atom type_; | 117 ::Atom type_; |
116 scoped_refptr<base::RefCountedMemory> memory_; | 118 scoped_refptr<base::RefCountedMemory> memory_; |
117 | 119 |
118 X11AtomCache atom_cache_; | 120 X11AtomCache atom_cache_; |
119 }; | 121 }; |
120 | 122 |
121 } // namespace ui | 123 } // namespace ui |
122 | 124 |
123 #endif // UI_BASE_X_SELECTION_UTILS_H_ | 125 #endif // UI_BASE_X_SELECTION_UTILS_H_ |
OLD | NEW |