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 "third_party/skia/include/core/SkBitmap.h" |
18 #include "ui/base/clipboard/clipboard.h" | 18 #include "ui/base/clipboard/clipboard.h" |
19 #include "ui/base/ui_base_export.h" | 19 #include "ui/base/ui_base_export.h" |
20 | 20 |
| 21 namespace base { |
21 class Pickle; | 22 class Pickle; |
| 23 } |
22 | 24 |
23 namespace ui { | 25 namespace ui { |
24 | 26 |
25 // This class is a wrapper for |Clipboard| that handles packing data | 27 // This class is a wrapper for |Clipboard| that handles packing data |
26 // into a Clipboard::ObjectMap. | 28 // into a Clipboard::ObjectMap. |
27 class UI_BASE_EXPORT ScopedClipboardWriter { | 29 class UI_BASE_EXPORT ScopedClipboardWriter { |
28 public: | 30 public: |
29 // Create an instance that is a simple wrapper around the clipboard of the | 31 // Create an instance that is a simple wrapper around the clipboard of the |
30 // given type. | 32 // given type. |
31 explicit ScopedClipboardWriter(ClipboardType type); | 33 explicit ScopedClipboardWriter(ClipboardType type); |
(...skipping 20 matching lines...) Expand all Loading... |
52 | 54 |
53 // Adds an html hyperlink (<a href>) to the clipboard. |anchor_text| and | 55 // Adds an html hyperlink (<a href>) to the clipboard. |anchor_text| and |
54 // |url| will be escaped as needed. | 56 // |url| will be escaped as needed. |
55 void WriteHyperlink(const base::string16& anchor_text, | 57 void WriteHyperlink(const base::string16& anchor_text, |
56 const std::string& url); | 58 const std::string& url); |
57 | 59 |
58 // Used by WebKit to determine whether WebKit wrote the clipboard last | 60 // Used by WebKit to determine whether WebKit wrote the clipboard last |
59 void WriteWebSmartPaste(); | 61 void WriteWebSmartPaste(); |
60 | 62 |
61 // Adds arbitrary pickled data to clipboard. | 63 // Adds arbitrary pickled data to clipboard. |
62 void WritePickledData(const Pickle& pickle, | 64 void WritePickledData(const base::Pickle& pickle, |
63 const Clipboard::FormatType& format); | 65 const Clipboard::FormatType& format); |
64 | 66 |
65 void WriteImage(const SkBitmap& bitmap); | 67 void WriteImage(const SkBitmap& bitmap); |
66 | 68 |
67 // Removes all objects that would be written to the clipboard. | 69 // Removes all objects that would be written to the clipboard. |
68 void Reset(); | 70 void Reset(); |
69 | 71 |
70 private: | 72 private: |
71 // Converts |text| to UTF-8 and adds it to the clipboard. If it's a URL, we | 73 // Converts |text| to UTF-8 and adds it to the clipboard. If it's a URL, we |
72 // also notify the clipboard of that fact. | 74 // also notify the clipboard of that fact. |
(...skipping 10 matching lines...) Expand all Loading... |
83 // Clipboard::DidWriteURL(). | 85 // Clipboard::DidWriteURL(). |
84 std::string url_text_; | 86 std::string url_text_; |
85 | 87 |
86 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); | 88 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); |
87 }; | 89 }; |
88 | 90 |
89 } // namespace ui | 91 } // namespace ui |
90 | 92 |
91 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ | 93 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ |
92 | 94 |
OLD | NEW |