OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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 // This file declares the ScopedClipboardWriter class, a wrapper around | 5 // This file declares the ScopedClipboardWriter class, a wrapper around |
6 // the Clipboard class which simplifies writing data to the system clipboard. | 6 // the Clipboard class which simplifies writing data to the system clipboard. |
7 // Upon deletion the class atomically writes all data to |clipboard_|, | 7 // Upon deletion the class atomically writes all data to |clipboard_|, |
8 // avoiding any potential race condition with other processes that are also | 8 // avoiding any potential race condition with other processes that are also |
9 // writing to the system clipboard. | 9 // writing to the system clipboard. |
10 #ifndef BASE_SCOPED_CLIPBOARD_WRITER_H_ | 10 #ifndef BASE_SCOPED_CLIPBOARD_WRITER_H_ |
(...skipping 23 matching lines...) Expand all Loading... |
34 void WriteText(const string16& text); | 34 void WriteText(const string16& text); |
35 | 35 |
36 // Adds HTML to the clipboard. The url parameter is optional, but especially | 36 // Adds HTML to the clipboard. The url parameter is optional, but especially |
37 // useful if the HTML fragment contains relative links. | 37 // useful if the HTML fragment contains relative links. |
38 void WriteHTML(const string16& markup, const std::string& source_url); | 38 void WriteHTML(const string16& markup, const std::string& source_url); |
39 | 39 |
40 // Adds a bookmark to the clipboard. | 40 // Adds a bookmark to the clipboard. |
41 void WriteBookmark(const string16& bookmark_title, | 41 void WriteBookmark(const string16& bookmark_title, |
42 const std::string& url); | 42 const std::string& url); |
43 | 43 |
44 // Adds both a bookmark and an HTML hyperlink to the clipboard. It is a | 44 // Adds an html hyperlink (<a href>) to the clipboard. |anchor_text| should |
45 // convenience wrapper around WriteBookmark and WriteHTML. |link_text| is | 45 // be escaped prior to being passed in. |
46 // used as the bookmark title. | 46 void WriteHyperlink(const std::string& anchor_text, const std::string& url); |
47 void WriteHyperlink(const string16& link_text, const std::string& url); | |
48 | 47 |
49 // Adds a file or group of files to the clipboard. | 48 // Adds a file or group of files to the clipboard. |
50 void WriteFile(const FilePath& file); | 49 void WriteFile(const FilePath& file); |
51 void WriteFiles(const std::vector<FilePath>& files); | 50 void WriteFiles(const std::vector<FilePath>& files); |
52 | 51 |
53 // Used by WebKit to determine whether WebKit wrote the clipboard last | 52 // Used by WebKit to determine whether WebKit wrote the clipboard last |
54 void WriteWebSmartPaste(); | 53 void WriteWebSmartPaste(); |
55 | 54 |
56 // Adds a bitmap to the clipboard | 55 // Adds a bitmap to the clipboard |
57 // Pixel format is assumed to be 32-bit BI_RGB. | 56 // Pixel format is assumed to be 32-bit BI_RGB. |
58 void WriteBitmapFromPixels(const void* pixels, const gfx::Size& size); | 57 void WriteBitmapFromPixels(const void* pixels, const gfx::Size& size); |
59 | 58 |
60 // Adds arbitrary data to clipboard. | 59 // Adds arbitrary data to clipboard. |
61 void WritePickledData(const Pickle& pickle, Clipboard::FormatType format); | 60 void WritePickledData(const Pickle& pickle, Clipboard::FormatType format); |
62 | 61 |
63 protected: | 62 protected: |
64 // We accumulate the data passed to the various targets in the |objects_| | 63 // We accumulate the data passed to the various targets in the |objects_| |
65 // vector, and pass it to Clipboard::WriteObjects() during object destruction. | 64 // vector, and pass it to Clipboard::WriteObjects() during object destruction. |
66 Clipboard::ObjectMap objects_; | 65 Clipboard::ObjectMap objects_; |
67 Clipboard* clipboard_; | 66 Clipboard* clipboard_; |
68 | 67 |
69 private: | 68 private: |
70 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); | 69 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); |
71 }; | 70 }; |
72 | 71 |
73 #endif // BASE_SCOPED_CLIPBOARD_WRITER_H_ | 72 #endif // BASE_SCOPED_CLIPBOARD_WRITER_H_ |
OLD | NEW |