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

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

Issue 9419036: Change all platforms except Windows to access the clipboard solely from the UI thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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
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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/process.h" 14 #include "base/process.h"
15 #include "base/shared_memory.h" 15 #include "base/shared_memory.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "base/threading/thread_checker.h"
17 #include "ui/base/ui_export.h" 18 #include "ui/base/ui_export.h"
18 19
19 #if defined(TOOLKIT_USES_GTK) 20 #if defined(TOOLKIT_USES_GTK)
20 #include <gdk/gdk.h> 21 #include <gdk/gdk.h>
21 #endif 22 #endif
22 23
23 namespace gfx { 24 namespace gfx {
24 class Size; 25 class Size;
25 } 26 }
26 27
27 class FilePath; 28 class FilePath;
28 class SkBitmap; 29 class SkBitmap;
29 30
30 #if defined(TOOLKIT_USES_GTK) 31 #if defined(TOOLKIT_USES_GTK)
31 typedef struct _GtkClipboard GtkClipboard; 32 typedef struct _GtkClipboard GtkClipboard;
32 #endif 33 #endif
33 34
34 #ifdef __OBJC__ 35 #ifdef __OBJC__
35 @class NSString; 36 @class NSString;
36 #else 37 #else
37 class NSString; 38 class NSString;
38 #endif 39 #endif
39 40
40 namespace ui { 41 namespace ui {
41 42
42 class UI_EXPORT Clipboard { 43 class UI_EXPORT Clipboard : public base::ThreadChecker {
43 public: 44 public:
44 // Platform neutral holder for native data representation of a clipboard type. 45 // Platform neutral holder for native data representation of a clipboard type.
45 struct UI_EXPORT FormatType { 46 struct UI_EXPORT FormatType {
46 FormatType(); 47 FormatType();
47 ~FormatType(); 48 ~FormatType();
48 49
49 std::string Serialize() const; 50 std::string Serialize() const;
50 static FormatType Deserialize(const std::string& serialization); 51 static FormatType Deserialize(const std::string& serialization);
51 52
52 private: 53 private:
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void ReadCustomData(Buffer buffer, 202 void ReadCustomData(Buffer buffer,
202 const string16& type, 203 const string16& type,
203 string16* result) const; 204 string16* result) const;
204 205
205 // Reads a bookmark from the clipboard, if available. 206 // Reads a bookmark from the clipboard, if available.
206 void ReadBookmark(string16* title, std::string* url) const; 207 void ReadBookmark(string16* title, std::string* url) const;
207 208
208 // Reads a file or group of files from the clipboard, if available, into the 209 // Reads a file or group of files from the clipboard, if available, into the
209 // out parameter. 210 // out parameter.
210 void ReadFile(FilePath* file) const; 211 void ReadFile(FilePath* file) const;
211 void ReadFiles(std::vector<FilePath>* files) const;
212 212
213 // Reads raw data from the clipboard with the given format type. Stores result 213 // Reads raw data from the clipboard with the given format type. Stores result
214 // as a byte vector. 214 // as a byte vector.
215 void ReadData(const FormatType& format, std::string* result) const; 215 void ReadData(const FormatType& format, std::string* result) const;
216 216
217 // Gets the FormatType corresponding to an arbitrary format string, 217 // Gets the FormatType corresponding to an arbitrary format string,
218 // registering it with the system if needed. Due to Windows/Linux 218 // registering it with the system if needed. Due to Windows/Linux
219 // limitiations, |format_string| must never be controlled by the user. 219 // limitiations, |format_string| must never be controlled by the user.
220 static FormatType GetFormatType(const std::string& format_string); 220 static FormatType GetFormatType(const std::string& format_string);
221 221
(...skipping 24 matching lines...) Expand all
246 static const FormatType& GetTextHtmlFormatType(); 246 static const FormatType& GetTextHtmlFormatType();
247 static const FormatType& GetCFHDropFormatType(); 247 static const FormatType& GetCFHDropFormatType();
248 static const FormatType& GetFileDescriptorFormatType(); 248 static const FormatType& GetFileDescriptorFormatType();
249 static const FormatType& GetFileContentFormatZeroType(); 249 static const FormatType& GetFileContentFormatZeroType();
250 #endif 250 #endif
251 251
252 private: 252 private:
253 FRIEND_TEST_ALL_PREFIXES(ClipboardTest, SharedBitmapTest); 253 FRIEND_TEST_ALL_PREFIXES(ClipboardTest, SharedBitmapTest);
254 FRIEND_TEST_ALL_PREFIXES(ClipboardTest, EmptyHTMLTest); 254 FRIEND_TEST_ALL_PREFIXES(ClipboardTest, EmptyHTMLTest);
255 255
256 void ReadFiles(std::vector<FilePath>* files) const;
257
256 void DispatchObject(ObjectType type, const ObjectMapParams& params); 258 void DispatchObject(ObjectType type, const ObjectMapParams& params);
257 259
258 void WriteText(const char* text_data, size_t text_len); 260 void WriteText(const char* text_data, size_t text_len);
259 261
260 void WriteHTML(const char* markup_data, 262 void WriteHTML(const char* markup_data,
261 size_t markup_len, 263 size_t markup_len,
262 const char* url_data, 264 const char* url_data,
263 size_t url_len); 265 size_t url_len);
264 266
265 void WriteBookmark(const char* title_data, 267 void WriteBookmark(const char* title_data,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 static const char kMimeTypeText[]; 329 static const char kMimeTypeText[];
328 static const char kMimeTypeHTML[]; 330 static const char kMimeTypeHTML[];
329 static const char kMimeTypePNG[]; 331 static const char kMimeTypePNG[];
330 332
331 DISALLOW_COPY_AND_ASSIGN(Clipboard); 333 DISALLOW_COPY_AND_ASSIGN(Clipboard);
332 }; 334 };
333 335
334 } // namespace ui 336 } // namespace ui
335 337
336 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_ 338 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698