OLD | NEW |
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> |
11 | 11 |
12 #include "base/process.h" | 12 #include "base/process.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 | 14 |
15 namespace gfx { | 15 namespace gfx { |
16 class Size; | 16 class Size; |
17 } | 17 } |
18 | 18 |
19 class FilePath; | 19 class FilePath; |
20 | 20 |
21 class Clipboard { | 21 class Clipboard { |
22 public: | 22 public: |
23 typedef std::string FormatType; | 23 typedef std::string FormatType; |
24 #if defined(OS_LINUX) | 24 #if defined(USE_X11) |
25 typedef struct _GtkClipboard GtkClipboard; | 25 typedef struct _GtkClipboard GtkClipboard; |
26 typedef std::map<FormatType, std::pair<char*, size_t> > TargetMap; | 26 typedef std::map<FormatType, std::pair<char*, size_t> > TargetMap; |
27 #endif | 27 #endif |
28 | 28 |
29 // ObjectType designates the type of data to be stored in the clipboard. This | 29 // ObjectType designates the type of data to be stored in the clipboard. This |
30 // designation is shared across all OSes. The system-specific designation | 30 // designation is shared across all OSes. The system-specific designation |
31 // is defined by FormatType. A single ObjectType might be represented by | 31 // is defined by FormatType. A single ObjectType might be represented by |
32 // several system-specific FormatTypes. For example, on Linux the CBF_TEXT | 32 // several system-specific FormatTypes. For example, on Linux the CBF_TEXT |
33 // ObjectType maps to "text/plain", "STRING", and several other formats. On | 33 // ObjectType maps to "text/plain", "STRING", and several other formats. On |
34 // windows it maps to CF_UNICODETEXT. | 34 // windows it maps to CF_UNICODETEXT. |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 void WriteHyperlink(const char* title_data, | 160 void WriteHyperlink(const char* title_data, |
161 size_t title_len, | 161 size_t title_len, |
162 const char* url_data, | 162 const char* url_data, |
163 size_t url_len); | 163 size_t url_len); |
164 | 164 |
165 void WriteWebSmartPaste(); | 165 void WriteWebSmartPaste(); |
166 | 166 |
167 void WriteFiles(const char* file_data, size_t file_len); | 167 void WriteFiles(const char* file_data, size_t file_len); |
168 | 168 |
169 void WriteBitmap(const char* pixel_data, const char* size_data); | 169 void WriteBitmap(const char* pixel_data, const char* size_data); |
170 #if defined(OS_WIN) || defined(OS_LINUX) | 170 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_FREEBSD) |
171 // |format_name| is an ASCII string and should be NULL-terminated. | 171 // |format_name| is an ASCII string and should be NULL-terminated. |
172 // TODO(estade): port to mac. | 172 // TODO(estade): port to mac. |
173 void WriteData(const char* format_name, size_t format_len, | 173 void WriteData(const char* format_name, size_t format_len, |
174 const char* data_data, size_t data_len); | 174 const char* data_data, size_t data_len); |
175 #endif | 175 #endif |
176 #if defined(OS_WIN) | 176 #if defined(OS_WIN) |
177 void WriteBitmapFromSharedMemory(const char* bitmap_data, | 177 void WriteBitmapFromSharedMemory(const char* bitmap_data, |
178 const char* size_data, | 178 const char* size_data, |
179 base::ProcessHandle handle); | 179 base::ProcessHandle handle); |
180 | 180 |
(...skipping 12 matching lines...) Expand all Loading... |
193 | 193 |
194 // Return the window that should be the clipboard owner, creating it | 194 // Return the window that should be the clipboard owner, creating it |
195 // if neccessary. Marked const for lazily initialization by const methods. | 195 // if neccessary. Marked const for lazily initialization by const methods. |
196 HWND GetClipboardWindow() const; | 196 HWND GetClipboardWindow() const; |
197 | 197 |
198 // Mark this as mutable so const methods can still do lazy initialization. | 198 // Mark this as mutable so const methods can still do lazy initialization. |
199 mutable HWND clipboard_owner_; | 199 mutable HWND clipboard_owner_; |
200 | 200 |
201 // True if we can create a window. | 201 // True if we can create a window. |
202 bool create_window_; | 202 bool create_window_; |
203 #elif defined(OS_LINUX) | 203 #elif defined(USE_X11) |
204 // Data is stored in the |clipboard_data_| map until it is saved to the system | 204 // Data is stored in the |clipboard_data_| map until it is saved to the system |
205 // clipboard. The Store* functions save data to the |clipboard_data_| map. The | 205 // clipboard. The Store* functions save data to the |clipboard_data_| map. The |
206 // SetGtkClipboard function replaces whatever is on the system clipboard with | 206 // SetGtkClipboard function replaces whatever is on the system clipboard with |
207 // the contents of |clipboard_data_|. | 207 // the contents of |clipboard_data_|. |
208 // The Write* functions make a deep copy of the data passed to them an store | 208 // The Write* functions make a deep copy of the data passed to them an store |
209 // it in |clipboard_data_|. | 209 // it in |clipboard_data_|. |
210 | 210 |
211 // Write changes to gtk clipboard. | 211 // Write changes to gtk clipboard. |
212 void SetGtkClipboard(); | 212 void SetGtkClipboard(); |
213 // Insert a mapping into clipboard_data_. | 213 // Insert a mapping into clipboard_data_. |
214 void InsertMapping(const char* key, char* data, size_t data_len); | 214 void InsertMapping(const char* key, char* data, size_t data_len); |
215 | 215 |
216 TargetMap* clipboard_data_; | 216 TargetMap* clipboard_data_; |
217 GtkClipboard* clipboard_; | 217 GtkClipboard* clipboard_; |
218 #endif | 218 #endif |
219 | 219 |
220 DISALLOW_COPY_AND_ASSIGN(Clipboard); | 220 DISALLOW_COPY_AND_ASSIGN(Clipboard); |
221 }; | 221 }; |
222 | 222 |
223 #endif // BASE_CLIPBOARD_H_ | 223 #endif // BASE_CLIPBOARD_H_ |
OLD | NEW |