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
3 // found in the LICENSE file.
5 // Multiply-included message file, so no include guard.
11 #include "base/memory/shared_memory.h"
12 #include "base/strings/string16.h"
13 #include "content/common/clipboard_format.h"
14 #include "content/public/common/common_param_traits.h"
15 #include "ipc/ipc_message_macros.h"
16 #include "ui/base/clipboard/clipboard.h"
18 // Singly-included section for types and/or struct declarations.
19 #ifndef CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
20 #define CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
22 // Custom data consists of arbitrary MIME types an untrusted sender wants to
23 // write to the clipboard. Note that exposing a general interface to do this is
24 // dangerous--an untrusted sender could cause a DoS or code execution.
25 typedef std::map
<base::string16
, base::string16
> CustomDataMap
;
27 #endif // CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
29 #undef IPC_MESSAGE_EXPORT
30 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
32 #define IPC_MESSAGE_START ClipboardMsgStart
34 IPC_ENUM_TRAITS_MAX_VALUE(content::ClipboardFormat
,
35 content::CLIPBOARD_FORMAT_LAST
)
36 IPC_ENUM_TRAITS_MAX_VALUE(ui::ClipboardType
, ui::CLIPBOARD_TYPE_LAST
)
38 // Clipboard IPC messages sent from the renderer to the browser.
40 IPC_SYNC_MESSAGE_CONTROL1_1(ClipboardHostMsg_GetSequenceNumber
,
41 ui::ClipboardType
/* type */,
43 IPC_SYNC_MESSAGE_CONTROL2_1(ClipboardHostMsg_IsFormatAvailable
,
44 content::ClipboardFormat
/* format */,
45 ui::ClipboardType
/* type */,
47 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_Clear
,
48 ui::ClipboardType
/* type */)
49 IPC_SYNC_MESSAGE_CONTROL1_2(ClipboardHostMsg_ReadAvailableTypes
,
50 ui::ClipboardType
/* type */,
51 std::vector
<base::string16
> /* types */,
52 bool /* contains filenames */)
53 IPC_SYNC_MESSAGE_CONTROL1_1(ClipboardHostMsg_ReadText
,
54 ui::ClipboardType
/* type */,
55 base::string16
/* result */)
56 IPC_SYNC_MESSAGE_CONTROL1_4(ClipboardHostMsg_ReadHTML
,
57 ui::ClipboardType
/* type */,
58 base::string16
/* markup */,
60 uint32
/* fragment start */,
61 uint32
/* fragment end */)
62 IPC_SYNC_MESSAGE_CONTROL1_1(ClipboardHostMsg_ReadRTF
,
63 ui::ClipboardType
/* type */,
64 std::string
/* result */)
65 IPC_SYNC_MESSAGE_CONTROL1_2(ClipboardHostMsg_ReadImage
,
66 ui::ClipboardType
/* type */,
67 base::SharedMemoryHandle
/* PNG-encoded image */,
68 uint32
/* image size */)
69 IPC_SYNC_MESSAGE_CONTROL2_1(ClipboardHostMsg_ReadCustomData
,
70 ui::ClipboardType
/* type */,
71 base::string16
/* type */,
72 base::string16
/* result */)
74 // Writing to the clipboard via IPC is a two-phase operation. First, the sender
75 // sends the different types of data it'd like to write to the receiver. Then,
76 // it sends a commit message to commit the data to the system clipboard.
77 IPC_MESSAGE_CONTROL2(ClipboardHostMsg_WriteText
,
78 ui::ClipboardType
/* type */,
79 base::string16
/* text */)
80 IPC_MESSAGE_CONTROL3(ClipboardHostMsg_WriteHTML
,
81 ui::ClipboardType
/* type */,
82 base::string16
/* markup */,
84 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_WriteSmartPasteMarker
,
85 ui::ClipboardType
/* type */)
86 IPC_MESSAGE_CONTROL2(ClipboardHostMsg_WriteCustomData
,
87 ui::ClipboardType
/* type */,
88 CustomDataMap
/* custom data */)
89 // TODO(dcheng): The |url| parameter should really be a GURL, but <canvas>'s
90 // copy as image tries to set very long data: URLs on the clipboard. Using
91 // GURL causes the browser to kill the renderer for sending a bad IPC (GURLs
92 // bigger than 2 megabytes are considered to be bad). https://crbug.com/459822
93 IPC_MESSAGE_CONTROL3(ClipboardHostMsg_WriteBookmark
,
94 ui::ClipboardType
/* type */,
95 std::string
/* url */,
96 base::string16
/* title */)
97 IPC_SYNC_MESSAGE_CONTROL3_0(ClipboardHostMsg_WriteImage
,
98 ui::ClipboardType
/* type */,
100 base::SharedMemoryHandle
/* bitmap handle */)
101 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_CommitWrite
, ui::ClipboardType
/* type */)
103 #if defined(OS_MACOSX)
104 IPC_MESSAGE_CONTROL1(ClipboardHostMsg_FindPboardWriteStringAsync
,
105 base::string16
/* text */)