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

Side by Side Diff: content/common/clipboard_messages.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 unified diff | Download patch
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 // Multiply-included message file, so no include guard. 5 // Multiply-included message file, so no include guard.
6 6
7 #include <map>
7 #include <string> 8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/memory/shared_memory.h" 11 #include "base/memory/shared_memory.h"
12 #include "base/strings/string16.h"
11 #include "content/common/clipboard_format.h" 13 #include "content/common/clipboard_format.h"
12 #include "content/public/common/common_param_traits.h" 14 #include "content/public/common/common_param_traits.h"
13 #include "ipc/ipc_message_macros.h" 15 #include "ipc/ipc_message_macros.h"
14 #include "ui/base/clipboard/clipboard.h" 16 #include "ui/base/clipboard/clipboard.h"
15 17
16 #define IPC_MESSAGE_START ClipboardMsgStart 18 #define IPC_MESSAGE_START ClipboardMsgStart
17 19
18 IPC_ENUM_TRAITS_MAX_VALUE(content::ClipboardFormat, 20 IPC_ENUM_TRAITS_MAX_VALUE(content::ClipboardFormat,
19 content::CLIPBOARD_FORMAT_LAST) 21 content::CLIPBOARD_FORMAT_LAST)
20 IPC_ENUM_TRAITS_MAX_VALUE(ui::ClipboardType, ui::CLIPBOARD_TYPE_LAST) 22 IPC_ENUM_TRAITS_MAX_VALUE(ui::ClipboardType, ui::CLIPBOARD_TYPE_LAST)
21 23
22 // Clipboard IPC messages sent from the renderer to the browser. 24 // Clipboard IPC messages sent from the renderer to the browser.
23 25
24 // This message is used when the object list does not contain a bitmap.
25 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_WriteObjectsAsync,
26 ui::Clipboard::ObjectMap /* objects */)
27 // This message is used when the object list contains a bitmap.
28 // It is synchronized so that the renderer knows when it is safe to
29 // free the shared memory used to transfer the bitmap.
30 IPC_SYNC_MESSAGE_CONTROL2_0(ClipboardHostMsg_WriteObjectsSync,
31 ui::Clipboard::ObjectMap /* objects */,
32 base::SharedMemoryHandle /* bitmap handle */)
33 IPC_SYNC_MESSAGE_CONTROL1_1(ClipboardHostMsg_GetSequenceNumber, 26 IPC_SYNC_MESSAGE_CONTROL1_1(ClipboardHostMsg_GetSequenceNumber,
34 ui::ClipboardType /* type */, 27 ui::ClipboardType /* type */,
35 uint64 /* result */) 28 uint64 /* result */)
36 IPC_SYNC_MESSAGE_CONTROL2_1(ClipboardHostMsg_IsFormatAvailable, 29 IPC_SYNC_MESSAGE_CONTROL2_1(ClipboardHostMsg_IsFormatAvailable,
37 content::ClipboardFormat /* format */, 30 content::ClipboardFormat /* format */,
38 ui::ClipboardType /* type */, 31 ui::ClipboardType /* type */,
39 bool /* result */) 32 bool /* result */)
40 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_Clear, 33 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_Clear,
41 ui::ClipboardType /* type */) 34 ui::ClipboardType /* type */)
42 IPC_SYNC_MESSAGE_CONTROL1_2(ClipboardHostMsg_ReadAvailableTypes, 35 IPC_SYNC_MESSAGE_CONTROL1_2(ClipboardHostMsg_ReadAvailableTypes,
(...skipping 14 matching lines...) Expand all
57 std::string /* result */) 50 std::string /* result */)
58 IPC_SYNC_MESSAGE_CONTROL1_2(ClipboardHostMsg_ReadImage, 51 IPC_SYNC_MESSAGE_CONTROL1_2(ClipboardHostMsg_ReadImage,
59 ui::ClipboardType /* type */, 52 ui::ClipboardType /* type */,
60 base::SharedMemoryHandle /* PNG-encoded image */, 53 base::SharedMemoryHandle /* PNG-encoded image */,
61 uint32 /* image size */) 54 uint32 /* image size */)
62 IPC_SYNC_MESSAGE_CONTROL2_1(ClipboardHostMsg_ReadCustomData, 55 IPC_SYNC_MESSAGE_CONTROL2_1(ClipboardHostMsg_ReadCustomData,
63 ui::ClipboardType /* type */, 56 ui::ClipboardType /* type */,
64 base::string16 /* type */, 57 base::string16 /* type */,
65 base::string16 /* result */) 58 base::string16 /* result */)
66 59
60 // Writing to the clipboard via IPC is a two-phase operation. First, the sender
61 // sends the different types of data it'd like to write to the receiver. Then,
62 // it sends a commit message to commit the data to the system clipboard.
63 IPC_MESSAGE_CONTROL2(ClipboardHostMsg_WriteText,
64 ui::ClipboardType /* type */,
65 base::string16 /* text */)
66 IPC_MESSAGE_CONTROL3(ClipboardHostMsg_WriteHTML,
67 ui::ClipboardType /* type */,
68 base::string16 /* markup */,
69 GURL /* url */)
70 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_WriteSmartPasteMarker,
71 ui::ClipboardType /* type */);
72 // Custom data consists of arbitrary MIME types an untrusted sender wants to
73 // write to the clipboard. Note that exposing a general interface to do this is
74 // dangerous--an untrusted sender could cause a DoS or code execution.
75 typedef std::map<base::string16, base::string16> CustomDataMap;
76 IPC_MESSAGE_CONTROL2(ClipboardHostMsg_WriteCustomData,
77 ui::ClipboardType /* type */,
78 CustomDataMap /* custom data */)
79 IPC_MESSAGE_CONTROL3(ClipboardHostMsg_WriteBookmark,
80 ui::ClipboardType /* type */,
81 GURL /* url */,
82 base::string16 /* title */)
83 IPC_SYNC_MESSAGE_CONTROL3_0(ClipboardHostMsg_WriteImage,
84 ui::ClipboardType /* type */,
85 gfx::Size /* size */,
86 base::SharedMemoryHandle /* bitmap handle */)
87 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_CommitWrite, ui::ClipboardType /* type */)
88
67 #if defined(OS_MACOSX) 89 #if defined(OS_MACOSX)
68 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_FindPboardWriteStringAsync, 90 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_FindPboardWriteStringAsync,
69 base::string16 /* text */) 91 base::string16 /* text */)
70 #endif 92 #endif
OLDNEW
« no previous file with comments | « content/browser/renderer_host/clipboard_message_filter_unittest.cc ('k') | content/content_renderer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698