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

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

Issue 199763002: Verify FormatType in ScopedClipboardWriter::WritePickledData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Linux GTK Created 6 years, 9 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 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // Platform neutral holder for native data representation of a clipboard type. 77 // Platform neutral holder for native data representation of a clipboard type.
78 struct UI_BASE_EXPORT FormatType { 78 struct UI_BASE_EXPORT FormatType {
79 FormatType(); 79 FormatType();
80 ~FormatType(); 80 ~FormatType();
81 81
82 // Serializes and deserializes a FormatType for use in IPC messages. 82 // Serializes and deserializes a FormatType for use in IPC messages.
83 std::string Serialize() const; 83 std::string Serialize() const;
84 static FormatType Deserialize(const std::string& serialization); 84 static FormatType Deserialize(const std::string& serialization);
85 85
86 #if defined(OS_WIN) || defined(USE_AURA)
87 // FormatType can be used in a set on some platforms.
88 bool operator<(const FormatType& other) const; 86 bool operator<(const FormatType& other) const;
89 #endif
90 87
91 #if defined(OS_WIN) 88 #if defined(OS_WIN)
92 const FORMATETC& ToFormatEtc() const { return data_; } 89 const FORMATETC& ToFormatEtc() const { return data_; }
93 #elif defined(USE_AURA) 90 #elif defined(USE_AURA)
94 const std::string& ToString() const { return data_; } 91 const std::string& ToString() const { return data_; }
95 #elif defined(OS_MACOSX) 92 #elif defined(OS_MACOSX)
96 // Custom copy and assignment constructor to handle NSString. 93 // Custom copy and assignment constructor to handle NSString.
97 FormatType(const FormatType& other); 94 FormatType(const FormatType& other);
98 FormatType& operator=(const FormatType& other); 95 FormatType& operator=(const FormatType& other);
99 #endif 96 #endif
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 263
267 // Reads raw data from the clipboard with the given format type. Stores result 264 // Reads raw data from the clipboard with the given format type. Stores result
268 // as a byte vector. 265 // as a byte vector.
269 void ReadData(const FormatType& format, std::string* result) const; 266 void ReadData(const FormatType& format, std::string* result) const;
270 267
271 // Gets the FormatType corresponding to an arbitrary format string, 268 // Gets the FormatType corresponding to an arbitrary format string,
272 // registering it with the system if needed. Due to Windows/Linux 269 // registering it with the system if needed. Due to Windows/Linux
273 // limitiations, |format_string| must never be controlled by the user. 270 // limitiations, |format_string| must never be controlled by the user.
274 static FormatType GetFormatType(const std::string& format_string); 271 static FormatType GetFormatType(const std::string& format_string);
275 272
273 // Returns true if the |format| was registered with GetFormatType().
274 static bool IsRegisteredFormatType(const FormatType& format);
275
276 // Get format identifiers for various types. 276 // Get format identifiers for various types.
277 static const FormatType& GetUrlFormatType(); 277 static const FormatType& GetUrlFormatType();
278 static const FormatType& GetUrlWFormatType(); 278 static const FormatType& GetUrlWFormatType();
279 static const FormatType& GetMozUrlFormatType(); 279 static const FormatType& GetMozUrlFormatType();
280 static const FormatType& GetPlainTextFormatType(); 280 static const FormatType& GetPlainTextFormatType();
281 static const FormatType& GetPlainTextWFormatType(); 281 static const FormatType& GetPlainTextWFormatType();
282 static const FormatType& GetFilenameFormatType(); 282 static const FormatType& GetFilenameFormatType();
283 static const FormatType& GetFilenameWFormatType(); 283 static const FormatType& GetFilenameWFormatType();
284 static const FormatType& GetWebKitSmartPasteFormatType(); 284 static const FormatType& GetWebKitSmartPasteFormatType();
285 // Win: MS HTML Format, Other: Generic HTML format 285 // Win: MS HTML Format, Other: Generic HTML format
(...skipping 24 matching lines...) Expand all
310 #endif 310 #endif
311 311
312 private: 312 private:
313 FRIEND_TEST_ALL_PREFIXES(ClipboardTest, SharedBitmapTest); 313 FRIEND_TEST_ALL_PREFIXES(ClipboardTest, SharedBitmapTest);
314 FRIEND_TEST_ALL_PREFIXES(ClipboardTest, EmptyHTMLTest); 314 FRIEND_TEST_ALL_PREFIXES(ClipboardTest, EmptyHTMLTest);
315 friend class ClipboardTest; 315 friend class ClipboardTest;
316 316
317 Clipboard(); 317 Clipboard();
318 ~Clipboard(); 318 ~Clipboard();
319 319
320 static FormatType GetFormatTypeInternal(const std::string& format_string);
321
320 void DispatchObject(ObjectType type, const ObjectMapParams& params); 322 void DispatchObject(ObjectType type, const ObjectMapParams& params);
321 323
322 void WriteText(const char* text_data, size_t text_len); 324 void WriteText(const char* text_data, size_t text_len);
323 325
324 void WriteHTML(const char* markup_data, 326 void WriteHTML(const char* markup_data,
325 size_t markup_len, 327 size_t markup_len,
326 const char* url_data, 328 const char* url_data,
327 size_t url_len); 329 size_t url_len);
328 330
329 void WriteRTF(const char* rtf_data, size_t data_len); 331 void WriteRTF(const char* rtf_data, size_t data_len);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 class AuraX11Details; 394 class AuraX11Details;
393 scoped_ptr<AuraX11Details> aurax11_details_; 395 scoped_ptr<AuraX11Details> aurax11_details_;
394 #endif 396 #endif
395 397
396 DISALLOW_COPY_AND_ASSIGN(Clipboard); 398 DISALLOW_COPY_AND_ASSIGN(Clipboard);
397 }; 399 };
398 400
399 } // namespace ui 401 } // namespace ui
400 402
401 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_ 403 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc ('k') | ui/base/clipboard/clipboard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698