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

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

Issue 2047703003: Revert of Implement ui::ClipboardMus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/BUILD.gn ('k') | ui/base/clipboard/clipboard.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 #ifndef UI_BASE_CLIPBOARD_CLIPBOARD_H_ 5 #ifndef UI_BASE_CLIPBOARD_CLIPBOARD_H_
6 #define UI_BASE_CLIPBOARD_CLIPBOARD_H_ 6 #define UI_BASE_CLIPBOARD_CLIPBOARD_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory>
13 #include <string> 12 #include <string>
14 #include <vector> 13 #include <vector>
15 14
16 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
17 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
18 #include "base/macros.h" 17 #include "base/macros.h"
19 #include "base/process/process.h" 18 #include "base/process/process.h"
20 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
21 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
22 #include "base/threading/platform_thread.h" 21 #include "base/threading/platform_thread.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 class ClipboardTest; 53 class ClipboardTest;
55 class TestClipboard; 54 class TestClipboard;
56 class ScopedClipboardWriter; 55 class ScopedClipboardWriter;
57 56
58 class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) { 57 class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
59 public: 58 public:
60 // MIME type constants. 59 // MIME type constants.
61 static const char kMimeTypeText[]; 60 static const char kMimeTypeText[];
62 static const char kMimeTypeURIList[]; 61 static const char kMimeTypeURIList[];
63 static const char kMimeTypeDownloadURL[]; 62 static const char kMimeTypeDownloadURL[];
64 static const char kMimeTypeMozillaURL[];
65 static const char kMimeTypeHTML[]; 63 static const char kMimeTypeHTML[];
66 static const char kMimeTypeRTF[]; 64 static const char kMimeTypeRTF[];
67 static const char kMimeTypePNG[]; 65 static const char kMimeTypePNG[];
68 static const char kMimeTypeWebCustomData[];
69 static const char kMimeTypeWebkitSmartPaste[];
70 static const char kMimeTypePepperCustomData[];
71 66
72 // Platform neutral holder for native data representation of a clipboard type. 67 // Platform neutral holder for native data representation of a clipboard type.
73 struct UI_BASE_EXPORT FormatType { 68 struct UI_BASE_EXPORT FormatType {
74 FormatType(); 69 FormatType();
75 ~FormatType(); 70 ~FormatType();
76 71
77 // Serializes and deserializes a FormatType for use in IPC messages. 72 // Serializes and deserializes a FormatType for use in IPC messages.
78 std::string Serialize() const; 73 std::string Serialize() const;
79 static FormatType Deserialize(const std::string& serialization); 74 static FormatType Deserialize(const std::string& serialization);
80 75
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 130 }
136 131
137 static ClipboardType FromInt(int32_t type) { 132 static ClipboardType FromInt(int32_t type) {
138 return static_cast<ClipboardType>(type); 133 return static_cast<ClipboardType>(type);
139 } 134 }
140 135
141 // Sets the list of threads that are allowed to access the clipboard. 136 // Sets the list of threads that are allowed to access the clipboard.
142 static void SetAllowedThreads( 137 static void SetAllowedThreads(
143 const std::vector<base::PlatformThreadId>& allowed_threads); 138 const std::vector<base::PlatformThreadId>& allowed_threads);
144 139
145 // Sets the clipboard for the current thread. Previously, there was only
146 // one clipboard implementation on a platform; now that mus exists, during
147 // mus app startup, we need to specifically initialize mus instead of the
148 // current platform clipboard. We take ownership of |platform_clipboard|.
149 static void SetClipboardForCurrentThread(
150 std::unique_ptr<Clipboard> platform_clipboard);
151
152 // Returns the clipboard object for the current thread. 140 // Returns the clipboard object for the current thread.
153 // 141 //
154 // Most implementations will have at most one clipboard which will live on 142 // Most implementations will have at most one clipboard which will live on
155 // the main UI thread, but Windows has tricky semantics where there have to 143 // the main UI thread, but Windows has tricky semantics where there have to
156 // be two clipboards: one that lives on the UI thread and one that lives on 144 // be two clipboards: one that lives on the UI thread and one that lives on
157 // the IO thread. 145 // the IO thread.
158 static Clipboard* GetForCurrentThread(); 146 static Clipboard* GetForCurrentThread();
159 147
160 // Destroys the clipboard for the current thread. Usually, this will clean up 148 // Destroys the clipboard for the current thread. Usually, this will clean up
161 // all clipboards, except on Windows. (Previous code leaks the IO thread 149 // all clipboards, except on Windows. (Previous code leaks the IO thread
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 virtual void WriteWebSmartPaste() = 0; 301 virtual void WriteWebSmartPaste() = 0;
314 302
315 virtual void WriteBitmap(const SkBitmap& bitmap) = 0; 303 virtual void WriteBitmap(const SkBitmap& bitmap) = 0;
316 304
317 virtual void WriteData(const FormatType& format, 305 virtual void WriteData(const FormatType& format,
318 const char* data_data, 306 const char* data_data,
319 size_t data_len) = 0; 307 size_t data_len) = 0;
320 308
321 private: 309 private:
322 // For access to WriteObjects(). 310 // For access to WriteObjects().
323 friend class ForwardingTestingClipboard;
324 friend class ScopedClipboardWriter; 311 friend class ScopedClipboardWriter;
325 friend class TestClipboard; 312 friend class TestClipboard;
326 // For SetClipboardForCurrentThread's argument.
327 friend struct std::default_delete<Clipboard>;
328
329 static base::PlatformThreadId GetAndValidateThreadID();
330 313
331 // A list of allowed threads. By default, this is empty and no thread checking 314 // A list of allowed threads. By default, this is empty and no thread checking
332 // is done (in the unit test case), but a user (like content) can set which 315 // is done (in the unit test case), but a user (like content) can set which
333 // threads are allowed to call this method. 316 // threads are allowed to call this method.
334 typedef std::vector<base::PlatformThreadId> AllowedThreadsVector; 317 typedef std::vector<base::PlatformThreadId> AllowedThreadsVector;
335 static base::LazyInstance<AllowedThreadsVector> allowed_threads_; 318 static base::LazyInstance<AllowedThreadsVector> allowed_threads_;
336 319
337 // Mapping from threads to clipboard objects. 320 // Mapping from threads to clipboard objects.
338 typedef std::map<base::PlatformThreadId, std::unique_ptr<Clipboard>> 321 typedef std::map<base::PlatformThreadId, Clipboard*> ClipboardMap;
339 ClipboardMap;
340 static base::LazyInstance<ClipboardMap> clipboard_map_; 322 static base::LazyInstance<ClipboardMap> clipboard_map_;
341 323
342 // Mutex that controls access to |g_clipboard_map|. 324 // Mutex that controls access to |g_clipboard_map|.
343 static base::LazyInstance<base::Lock>::Leaky clipboard_map_lock_; 325 static base::LazyInstance<base::Lock>::Leaky clipboard_map_lock_;
344 326
345 DISALLOW_COPY_AND_ASSIGN(Clipboard); 327 DISALLOW_COPY_AND_ASSIGN(Clipboard);
346 }; 328 };
347 329
348 } // namespace ui 330 } // namespace ui
349 331
350 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_ 332 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_
OLDNEW
« no previous file with comments | « ui/base/BUILD.gn ('k') | ui/base/clipboard/clipboard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698