| Index: chrome/browser/gtk/xclipboard.h
|
| diff --git a/chrome/browser/gtk/xclipboard.h b/chrome/browser/gtk/xclipboard.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..69726d954399767bcaaa8761e9cfd39ad932e0b7
|
| --- /dev/null
|
| +++ b/chrome/browser/gtk/xclipboard.h
|
| @@ -0,0 +1,68 @@
|
| +struct XClipboardImpl; // to hide Xlib headers
|
| +
|
| +class XClipboard {
|
| + public:
|
| + // display: the X server display to use. This is a void* to avoid polluting the namespace.
|
| + // delegate: an object which acts on events from the X server. All callbacks
|
| + // are made in the context of the thread which is running this object and
|
| + // will block processing if they block.
|
| + XClipboard(void* display, Delegate* delegate);
|
| +
|
| + ~XClipboard();
|
| +
|
| + // X understands an arbitary number of clipboard types. However, three are
|
| + // defined in the specs and two of those are actually used. the PRIMARY
|
| + // clipboard is used for the current selection. The CLIPBOARD clipboard is
|
| + // used when the user hits Ctrl-C or "Copy" from a menu etc.
|
| + enum Type {
|
| + CLIPBOARD_PRIMARY,
|
| + CLIPBOARD_SECONDARY,
|
| + CLIPBOARD_CLIPBOARD,
|
| + };
|
| +
|
| + // Content types are passed around as strings.
|
| + typedef const std::string& ContentType;
|
| +
|
| + class Delegate {
|
| + // This is called when we loose ownership of the given clipboard.
|
| + void ClipboardLost(Type);
|
| +
|
| + // This is called when another client has requested the current clipboard
|
| + // contents. You can call ReplyWith* from within this callback.
|
| + void ClipboardContentsRequested(Type, uint64_t tag, ContentType);
|
| +
|
| + // This is called when a clipboard request has completed (successfully or
|
| + // otherwise)
|
| + // tag: the value given to |RequestClipboard|
|
| + // success: true if |type| and |data| is valid
|
| + // type: the type of the data
|
| + // data: chunks of data. You must free these chunks.
|
| + void ClipboardRequestComplete(
|
| + uint64_t tag, bool success, ContentType type,
|
| + const std::vector<pair<uint8_t*, size_t> > &data);
|
| + };
|
| +
|
| + // Assert that we own the given clipboard. If this returns true, then we own
|
| + // the given clipboard and ClipboardLost will be called when someone else
|
| + // takes it from us.
|
| + bool AssertOwnership(Type);
|
| +
|
| + // Reply negatively to a request.
|
| + void ReplyWithFailure(uint64_t tag);
|
| +
|
| + // Reply positivly to a clipboard request.
|
| + // tag: the value given in the |ClipboardContentsRequested| callback
|
| + // data: bytes to reply with.
|
| + // length: the length of |data|, in bytes
|
| + // This function may block arbitarity if the other client misbehaves. Also,
|
| + // this function may only enqueue the reply if ordering constrains proclude
|
| + // its immediate transmission.
|
| + void ReplyWithContents(uint64_t tag, const uint8_t* data, size_t length);
|
| +
|
| + // Request the current contents of the given clipboard in the given format.
|
| + void RequestClipboard(uint64_t tag, Type, ContentType);
|
| +
|
| + private:
|
| + Delegate* const delegate_;
|
| + XClipboardImpl* const pimpl_;
|
| +};
|
|
|