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

Unified Diff: ui/base/clipboard/clipboard.h

Issue 574273002: Rewrite clipboard write IPC handling to be easier to understand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Document Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/webclipboard_impl.cc ('k') | ui/base/clipboard/clipboard.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/clipboard/clipboard.h
diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h
index ab3d34b3ceff6d8b7939b451e0026b597343f6f3..6c23a6da0616b8b7dcf79726741b944ec0cb819e 100644
--- a/ui/base/clipboard/clipboard.h
+++ b/ui/base/clipboard/clipboard.h
@@ -32,11 +32,6 @@ class MessageWindow;
} // namespace win
} // namespace base
-// TODO(dcheng): Temporary until the IPC layer doesn't use WriteObjects().
-namespace content {
-class ClipboardMessageFilter;
-}
-
namespace gfx {
class Size;
}
@@ -118,48 +113,6 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
// Copyable and assignable, since this is essentially an opaque value type.
};
- // TODO(dcheng): Make this private once the IPC layer no longer needs to
- // serialize this information.
- // ObjectType designates the type of data to be stored in the clipboard. This
- // designation is shared across all OSes. The system-specific designation
- // is defined by FormatType. A single ObjectType might be represented by
- // several system-specific FormatTypes. For example, on Linux the CBF_TEXT
- // ObjectType maps to "text/plain", "STRING", and several other formats. On
- // windows it maps to CF_UNICODETEXT.
- enum ObjectType {
- CBF_TEXT,
- CBF_HTML,
- CBF_RTF,
- CBF_BOOKMARK,
- CBF_WEBKIT,
- CBF_SMBITMAP, // Bitmap from shared memory.
- CBF_DATA, // Arbitrary block of bytes.
- };
-
- // ObjectMap is a map from ObjectType to associated data.
- // The data is organized differently for each ObjectType. The following
- // table summarizes what kind of data is stored for each key.
- // * indicates an optional argument.
- //
- // Key Arguments Type
- // -------------------------------------
- // CBF_TEXT text char array
- // CBF_HTML html char array
- // url* char array
- // CBF_RTF data byte array
- // CBF_BOOKMARK html char array
- // url char array
- // CBF_WEBKIT none empty vector
- // CBF_SMBITMAP shared_mem A pointer to an unmapped base::SharedMemory
- // object containing the bitmap data. The bitmap
- // data should be premultiplied.
- // size gfx::Size struct
- // CBF_DATA format char array
- // data byte array
- typedef std::vector<char> ObjectMapParam;
- typedef std::vector<ObjectMapParam> ObjectMapParams;
- typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap;
-
static bool IsSupportedClipboardType(int32 type) {
switch (type) {
case CLIPBOARD_TYPE_COPY_PASTE:
@@ -267,15 +220,6 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
static const FormatType& GetWebCustomDataFormatType();
static const FormatType& GetPepperCustomDataFormatType();
- // Embeds a pointer to a SharedMemory object pointed to by |bitmap_handle|
- // belonging to |process| into a shared bitmap [CBF_SMBITMAP] slot in
- // |objects|. The pointer is deleted by DispatchObjects().
- //
- // On non-Windows platforms, |process| is ignored.
- static bool ReplaceSharedMemHandle(ObjectMap* objects,
- base::SharedMemoryHandle bitmap_handle,
- base::ProcessHandle process)
- WARN_UNUSED_RESULT;
#if defined(OS_WIN)
// Firefox text/html
static const FormatType& GetTextHtmlFormatType();
@@ -291,6 +235,45 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
Clipboard() {}
virtual ~Clipboard() {}
+ // ObjectType designates the type of data to be stored in the clipboard. This
+ // designation is shared across all OSes. The system-specific designation
+ // is defined by FormatType. A single ObjectType might be represented by
+ // several system-specific FormatTypes. For example, on Linux the CBF_TEXT
+ // ObjectType maps to "text/plain", "STRING", and several other formats. On
+ // windows it maps to CF_UNICODETEXT.
+ enum ObjectType {
+ CBF_TEXT,
+ CBF_HTML,
+ CBF_RTF,
+ CBF_BOOKMARK,
+ CBF_WEBKIT,
+ CBF_SMBITMAP, // Bitmap from shared memory.
+ CBF_DATA, // Arbitrary block of bytes.
+ };
+
+ // ObjectMap is a map from ObjectType to associated data.
+ // The data is organized differently for each ObjectType. The following
+ // table summarizes what kind of data is stored for each key.
+ // * indicates an optional argument.
+ //
+ // Key Arguments Type
+ // -------------------------------------
+ // CBF_TEXT text char array
+ // CBF_HTML html char array
+ // url* char array
+ // CBF_RTF data byte array
+ // CBF_BOOKMARK html char array
+ // url char array
+ // CBF_WEBKIT none empty vector
+ // CBF_SMBITMAP bitmap A pointer to a SkBitmap. The caller must ensure
+ // the SkBitmap remains live for the duration of
+ // the WriteObjects call.
+ // CBF_DATA format char array
+ // data byte array
+ typedef std::vector<char> ObjectMapParam;
+ typedef std::vector<ObjectMapParam> ObjectMapParams;
+ typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap;
+
// Write a bunch of objects to the system clipboard. Copies are made of the
// contents of |objects|.
virtual void WriteObjects(ClipboardType type, const ObjectMap& objects) = 0;
@@ -320,11 +303,7 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
size_t data_len) = 0;
private:
- template <typename T>
- friend class ClipboardTest;
// For access to WriteObjects().
- // TODO(dcheng): Remove the temporary exception for content.
- friend class content::ClipboardMessageFilter;
friend class ScopedClipboardWriter;
friend class TestClipboard;
« no previous file with comments | « content/renderer/webclipboard_impl.cc ('k') | ui/base/clipboard/clipboard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698