Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Unified Diff: base/clipboard.h

Issue 8038: Simultaneously store multiple formats on the linux clipboard. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base_unittests.scons ('k') | base/clipboard_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/clipboard.h
===================================================================
--- base/clipboard.h (revision 3794)
+++ base/clipboard.h (working copy)
@@ -5,7 +5,9 @@
#ifndef BASE_CLIPBOARD_H_
#define BASE_CLIPBOARD_H_
+#include <map>
#include <string>
+#include <utility>
#include <vector>
#include "base/basictypes.h"
@@ -29,6 +31,9 @@
#elif defined(OS_LINUX)
typedef struct _GdkAtom* FormatType;
typedef struct _GtkClipboard GtkClipboard;
+ // A mapping from target (format) string to the relevant data (usually a
+ // string, but potentially arbitrary data).
+ typedef std::map<std::string, std::pair<uint8*, size_t> > TargetMap;
#endif
Clipboard();
@@ -98,7 +103,7 @@
// out parameter.
void ReadFile(std::wstring* file) const;
void ReadFiles(std::vector<std::wstring>* files) const;
-
+
// Get format Identifiers for various types.
static FormatType GetUrlFormatType();
static FormatType GetUrlWFormatType();
@@ -135,6 +140,23 @@
HWND clipboard_owner_;
#elif defined(OS_LINUX)
+ // Write changes to gtk clipboard.
+ void SetGtkClipboard();
+ // Free pointers in clipboard_data_ and clear() the map.
+ void FreeTargetMap();
+ // Insert a mapping into clipboard_data_, or change an existing mapping.
+ uint8* InsertOrOverwrite(std::string target, uint8* data, size_t data_len);
+
+ // We have to be able to store multiple formats on the clipboard
+ // simultaneously. The Chrome Clipboard class accomplishes this by
+ // expecting that consecutive calls to Write* (WriteHTML, WriteText, etc.)
+ // The GTK clipboard interface does not naturally support consecutive calls
+ // building on one another. So we keep all data in a map, and always pass the
+ // map when we are setting the gtk clipboard. Consecutive calls to Write*
+ // will write to the map and set the GTK clipboard, then add to the same
+ // map and set the GTK clipboard again. GTK thinks it is wiping out the
+ // clipboard but we are actually keeping the previous data.
+ TargetMap clipboard_data_;
GtkClipboard* clipboard_;
#endif
« no previous file with comments | « base/base_unittests.scons ('k') | base/clipboard_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698