Chromium Code Reviews| 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(OS_LINUX) || defined(OS_OPENBSD) |
|
tony
2009/06/10 18:42:04
After some discussion with some others working on
| |
| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 | 176 |
| 177 // Return the window that should be the clipboard owner, creating it | 177 // Return the window that should be the clipboard owner, creating it |
| 178 // if neccessary. Marked const for lazily initialization by const methods. | 178 // if neccessary. Marked const for lazily initialization by const methods. |
| 179 HWND GetClipboardWindow() const; | 179 HWND GetClipboardWindow() const; |
| 180 | 180 |
| 181 // Mark this as mutable so const methods can still do lazy initialization. | 181 // Mark this as mutable so const methods can still do lazy initialization. |
| 182 mutable HWND clipboard_owner_; | 182 mutable HWND clipboard_owner_; |
| 183 | 183 |
| 184 // True if we can create a window. | 184 // True if we can create a window. |
| 185 bool create_window_; | 185 bool create_window_; |
| 186 #elif defined(OS_LINUX) | 186 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
| 187 // Data is stored in the |clipboard_data_| map until it is saved to the system | 187 // Data is stored in the |clipboard_data_| map until it is saved to the system |
| 188 // clipboard. The Store* functions save data to the |clipboard_data_| map. The | 188 // clipboard. The Store* functions save data to the |clipboard_data_| map. The |
| 189 // SetGtkClipboard function replaces whatever is on the system clipboard with | 189 // SetGtkClipboard function replaces whatever is on the system clipboard with |
| 190 // the contents of |clipboard_data_|. | 190 // the contents of |clipboard_data_|. |
| 191 // The Write* functions make a deep copy of the data passed to them an store | 191 // The Write* functions make a deep copy of the data passed to them an store |
| 192 // it in |clipboard_data_|. | 192 // it in |clipboard_data_|. |
| 193 | 193 |
| 194 // Write changes to gtk clipboard. | 194 // Write changes to gtk clipboard. |
| 195 void SetGtkClipboard(); | 195 void SetGtkClipboard(); |
| 196 // Free pointers in clipboard_data_ and clear() the map. | 196 // Free pointers in clipboard_data_ and clear() the map. |
| 197 void FreeTargetMap(); | 197 void FreeTargetMap(); |
| 198 // Insert a mapping into clipboard_data_. | 198 // Insert a mapping into clipboard_data_. |
| 199 void InsertMapping(const char* key, char* data, size_t data_len); | 199 void InsertMapping(const char* key, char* data, size_t data_len); |
| 200 | 200 |
| 201 TargetMap* clipboard_data_; | 201 TargetMap* clipboard_data_; |
| 202 GtkClipboard* clipboard_; | 202 GtkClipboard* clipboard_; |
| 203 #endif | 203 #endif |
| 204 | 204 |
| 205 DISALLOW_EVIL_CONSTRUCTORS(Clipboard); | 205 DISALLOW_EVIL_CONSTRUCTORS(Clipboard); |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 #endif // BASE_CLIPBOARD_H_ | 208 #endif // BASE_CLIPBOARD_H_ |
| OLD | NEW |