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 the clipboard, | 7 // Upon deletion the class atomically writes all data to the 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 |
11 #ifndef UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ | 11 #ifndef UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ |
12 #define UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ | 12 #define UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" |
17 #include "ui/base/clipboard/clipboard.h" | 18 #include "ui/base/clipboard/clipboard.h" |
18 #include "ui/base/ui_base_export.h" | 19 #include "ui/base/ui_base_export.h" |
19 | 20 |
20 class Pickle; | 21 class Pickle; |
21 | 22 |
22 namespace ui { | 23 namespace ui { |
23 | 24 |
24 // This class is a wrapper for |Clipboard| that handles packing data | 25 // This class is a wrapper for |Clipboard| that handles packing data |
25 // into a Clipboard::ObjectMap. | 26 // into a Clipboard::ObjectMap. |
26 class UI_BASE_EXPORT ScopedClipboardWriter { | 27 class UI_BASE_EXPORT ScopedClipboardWriter { |
(...skipping 27 matching lines...) Expand all Loading... |
54 void WriteHyperlink(const base::string16& anchor_text, | 55 void WriteHyperlink(const base::string16& anchor_text, |
55 const std::string& url); | 56 const std::string& url); |
56 | 57 |
57 // Used by WebKit to determine whether WebKit wrote the clipboard last | 58 // Used by WebKit to determine whether WebKit wrote the clipboard last |
58 void WriteWebSmartPaste(); | 59 void WriteWebSmartPaste(); |
59 | 60 |
60 // Adds arbitrary pickled data to clipboard. | 61 // Adds arbitrary pickled data to clipboard. |
61 void WritePickledData(const Pickle& pickle, | 62 void WritePickledData(const Pickle& pickle, |
62 const Clipboard::FormatType& format); | 63 const Clipboard::FormatType& format); |
63 | 64 |
| 65 void WriteImage(const SkBitmap& bitmap); |
| 66 |
64 // Removes all objects that would be written to the clipboard. | 67 // Removes all objects that would be written to the clipboard. |
65 void Reset(); | 68 void Reset(); |
66 | 69 |
67 protected: | 70 private: |
68 // Converts |text| to UTF-8 and adds it to the clipboard. If it's a URL, we | 71 // Converts |text| to UTF-8 and adds it to the clipboard. If it's a URL, we |
69 // also notify the clipboard of that fact. | 72 // also notify the clipboard of that fact. |
70 void WriteTextOrURL(const base::string16& text, bool is_url); | 73 void WriteTextOrURL(const base::string16& text, bool is_url); |
71 | 74 |
72 // We accumulate the data passed to the various targets in the |objects_| | 75 // We accumulate the data passed to the various targets in the |objects_| |
73 // vector, and pass it to Clipboard::WriteObjects() during object destruction. | 76 // vector, and pass it to Clipboard::WriteObjects() during object destruction. |
74 Clipboard::ObjectMap objects_; | 77 Clipboard::ObjectMap objects_; |
75 const ClipboardType type_; | 78 const ClipboardType type_; |
76 | 79 |
| 80 SkBitmap bitmap_; |
| 81 |
77 // 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 |
78 // Clipboard::DidWriteURL(). | 83 // Clipboard::DidWriteURL(). |
79 std::string url_text_; | 84 std::string url_text_; |
80 | 85 |
81 private: | |
82 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); | 86 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); |
83 }; | 87 }; |
84 | 88 |
85 } // namespace ui | 89 } // namespace ui |
86 | 90 |
87 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ | 91 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ |
88 | 92 |
OLD | NEW |