Chromium Code Reviews| Index: ui/base/x/selection_utils.h |
| diff --git a/ui/base/x/selection_utils.h b/ui/base/x/selection_utils.h |
| index eba259b37ddc48e5caf375490a4565d9a97f01aa..fc3e15cf95b1f6e0555f7c2d177408954b9a0af5 100644 |
| --- a/ui/base/x/selection_utils.h |
| +++ b/ui/base/x/selection_utils.h |
| @@ -15,13 +15,26 @@ |
| #include "base/basictypes.h" |
| #include "ui/base/clipboard/clipboard.h" |
| #include "ui/base/ui_export.h" |
| +#include "ui/base/x/x11_atom_cache.h" |
| namespace ui { |
| class X11AtomCache; |
| +extern const char kMimeTypeMozillaURL[]; |
| +extern const char kString[]; |
| +extern const char kText[]; |
| +extern const char kUtf8String[]; |
| + |
| // Returns a list of all text atoms that we handle. |
| UI_EXPORT std::vector< ::Atom> GetTextAtomsFrom(const X11AtomCache* atom_cache); |
| +UI_EXPORT std::vector< ::Atom> GetURLAtomsFrom(const X11AtomCache* atom_cache); |
| + |
| +// Places the intersection of |one| and |two| into |output|. |
| +UI_EXPORT void GetAtomIntersection(const std::vector< ::Atom>& one, |
| + const std::vector< ::Atom>& two, |
| + std::vector< ::Atom>* output); |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| // Represents the selection in different data formats. Binary data passed in is |
| @@ -52,6 +65,41 @@ class UI_EXPORT SelectionFormatMap { |
| DISALLOW_COPY_AND_ASSIGN(SelectionFormatMap); |
| }; |
| +/////////////////////////////////////////////////////////////////////////////// |
| + |
| +// A holder for data with optional X11 deletion semantics. |
| +class UI_EXPORT SelectionData { |
| + public: |
| + // |atom_cache| is still owned by caller. |
| + explicit SelectionData(Display* x_display); |
| + ~SelectionData(); |
| + |
| + ::Atom type() const { return type_; } |
| + char* data() const { return data_; } |
| + size_t size() const { return size_; } |
| + |
| + void Set(::Atom type, char* data, size_t size, bool owned); |
| + |
| + // If |type_| is a string type, convert the data to UTF8 and return it. |
| + std::string GetText() const; |
| + |
| + // If |type_| is the HTML type, returns the data as a string16. This detects |
| + // guesses the character encoding of the source. |
| + string16 GetHtml() const; |
| + |
| + // Assigns the raw data to the string. |
| + void AssignTo(std::string* result) const; |
| + void AssignTo(string16* result) const; |
| + |
| + private: |
| + ::Atom type_; |
| + char* data_; |
| + size_t size_; |
| + bool owned_; |
| + |
| + X11AtomCache atom_cache_; |
| +}; |
|
sky
2013/04/12 20:12:11
DISALLOW_COPY_AND_ASSIGN?
|
| + |
| } // namespace ui |
| #endif // UI_BASE_X_SELECTION_UTILS_H_ |