| Index: ui/base/clipboard/clipboard.h
|
| diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h
|
| index c85b90adcd20319bc78d5e1bfe9c046d5db59cbe..873afcf06f0874961074d07826cab80016de9614 100644
|
| --- a/ui/base/clipboard/clipboard.h
|
| +++ b/ui/base/clipboard/clipboard.h
|
| @@ -11,6 +11,7 @@
|
|
|
| #include "base/compiler_specific.h"
|
| #include "base/gtest_prod_util.h"
|
| +#include "base/observer_list.h"
|
| #include "base/process.h"
|
| #include "base/shared_memory.h"
|
| #include "base/string16.h"
|
| @@ -135,6 +136,7 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
|
| CBF_BITMAP,
|
| CBF_SMBITMAP, // Bitmap from shared memory.
|
| CBF_DATA, // Arbitrary block of bytes.
|
| + CBF_SOURCE_TAG, // Signifies the source of data.
|
| };
|
|
|
| // ObjectMap is a map from ObjectType to associated data.
|
| @@ -169,6 +171,12 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
|
| typedef std::vector<ObjectMapParam> ObjectMapParams;
|
| typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap;
|
|
|
| + // WriteObject() caller can use the SourceTag that will be stored in the
|
| + // clipboard. NULL value means "no tag".
|
| + typedef void* SourceTag;
|
| + static ObjectMapParam SourceTag2Binary(SourceTag tag);
|
| + static SourceTag Binary2SourceTag(const std::string& serialization);
|
| +
|
| // Buffer designates which clipboard the action should be applied to.
|
| // Only platforms that use the X Window System support the selection
|
| // buffer.
|
| @@ -177,6 +185,24 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
|
| BUFFER_SELECTION,
|
| };
|
|
|
| + // This observer does track only calls to Clipboard::WriteObjects.
|
| + // Don't use it for notification about changed OS clipboard.
|
| + class ClipboardObserverForTesting {
|
| + public:
|
| + // Called at the end of Clipboard::WriteObjects().
|
| + virtual void OnWriteObjects(Buffer buffer) = 0;
|
| + protected:
|
| + virtual ~ClipboardObserverForTesting() {}
|
| + };
|
| +
|
| + void AddObserver(ClipboardObserverForTesting* obs) {
|
| + observer_list_.AddObserver(obs);
|
| + }
|
| +
|
| + void RemoveObserver(ClipboardObserverForTesting* obs) {
|
| + observer_list_.RemoveObserver(obs);
|
| + }
|
| +
|
| static bool IsValidBuffer(int32 buffer) {
|
| switch (buffer) {
|
| case BUFFER_STANDARD:
|
| @@ -214,7 +240,9 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
|
| // contents of |objects|. On Windows they are copied to the system clipboard.
|
| // On linux they are copied into a structure owned by the Clipboard object and
|
| // kept until the system clipboard is set again.
|
| - void WriteObjects(Buffer buffer, const ObjectMap& objects);
|
| + // SourceTag is optional value to be stored in the clipboard, NULL won't be
|
| + // stored.
|
| + void WriteObjects(Buffer buffer, const ObjectMap& objects, SourceTag tag);
|
|
|
| // Returns a sequence number which uniquely identifies clipboard state.
|
| // This can be used to version the data on the clipboard and determine
|
| @@ -261,6 +289,9 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
|
| // as a byte vector.
|
| void ReadData(const FormatType& format, std::string* result) const;
|
|
|
| + // Reads Source tag from the clipboard, if available.
|
| + SourceTag ReadSourceTag() const;
|
| +
|
| // Gets the FormatType corresponding to an arbitrary format string,
|
| // registering it with the system if needed. Due to Windows/Linux
|
| // limitiations, |format_string| must never be controlled by the user.
|
| @@ -283,6 +314,7 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
|
| // crbug.com/158399.
|
| static const FormatType& GetWebCustomDataFormatType();
|
| static const FormatType& GetPepperCustomDataFormatType();
|
| + static const FormatType& GetSourceTagFormatType();
|
|
|
| // Embeds a pointer to a SharedMemory object pointed to by |bitmap_handle|
|
| // belonging to |process| into a shared bitmap [CBF_SMBITMAP] slot in
|
| @@ -310,6 +342,8 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
|
|
|
| void DispatchObject(ObjectType type, const ObjectMapParams& params);
|
|
|
| + void WriteObjectsImpl(Buffer buffer, const ObjectMap& objects, SourceTag tag);
|
| +
|
| void WriteText(const char* text_data, size_t text_len);
|
|
|
| void WriteHTML(const char* markup_data,
|
| @@ -331,6 +365,8 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
|
| void WriteData(const FormatType& format,
|
| const char* data_data,
|
| size_t data_len);
|
| +
|
| + void WriteSourceTag(SourceTag tag);
|
| #if defined(OS_WIN)
|
| void WriteBitmapFromHandle(HBITMAP source_hbitmap,
|
| const gfx::Size& size);
|
| @@ -385,6 +421,7 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
|
| class AuraX11Details;
|
| scoped_ptr<AuraX11Details> aurax11_details_;
|
| #endif
|
| + ObserverList<ClipboardObserverForTesting> observer_list_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(Clipboard);
|
| };
|
|
|