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

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

Issue 558913003: Remove clipboard argument from ScopedClipboardWriter constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 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
« no previous file with comments | « ui/base/clipboard/clipboard_unittest.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) 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 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 "ui/base/clipboard/clipboard.h" 17 #include "ui/base/clipboard/clipboard.h"
18 #include "ui/base/ui_base_export.h" 18 #include "ui/base/ui_base_export.h"
19 19
20 class Pickle; 20 class Pickle;
21 21
22 namespace ui { 22 namespace ui {
23 23
24 // This class is a wrapper for |Clipboard| that handles packing data 24 // This class is a wrapper for |Clipboard| that handles packing data
25 // into a Clipboard::ObjectMap. 25 // into a Clipboard::ObjectMap.
26 class UI_BASE_EXPORT ScopedClipboardWriter { 26 class UI_BASE_EXPORT ScopedClipboardWriter {
27 public: 27 public:
28 // Create an instance that is a simple wrapper around clipboard. 28 // Create an instance that is a simple wrapper around the clipboard of the
29 ScopedClipboardWriter(Clipboard* clipboard, ClipboardType type); 29 // given type.
30 explicit ScopedClipboardWriter(ClipboardType type);
30 31
31 ~ScopedClipboardWriter(); 32 ~ScopedClipboardWriter();
32 33
33 // Converts |text| to UTF-8 and adds it to the clipboard. 34 // Converts |text| to UTF-8 and adds it to the clipboard.
34 void WriteText(const base::string16& text); 35 void WriteText(const base::string16& text);
35 36
36 // Converts the text of the URL to UTF-8 and adds it to the clipboard, then 37 // Converts the text of the URL to UTF-8 and adds it to the clipboard, then
37 // notifies the Clipboard that we just wrote a URL. 38 // notifies the Clipboard that we just wrote a URL.
38 void WriteURL(const base::string16& text); 39 void WriteURL(const base::string16& text);
39 40
(...skipping 23 matching lines...) Expand all
63 // Removes all objects that would be written to the clipboard. 64 // Removes all objects that would be written to the clipboard.
64 void Reset(); 65 void Reset();
65 66
66 protected: 67 protected:
67 // Converts |text| to UTF-8 and adds it to the clipboard. If it's a URL, we 68 // 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. 69 // also notify the clipboard of that fact.
69 void WriteTextOrURL(const base::string16& text, bool is_url); 70 void WriteTextOrURL(const base::string16& text, bool is_url);
70 71
71 // We accumulate the data passed to the various targets in the |objects_| 72 // We accumulate the data passed to the various targets in the |objects_|
72 // vector, and pass it to Clipboard::WriteObjects() during object destruction. 73 // vector, and pass it to Clipboard::WriteObjects() during object destruction.
73 Clipboard::ObjectMap objects_; 74 Clipboard::ObjectMap objects_;
sky 2014/09/17 15:41:50 style guide says members should be private.
dcheng 2014/09/17 17:10:48 Yeah, ScopedClipboardWriterGlue directly modifies
74 Clipboard* clipboard_; 75 const ClipboardType type_;
75 ClipboardType type_;
76 76
77 // 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
78 // Clipboard::DidWriteURL(). 78 // Clipboard::DidWriteURL().
79 std::string url_text_; 79 std::string url_text_;
80 80
81 private: 81 private:
82 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); 82 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter);
83 }; 83 };
84 84
85 } // namespace ui 85 } // namespace ui
86 86
87 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_ 87 #endif // UI_BASE_CLIPBOARD_SCOPED_CLIPBOARD_WRITER_H_
88 88
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_unittest.cc ('k') | ui/base/clipboard/scoped_clipboard_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698