Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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; | |
|
dcheng
2012/02/17 19:43:22
Why was this line moved?
raymes
2012/02/17 23:14:03
AFAICT this function is only used internally in th
raymes
2012/02/21 18:00:43
I removed this change as not to conflict with your
| |
| 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 Loading... | |
| 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_ |
| OLD | NEW |