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. |
(...skipping 19 matching lines...) Expand all Loading... |
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_EXPORT std::vector< ::Atom> GetTextAtomsFrom(const X11AtomCache* atom_cache); |
32 | 32 |
33 UI_EXPORT std::vector< ::Atom> GetURLAtomsFrom(const X11AtomCache* atom_cache); | 33 UI_EXPORT std::vector< ::Atom> GetURLAtomsFrom(const X11AtomCache* atom_cache); |
34 | 34 |
35 // Places the intersection of |desired| and |offered| into |output|. | 35 // Places the intersection of |desired| and |offered| into |output|. |
36 UI_EXPORT void GetAtomIntersection(const std::vector< ::Atom>& desired, | 36 UI_EXPORT void GetAtomIntersection(const std::vector< ::Atom>& desired, |
37 const std::vector< ::Atom>& offered, | 37 const std::vector< ::Atom>& offered, |
38 std::vector< ::Atom>* output); | 38 std::vector< ::Atom>* output); |
39 | 39 |
40 // Takes the raw bytes of the string16 and copies them into |bytes|. | 40 // Takes the raw bytes of the base::string16 and copies them into |bytes|. |
41 UI_EXPORT void AddString16ToVector(const string16& str, | 41 UI_EXPORT void AddString16ToVector(const base::string16& str, |
42 std::vector<unsigned char>* bytes); | 42 std::vector<unsigned char>* bytes); |
43 | 43 |
44 UI_EXPORT std::string RefCountedMemoryToString( | 44 UI_EXPORT std::string RefCountedMemoryToString( |
45 const scoped_refptr<base::RefCountedMemory>& memory); | 45 const scoped_refptr<base::RefCountedMemory>& memory); |
46 | 46 |
47 UI_EXPORT string16 RefCountedMemoryToString16( | 47 UI_EXPORT base::string16 RefCountedMemoryToString16( |
48 const scoped_refptr<base::RefCountedMemory>& memory); | 48 const scoped_refptr<base::RefCountedMemory>& memory); |
49 | 49 |
50 /////////////////////////////////////////////////////////////////////////////// | 50 /////////////////////////////////////////////////////////////////////////////// |
51 | 51 |
52 // Represents the selection in different data formats. Binary data passed in is | 52 // 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. | 53 // assumed to be allocated with new char[], and is owned by SelectionFormatMap. |
54 class UI_EXPORT SelectionFormatMap { | 54 class UI_EXPORT SelectionFormatMap { |
55 public: | 55 public: |
56 // Our internal data store, which we only expose through iterators. | 56 // Our internal data store, which we only expose through iterators. |
57 typedef std::map< ::Atom, scoped_refptr<base::RefCountedMemory> > InternalMap; | 57 typedef std::map< ::Atom, scoped_refptr<base::RefCountedMemory> > InternalMap; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 bool IsValid() const; | 98 bool IsValid() const; |
99 ::Atom GetType() const; | 99 ::Atom GetType() const; |
100 const unsigned char* GetData() const; | 100 const unsigned char* GetData() const; |
101 size_t GetSize() const; | 101 size_t GetSize() const; |
102 | 102 |
103 // If |type_| is a string type, convert the data to UTF8 and return it. | 103 // If |type_| is a string type, convert the data to UTF8 and return it. |
104 std::string GetText() const; | 104 std::string GetText() const; |
105 | 105 |
106 // If |type_| is the HTML type, returns the data as a string16. This detects | 106 // If |type_| is the HTML type, returns the data as a string16. This detects |
107 // guesses the character encoding of the source. | 107 // guesses the character encoding of the source. |
108 string16 GetHtml() const; | 108 base::string16 GetHtml() const; |
109 | 109 |
110 // Assigns the raw data to the string. | 110 // Assigns the raw data to the string. |
111 void AssignTo(std::string* result) const; | 111 void AssignTo(std::string* result) const; |
112 void AssignTo(string16* result) const; | 112 void AssignTo(base::string16* result) const; |
113 | 113 |
114 private: | 114 private: |
115 ::Atom type_; | 115 ::Atom type_; |
116 scoped_refptr<base::RefCountedMemory> memory_; | 116 scoped_refptr<base::RefCountedMemory> memory_; |
117 | 117 |
118 X11AtomCache atom_cache_; | 118 X11AtomCache atom_cache_; |
119 }; | 119 }; |
120 | 120 |
121 } // namespace ui | 121 } // namespace ui |
122 | 122 |
123 #endif // UI_BASE_X_SELECTION_UTILS_H_ | 123 #endif // UI_BASE_X_SELECTION_UTILS_H_ |
OLD | NEW |