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