OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void WriteHyperlink(const string16& anchor_text, const std::string& url); | 53 void WriteHyperlink(const string16& anchor_text, const std::string& url); |
54 | 54 |
55 // Used by WebKit to determine whether WebKit wrote the clipboard last | 55 // Used by WebKit to determine whether WebKit wrote the clipboard last |
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, Clipboard::FormatType format); | 63 void WritePickledData(const Pickle& pickle, |
| 64 const Clipboard::FormatType& format); |
64 | 65 |
65 protected: | 66 protected: |
66 // Converts |text| to UTF-8 and adds it to the clipboard. If it's a URL, we | 67 // Converts |text| to UTF-8 and adds it to the clipboard. If it's a URL, we |
67 // also notify the clipboard of that fact. | 68 // also notify the clipboard of that fact. |
68 void WriteTextOrURL(const string16& text, bool is_url); | 69 void WriteTextOrURL(const string16& text, bool is_url); |
69 | 70 |
70 // We accumulate the data passed to the various targets in the |objects_| | 71 // We accumulate the data passed to the various targets in the |objects_| |
71 // vector, and pass it to Clipboard::WriteObjects() during object destruction. | 72 // vector, and pass it to Clipboard::WriteObjects() during object destruction. |
72 Clipboard::ObjectMap objects_; | 73 Clipboard::ObjectMap objects_; |
73 Clipboard* clipboard_; | 74 Clipboard* clipboard_; |
74 | 75 |
75 // We keep around the UTF-8 text of the URL in order to pass it to | 76 // We keep around the UTF-8 text of the URL in order to pass it to |
76 // Clipboard::DidWriteURL(). | 77 // Clipboard::DidWriteURL(). |
77 std::string url_text_; | 78 std::string url_text_; |
78 | 79 |
79 private: | 80 private: |
80 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); | 81 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); |
81 }; | 82 }; |
82 | 83 |
83 } // namespace ui | 84 } // namespace ui |
84 | 85 |
85 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ | 86 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ |
86 | 87 |
OLD | NEW |