| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_BASE_CLIPBOARD_CLIPBOARD_H_ | 5 #ifndef UI_BASE_CLIPBOARD_CLIPBOARD_H_ |
| 6 #define UI_BASE_CLIPBOARD_CLIPBOARD_H_ | 6 #define UI_BASE_CLIPBOARD_CLIPBOARD_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 250 |
| 251 Clipboard() {} | 251 Clipboard() {} |
| 252 virtual ~Clipboard() {} | 252 virtual ~Clipboard() {} |
| 253 | 253 |
| 254 // ObjectType designates the type of data to be stored in the clipboard. This | 254 // ObjectType designates the type of data to be stored in the clipboard. This |
| 255 // designation is shared across all OSes. The system-specific designation | 255 // designation is shared across all OSes. The system-specific designation |
| 256 // is defined by FormatType. A single ObjectType might be represented by | 256 // is defined by FormatType. A single ObjectType might be represented by |
| 257 // several system-specific FormatTypes. For example, on Linux the CBF_TEXT | 257 // several system-specific FormatTypes. For example, on Linux the CBF_TEXT |
| 258 // ObjectType maps to "text/plain", "STRING", and several other formats. On | 258 // ObjectType maps to "text/plain", "STRING", and several other formats. On |
| 259 // windows it maps to CF_UNICODETEXT. | 259 // windows it maps to CF_UNICODETEXT. |
| 260 // |
| 261 // The order below is the order in which data will be written to the |
| 262 // clipboard, so more specific types must be listed before less specific |
| 263 // types. For example, placing an image on the clipboard might cause the |
| 264 // clipboard to contain a bitmap, HTML markup representing the image, a URL to |
| 265 // the image, and the image's alt text. Having the types follow this order |
| 266 // maximizes the amount of data that can be extracted by various programs. |
| 260 enum ObjectType { | 267 enum ObjectType { |
| 261 CBF_TEXT, | 268 CBF_SMBITMAP, // Bitmap from shared memory. |
| 262 CBF_HTML, | 269 CBF_HTML, |
| 263 CBF_RTF, | 270 CBF_RTF, |
| 264 CBF_BOOKMARK, | 271 CBF_BOOKMARK, |
| 272 CBF_TEXT, |
| 265 CBF_WEBKIT, | 273 CBF_WEBKIT, |
| 266 CBF_SMBITMAP, // Bitmap from shared memory. | |
| 267 CBF_DATA, // Arbitrary block of bytes. | 274 CBF_DATA, // Arbitrary block of bytes. |
| 268 }; | 275 }; |
| 269 | 276 |
| 270 // ObjectMap is a map from ObjectType to associated data. | 277 // ObjectMap is a map from ObjectType to associated data. |
| 271 // The data is organized differently for each ObjectType. The following | 278 // The data is organized differently for each ObjectType. The following |
| 272 // table summarizes what kind of data is stored for each key. | 279 // table summarizes what kind of data is stored for each key. |
| 273 // * indicates an optional argument. | 280 // * indicates an optional argument. |
| 274 // | 281 // |
| 275 // Key Arguments Type | 282 // Key Arguments Type |
| 276 // ------------------------------------- | 283 // ------------------------------------- |
| 277 // CBF_TEXT text char array | 284 // CBF_SMBITMAP bitmap A pointer to a SkBitmap. The caller must ensure |
| 285 // the SkBitmap remains live for the duration of |
| 286 // the WriteObjects call. |
| 278 // CBF_HTML html char array | 287 // CBF_HTML html char array |
| 279 // url* char array | 288 // url* char array |
| 280 // CBF_RTF data byte array | 289 // CBF_RTF data byte array |
| 281 // CBF_BOOKMARK html char array | 290 // CBF_BOOKMARK html char array |
| 282 // url char array | 291 // url char array |
| 292 // CBF_TEXT text char array |
| 283 // CBF_WEBKIT none empty vector | 293 // CBF_WEBKIT none empty vector |
| 284 // CBF_SMBITMAP bitmap A pointer to a SkBitmap. The caller must ensure | |
| 285 // the SkBitmap remains live for the duration of | |
| 286 // the WriteObjects call. | |
| 287 // CBF_DATA format char array | 294 // CBF_DATA format char array |
| 288 // data byte array | 295 // data byte array |
| 289 typedef std::vector<char> ObjectMapParam; | 296 typedef std::vector<char> ObjectMapParam; |
| 290 typedef std::vector<ObjectMapParam> ObjectMapParams; | 297 typedef std::vector<ObjectMapParam> ObjectMapParams; |
| 291 typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap; | 298 typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap; |
| 292 | 299 |
| 293 // Write a bunch of objects to the system clipboard. Copies are made of the | 300 // Write a bunch of objects to the system clipboard. Copies are made of the |
| 294 // contents of |objects|. | 301 // contents of |objects|. |
| 295 virtual void WriteObjects(ClipboardType type, const ObjectMap& objects) = 0; | 302 virtual void WriteObjects(ClipboardType type, const ObjectMap& objects) = 0; |
| 296 | 303 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 348 |
| 342 // Mutex that controls access to |g_clipboard_map|. | 349 // Mutex that controls access to |g_clipboard_map|. |
| 343 static base::LazyInstance<base::Lock>::Leaky clipboard_map_lock_; | 350 static base::LazyInstance<base::Lock>::Leaky clipboard_map_lock_; |
| 344 | 351 |
| 345 DISALLOW_COPY_AND_ASSIGN(Clipboard); | 352 DISALLOW_COPY_AND_ASSIGN(Clipboard); |
| 346 }; | 353 }; |
| 347 | 354 |
| 348 } // namespace ui | 355 } // namespace ui |
| 349 | 356 |
| 350 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_ | 357 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_ |
| OLD | NEW |