OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SCOPED_CLIPBOARD_WRITER_H_ |
| 6 #define SCOPED_CLIPBOARD_WRITER_H_ |
| 7 |
| 8 #include "base/clipboard.h" |
| 9 |
| 10 #if defined(OS_WIN) |
| 11 class SkBitmap; |
| 12 #endif |
| 13 |
| 14 // This class is a wrapper for |Clipboard| that handles packing data |
| 15 // into a Clipboard::ObjectMap. |
| 16 // NB: You should probably NOT be using this class if you include |
| 17 // webkit_glue.h. Use ScopedClipboardWriterGlue instead. |
| 18 class ScopedClipboardWriter { |
| 19 public: |
| 20 // Create an instance that is a simple wrapper around clipboard. |
| 21 ScopedClipboardWriter(Clipboard* clipboard); |
| 22 |
| 23 ~ScopedClipboardWriter(); |
| 24 |
| 25 // Adds UNICODE and ASCII text to the clipboard. |
| 26 void WriteText(const std::wstring& text); |
| 27 |
| 28 // Adds HTML to the clipboard. The url parameter is optional, but especially |
| 29 // useful if the HTML fragment contains relative links |
| 30 void WriteHTML(const std::wstring& markup, const std::string& src_url); |
| 31 |
| 32 // Adds a bookmark to the clipboard |
| 33 void WriteBookmark(const std::wstring& title, const std::string& url); |
| 34 |
| 35 // Adds both a bookmark and an HTML hyperlink to the clipboard. It is a |
| 36 // convenience wrapper around WriteBookmark and WriteHTML. |
| 37 void WriteHyperlink(const std::wstring& title, const std::string& url); |
| 38 |
| 39 // Adds a file or group of files to the clipboard. |
| 40 void WriteFile(const std::wstring& file); |
| 41 void WriteFiles(const std::vector<std::wstring>& files); |
| 42 |
| 43 #if defined(OS_WIN) |
| 44 // Used by WebKit to determine whether WebKit wrote the clipboard last |
| 45 void WriteWebSmartPaste(); |
| 46 |
| 47 // Adds a bitmap to the clipboard |
| 48 // This is the slowest way to copy a bitmap to the clipboard as we must first |
| 49 // memcpy the pixels into GDI and the blit the bitmap to the clipboard. |
| 50 // Pixel format is assumed to be 32-bit BI_RGB. |
| 51 void WriteBitmapFromPixels(const void* pixels, const gfx::Size& size); |
| 52 #endif |
| 53 |
| 54 protected: |
| 55 Clipboard::ObjectMap objects_; |
| 56 Clipboard* clipboard_; |
| 57 |
| 58 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); |
| 60 }; |
| 61 |
| 62 #endif // SCOPED_CLIPBOARD_WRITER_H_ |
OLD | NEW |