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 // 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 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void WriteWebSmartPaste(); | 56 void WriteWebSmartPaste(); |
57 | 57 |
58 // Adds a bitmap to the clipboard | 58 // Adds a bitmap to the clipboard |
59 // Pixel format is assumed to be 32-bit BI_RGB. | 59 // Pixel format is assumed to be 32-bit BI_RGB. |
60 void WriteBitmapFromPixels(const void* pixels, const gfx::Size& size); | 60 void WriteBitmapFromPixels(const void* pixels, const gfx::Size& size); |
61 | 61 |
62 // Adds arbitrary data to clipboard. | 62 // Adds arbitrary data to clipboard. |
63 void WritePickledData(const Pickle& pickle, | 63 void WritePickledData(const Pickle& pickle, |
64 const Clipboard::FormatType& format); | 64 const Clipboard::FormatType& format); |
65 | 65 |
| 66 // Removes all objects that would be written to the clipboard. |
| 67 void Reset(); |
| 68 |
66 protected: | 69 protected: |
67 // Converts |text| to UTF-8 and adds it to the clipboard. If it's a URL, we | 70 // Converts |text| to UTF-8 and adds it to the clipboard. If it's a URL, we |
68 // also notify the clipboard of that fact. | 71 // also notify the clipboard of that fact. |
69 void WriteTextOrURL(const string16& text, bool is_url); | 72 void WriteTextOrURL(const string16& text, bool is_url); |
70 | 73 |
71 // We accumulate the data passed to the various targets in the |objects_| | 74 // We accumulate the data passed to the various targets in the |objects_| |
72 // vector, and pass it to Clipboard::WriteObjects() during object destruction. | 75 // vector, and pass it to Clipboard::WriteObjects() during object destruction. |
73 Clipboard::ObjectMap objects_; | 76 Clipboard::ObjectMap objects_; |
74 Clipboard* clipboard_; | 77 Clipboard* clipboard_; |
75 Clipboard::Buffer buffer_; | 78 Clipboard::Buffer buffer_; |
76 | 79 |
77 // We keep around the UTF-8 text of the URL in order to pass it to | 80 // We keep around the UTF-8 text of the URL in order to pass it to |
78 // Clipboard::DidWriteURL(). | 81 // Clipboard::DidWriteURL(). |
79 std::string url_text_; | 82 std::string url_text_; |
80 | 83 |
81 private: | 84 private: |
82 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); | 85 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); |
83 }; | 86 }; |
84 | 87 |
85 } // namespace ui | 88 } // namespace ui |
86 | 89 |
87 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ | 90 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ |
88 | 91 |
OLD | NEW |