diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-04 21:52:29 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-04 21:52:29 +0000 |
commit | b08cadb9ab90b41af81b9fd8da65fb52433c8004 (patch) | |
tree | 55738edf0c98b596cd6f9a89533e92f5a82c6fff /base/clipboard.h | |
parent | 021d688a1e02ae7bd88e54162d5d25e1dae52e7c (diff) | |
download | chromium_src-b08cadb9ab90b41af81b9fd8da65fb52433c8004.zip chromium_src-b08cadb9ab90b41af81b9fd8da65fb52433c8004.tar.gz chromium_src-b08cadb9ab90b41af81b9fd8da65fb52433c8004.tar.bz2 |
GTK: implement bookmark manager copy/paste.
- Refactor bookmark util clipboard code to be cross platform.
- Add a CBF_DATA format for writing arbitrary data to the clipboard.
- Change MenuGtk so that showing a menu only makes the menu items update asynchronously. This way we can show the menu immediately and we won't get in trouble if the delegate's IsCommandEnabled() runs a nested message loop.
I did not do any mac-side implementation of the new clipboard stuff. The implementation should be easy when they get around to writing the bookmark manager.
Review URL: http://codereview.chromium.org/159815
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22419 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/clipboard.h')
-rw-r--r-- | base/clipboard.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/base/clipboard.h b/base/clipboard.h index 3b87071..de0f62d 100644 --- a/base/clipboard.h +++ b/base/clipboard.h @@ -40,7 +40,8 @@ class Clipboard { CBF_FILES, CBF_WEBKIT, CBF_BITMAP, - CBF_SMBITMAP // bitmap from shared memory + CBF_SMBITMAP, // Bitmap from shared memory. + CBF_DATA, // Arbitrary block of bytes. }; // ObjectMap is a map from ObjectType to associated data. @@ -67,6 +68,8 @@ class Clipboard { // size gfx::Size struct // CBF_SMBITMAP shared_mem shared memory handle // size gfx::Size struct + // CBF_DATA format char array + // data byte array typedef std::vector<char> ObjectMapParam; typedef std::vector<ObjectMapParam> ObjectMapParams; typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap; @@ -89,6 +92,10 @@ class Clipboard { // Tests whether the clipboard contains a certain format bool IsFormatAvailable(const FormatType& format) const; + // As above, but instead of interpreting |format| by some platform-specific + // definition, interpret it as a literal MIME type. + bool IsFormatAvailableByString(const std::string& format) const; + // Reads UNICODE text from the clipboard, if available. void ReadText(string16* result) const; @@ -106,6 +113,10 @@ class Clipboard { void ReadFile(FilePath* file) const; void ReadFiles(std::vector<FilePath>* files) const; + // Reads raw data from the clipboard with the given format type. Stores result + // as a byte vector. + void ReadData(const std::string& format, std::string* result); + // Get format Identifiers for various types. static FormatType GetUrlFormatType(); static FormatType GetUrlWFormatType(); @@ -132,6 +143,8 @@ class Clipboard { #endif private: + void DispatchObject(ObjectType type, const ObjectMapParams& params); + void WriteText(const char* text_data, size_t text_len); void WriteHTML(const char* markup_data, @@ -153,9 +166,13 @@ class Clipboard { void WriteFiles(const char* file_data, size_t file_len); - void DispatchObject(ObjectType type, const ObjectMapParams& params); - void WriteBitmap(const char* pixel_data, const char* size_data); +#if defined(OS_WIN) || defined(OS_LINUX) + // |format_name| is an ASCII string and should be NULL-terminated. + // TODO(estade): port to mac. + void WriteData(const char* format_name, size_t format_len, + const char* data_data, size_t data_len); +#endif #if defined(OS_WIN) void WriteBitmapFromSharedMemory(const char* bitmap_data, const char* size_data, @@ -200,7 +217,7 @@ class Clipboard { GtkClipboard* clipboard_; #endif - DISALLOW_EVIL_CONSTRUCTORS(Clipboard); + DISALLOW_COPY_AND_ASSIGN(Clipboard); }; #endif // BASE_CLIPBOARD_H_ |