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

Side by Side Diff: base/clipboard.h

Issue 174367: Change the ChromiumPasteboard to have a notion of an alternate clipboard... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/clipboard_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_CLIPBOARD_H_ 5 #ifndef BASE_CLIPBOARD_H_
6 #define BASE_CLIPBOARD_H_ 6 #define BASE_CLIPBOARD_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // CBF_BITMAP pixels byte array 67 // CBF_BITMAP pixels byte array
68 // size gfx::Size struct 68 // size gfx::Size struct
69 // CBF_SMBITMAP shared_mem shared memory handle 69 // CBF_SMBITMAP shared_mem shared memory handle
70 // size gfx::Size struct 70 // size gfx::Size struct
71 // CBF_DATA format char array 71 // CBF_DATA format char array
72 // data byte array 72 // data byte array
73 typedef std::vector<char> ObjectMapParam; 73 typedef std::vector<char> ObjectMapParam;
74 typedef std::vector<ObjectMapParam> ObjectMapParams; 74 typedef std::vector<ObjectMapParam> ObjectMapParams;
75 typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap; 75 typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap;
76 76
77 // Buffer designates which clipboard the action should be applied to.
78 // Only platforms that use the X Window System support the selection
79 // buffer. Furthermore we currently only use a buffer other than the
80 // standard buffer when reading from the clipboard so only those
81 // functions accept a buffer parameter.
82 enum Buffer {
83 BUFFER_STANDARD,
84 #if defined(OS_LINUX)
85 BUFFER_SELECTION,
86 #endif
87 };
88
89 static bool IsValidBuffer(int32 buffer) {
90 switch (buffer) {
91 case BUFFER_STANDARD:
92 return true;
93 #if defined(OS_LINUX)
94 case BUFFER_SELECTION:
95 return true;
96 #endif
97 }
98 return false;
99 }
100
101 static Buffer FromInt(int32 buffer) {
102 return static_cast<Buffer>(buffer);
103 }
104
77 Clipboard(); 105 Clipboard();
78 ~Clipboard(); 106 ~Clipboard();
79 107
80 // Write a bunch of objects to the system clipboard. Copies are made of the 108 // Write a bunch of objects to the system clipboard. Copies are made of the
81 // contents of |objects|. On Windows they are copied to the system clipboard. 109 // contents of |objects|. On Windows they are copied to the system clipboard.
82 // On linux they are copied into a structure owned by the Clipboard object and 110 // On linux they are copied into a structure owned by the Clipboard object and
83 // kept until the system clipboard is set again. 111 // kept until the system clipboard is set again.
84 void WriteObjects(const ObjectMap& objects); 112 void WriteObjects(const ObjectMap& objects);
85 113
86 // Behaves as above. If there is some shared memory handle passed as one of 114 // Behaves as above. If there is some shared memory handle passed as one of
87 // the objects, it came from the process designated by |process|. This will 115 // the objects, it came from the process designated by |process|. This will
88 // assist in turning it into a shared memory region that the current process 116 // assist in turning it into a shared memory region that the current process
89 // can use. 117 // can use.
90 void WriteObjects(const ObjectMap& objects, base::ProcessHandle process); 118 void WriteObjects(const ObjectMap& objects, base::ProcessHandle process);
91 119
92 // Tests whether the clipboard contains a certain format 120 // Tests whether the clipboard contains a certain format
93 bool IsFormatAvailable(const FormatType& format) const; 121 bool IsFormatAvailable(const FormatType& format, Buffer buffer) const;
94 122
95 // As above, but instead of interpreting |format| by some platform-specific 123 // As above, but instead of interpreting |format| by some platform-specific
96 // definition, interpret it as a literal MIME type. 124 // definition, interpret it as a literal MIME type.
97 bool IsFormatAvailableByString(const std::string& format) const; 125 bool IsFormatAvailableByString(const std::string& format,
126 Buffer buffer) const;
98 127
99 // Reads UNICODE text from the clipboard, if available. 128 // Reads UNICODE text from the clipboard, if available.
100 void ReadText(string16* result) const; 129 void ReadText(Buffer buffer, string16* result) const;
101 130
102 // Reads ASCII text from the clipboard, if available. 131 // Reads ASCII text from the clipboard, if available.
103 void ReadAsciiText(std::string* result) const; 132 void ReadAsciiText(Buffer buffer, std::string* result) const;
104 133
105 // Reads HTML from the clipboard, if available. 134 // Reads HTML from the clipboard, if available.
106 void ReadHTML(string16* markup, std::string* src_url) const; 135 void ReadHTML(Buffer buffer, string16* markup, std::string* src_url) const;
107 136
108 // Reads a bookmark from the clipboard, if available. 137 // Reads a bookmark from the clipboard, if available.
109 void ReadBookmark(string16* title, std::string* url) const; 138 void ReadBookmark(string16* title, std::string* url) const;
110 139
111 // Reads a file or group of files from the clipboard, if available, into the 140 // Reads a file or group of files from the clipboard, if available, into the
112 // out parameter. 141 // out parameter.
113 void ReadFile(FilePath* file) const; 142 void ReadFile(FilePath* file) const;
114 void ReadFiles(std::vector<FilePath>* files) const; 143 void ReadFiles(std::vector<FilePath>* files) const;
115 144
116 // Reads raw data from the clipboard with the given format type. Stores result 145 // Reads raw data from the clipboard with the given format type. Stores result
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // SetGtkClipboard function replaces whatever is on the system clipboard with 235 // SetGtkClipboard function replaces whatever is on the system clipboard with
207 // the contents of |clipboard_data_|. 236 // the contents of |clipboard_data_|.
208 // The Write* functions make a deep copy of the data passed to them an store 237 // The Write* functions make a deep copy of the data passed to them an store
209 // it in |clipboard_data_|. 238 // it in |clipboard_data_|.
210 239
211 // Write changes to gtk clipboard. 240 // Write changes to gtk clipboard.
212 void SetGtkClipboard(); 241 void SetGtkClipboard();
213 // Insert a mapping into clipboard_data_. 242 // Insert a mapping into clipboard_data_.
214 void InsertMapping(const char* key, char* data, size_t data_len); 243 void InsertMapping(const char* key, char* data, size_t data_len);
215 244
245 // find the gtk clipboard for the passed buffer enum
246 GtkClipboard* LookupBackingClipboard(Buffer clipboard) const;
247
216 TargetMap* clipboard_data_; 248 TargetMap* clipboard_data_;
217 GtkClipboard* clipboard_; 249 GtkClipboard* clipboard_;
250 GtkClipboard* primary_selection_;
218 #endif 251 #endif
219 252
220 DISALLOW_COPY_AND_ASSIGN(Clipboard); 253 DISALLOW_COPY_AND_ASSIGN(Clipboard);
221 }; 254 };
222 255
223 #endif // BASE_CLIPBOARD_H_ 256 #endif // BASE_CLIPBOARD_H_
OLDNEW
« no previous file with comments | « no previous file | base/clipboard_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698