Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: ui/base/clipboard/scoped_clipboard_writer.h

Issue 9232075: Have ScopedClipboardWriter and Clipboard::WriteObjects take a buffer parameter. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix build error. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/clipboard/clipboard_win.cc ('k') | ui/base/clipboard/scoped_clipboard_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 22
23 namespace ui { 23 namespace ui {
24 24
25 // This class is a wrapper for |Clipboard| that handles packing data 25 // This class is a wrapper for |Clipboard| that handles packing data
26 // into a Clipboard::ObjectMap. 26 // into a Clipboard::ObjectMap.
27 // NB: You should probably NOT be using this class if you include 27 // NB: You should probably NOT be using this class if you include
28 // webkit_glue.h. Use ScopedClipboardWriterGlue instead. 28 // webkit_glue.h. Use ScopedClipboardWriterGlue instead.
29 class UI_EXPORT ScopedClipboardWriter { 29 class UI_EXPORT ScopedClipboardWriter {
30 public: 30 public:
31 // Create an instance that is a simple wrapper around clipboard. 31 // Create an instance that is a simple wrapper around clipboard.
32 explicit ScopedClipboardWriter(Clipboard* clipboard); 32 ScopedClipboardWriter(Clipboard* clipboard, Clipboard::Buffer buffer);
33 33
34 ~ScopedClipboardWriter(); 34 ~ScopedClipboardWriter();
35 35
36 // Converts |text| to UTF-8 and adds it to the clipboard. 36 // Converts |text| to UTF-8 and adds it to the clipboard.
37 void WriteText(const string16& text); 37 void WriteText(const string16& text);
38 38
39 // Converts the text of the URL to UTF-8 and adds it to the clipboard, then 39 // Converts the text of the URL to UTF-8 and adds it to the clipboard, then
40 // notifies the Clipboard that we just wrote a URL. 40 // notifies the Clipboard that we just wrote a URL.
41 void WriteURL(const string16& text); 41 void WriteURL(const string16& text);
42 42
(...skipping 22 matching lines...) Expand all
65 65
66 protected: 66 protected:
67 // 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
68 // also notify the clipboard of that fact. 68 // also notify the clipboard of that fact.
69 void WriteTextOrURL(const string16& text, bool is_url); 69 void WriteTextOrURL(const string16& text, bool is_url);
70 70
71 // 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_|
72 // vector, and pass it to Clipboard::WriteObjects() during object destruction. 72 // vector, and pass it to Clipboard::WriteObjects() during object destruction.
73 Clipboard::ObjectMap objects_; 73 Clipboard::ObjectMap objects_;
74 Clipboard* clipboard_; 74 Clipboard* clipboard_;
75 Clipboard::Buffer buffer_;
75 76
76 // We keep around the UTF-8 text of the URL in order to pass it to 77 // We keep around the UTF-8 text of the URL in order to pass it to
77 // Clipboard::DidWriteURL(). 78 // Clipboard::DidWriteURL().
78 std::string url_text_; 79 std::string url_text_;
79 80
80 private: 81 private:
81 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); 82 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter);
82 }; 83 };
83 84
84 } // namespace ui 85 } // namespace ui
85 86
86 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ 87 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_
87 88
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_win.cc ('k') | ui/base/clipboard/scoped_clipboard_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698