OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #include "chrome/browser/renderer_host/resource_message_filter.h" | 5 #include "chrome/browser/renderer_host/resource_message_filter.h" |
6 | 6 |
7 #include "base/clipboard.h" | 7 #include "base/clipboard.h" |
8 #include "base/gfx/gtk_native_view_id_manager.h" | 8 #include "base/gfx/gtk_native_view_id_manager.h" |
9 #include "chrome/browser/chrome_thread.h" | 9 #include "chrome/browser/chrome_thread.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 ViewHostMsg_GetRootWindowRect::WriteReplyParams(reply_msg, rect); | 96 ViewHostMsg_GetRootWindowRect::WriteReplyParams(reply_msg, rect); |
97 | 97 |
98 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask( | 98 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask( |
99 FROM_HERE, NewRunnableMethod( | 99 FROM_HERE, NewRunnableMethod( |
100 this, &ResourceMessageFilter::SendDelayedReply, reply_msg)); | 100 this, &ResourceMessageFilter::SendDelayedReply, reply_msg)); |
101 } | 101 } |
102 | 102 |
103 // Called on the UI thread. | 103 // Called on the UI thread. |
104 void ResourceMessageFilter::DoOnClipboardIsFormatAvailable( | 104 void ResourceMessageFilter::DoOnClipboardIsFormatAvailable( |
105 Clipboard::FormatType format, IPC::Message* reply_msg) { | 105 Clipboard::FormatType format, Clipboard::Buffer buffer, |
106 const bool result = GetClipboard()->IsFormatAvailable(format); | 106 IPC::Message* reply_msg) { |
| 107 const bool result = GetClipboard()->IsFormatAvailable(format, buffer); |
107 | 108 |
108 ViewHostMsg_ClipboardIsFormatAvailable::WriteReplyParams(reply_msg, result); | 109 ViewHostMsg_ClipboardIsFormatAvailable::WriteReplyParams(reply_msg, result); |
109 | 110 |
110 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask( | 111 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask( |
111 FROM_HERE, NewRunnableMethod( | 112 FROM_HERE, NewRunnableMethod( |
112 this, &ResourceMessageFilter::SendDelayedReply, reply_msg)); | 113 this, &ResourceMessageFilter::SendDelayedReply, reply_msg)); |
113 } | 114 } |
114 | 115 |
115 // Called on the UI thread. | 116 // Called on the UI thread. |
116 void ResourceMessageFilter::DoOnClipboardReadText(IPC::Message* reply_msg) { | 117 void ResourceMessageFilter::DoOnClipboardReadText(Clipboard::Buffer buffer, |
| 118 IPC::Message* reply_msg) { |
117 string16 result; | 119 string16 result; |
118 GetClipboard()->ReadText(&result); | 120 GetClipboard()->ReadText(buffer, &result); |
119 | 121 |
120 ViewHostMsg_ClipboardReadText::WriteReplyParams(reply_msg, result); | 122 ViewHostMsg_ClipboardReadText::WriteReplyParams(reply_msg, result); |
121 | 123 |
122 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask( | 124 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask( |
123 FROM_HERE, NewRunnableMethod( | 125 FROM_HERE, NewRunnableMethod( |
124 this, &ResourceMessageFilter::SendDelayedReply, reply_msg)); | 126 this, &ResourceMessageFilter::SendDelayedReply, reply_msg)); |
125 } | 127 } |
126 | 128 |
127 // Called on the UI thread. | 129 // Called on the UI thread. |
128 void ResourceMessageFilter::DoOnClipboardReadAsciiText( | 130 void ResourceMessageFilter::DoOnClipboardReadAsciiText( |
129 IPC::Message* reply_msg) { | 131 Clipboard::Buffer buffer, IPC::Message* reply_msg) { |
130 std::string result; | 132 std::string result; |
131 GetClipboard()->ReadAsciiText(&result); | 133 GetClipboard()->ReadAsciiText(buffer, &result); |
132 | 134 |
133 ViewHostMsg_ClipboardReadAsciiText::WriteReplyParams(reply_msg, result); | 135 ViewHostMsg_ClipboardReadAsciiText::WriteReplyParams(reply_msg, result); |
134 | 136 |
135 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask( | 137 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask( |
136 FROM_HERE, NewRunnableMethod( | 138 FROM_HERE, NewRunnableMethod( |
137 this, &ResourceMessageFilter::SendDelayedReply, reply_msg)); | 139 this, &ResourceMessageFilter::SendDelayedReply, reply_msg)); |
138 } | 140 } |
139 | 141 |
140 // Called on the UI thread. | 142 // Called on the UI thread. |
141 void ResourceMessageFilter::DoOnClipboardReadHTML(IPC::Message* reply_msg) { | 143 void ResourceMessageFilter::DoOnClipboardReadHTML(Clipboard::Buffer buffer, |
| 144 IPC::Message* reply_msg) { |
142 std::string src_url_str; | 145 std::string src_url_str; |
143 string16 markup; | 146 string16 markup; |
144 GetClipboard()->ReadHTML(&markup, &src_url_str); | 147 GetClipboard()->ReadHTML(buffer, &markup, &src_url_str); |
145 const GURL src_url = GURL(src_url_str); | 148 const GURL src_url = GURL(src_url_str); |
146 | 149 |
147 ViewHostMsg_ClipboardReadHTML::WriteReplyParams(reply_msg, markup, src_url); | 150 ViewHostMsg_ClipboardReadHTML::WriteReplyParams(reply_msg, markup, src_url); |
148 | 151 |
149 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask( | 152 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask( |
150 FROM_HERE, NewRunnableMethod( | 153 FROM_HERE, NewRunnableMethod( |
151 this, &ResourceMessageFilter::SendDelayedReply, reply_msg)); | 154 this, &ResourceMessageFilter::SendDelayedReply, reply_msg)); |
152 } | 155 } |
153 | 156 |
154 // Called on the IO thread. | 157 // Called on the IO thread. |
(...skipping 15 matching lines...) Expand all Loading... |
170 // Called on the IO thread. | 173 // Called on the IO thread. |
171 void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId view, | 174 void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId view, |
172 IPC::Message* reply_msg) { | 175 IPC::Message* reply_msg) { |
173 ChromeThread::GetMessageLoop(ChromeThread::BACKGROUND_X11)->PostTask( | 176 ChromeThread::GetMessageLoop(ChromeThread::BACKGROUND_X11)->PostTask( |
174 FROM_HERE, NewRunnableMethod( | 177 FROM_HERE, NewRunnableMethod( |
175 this, &ResourceMessageFilter::DoOnGetRootWindowRect, view, reply_msg)); | 178 this, &ResourceMessageFilter::DoOnGetRootWindowRect, view, reply_msg)); |
176 } | 179 } |
177 | 180 |
178 // Called on the IO thread. | 181 // Called on the IO thread. |
179 void ResourceMessageFilter::OnClipboardIsFormatAvailable( | 182 void ResourceMessageFilter::OnClipboardIsFormatAvailable( |
180 Clipboard::FormatType format, IPC::Message* reply_msg) { | 183 Clipboard::FormatType format, Clipboard::Buffer buffer, |
| 184 IPC::Message* reply_msg) { |
181 ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 185 ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
182 this, &ResourceMessageFilter::DoOnClipboardIsFormatAvailable, format, | 186 this, &ResourceMessageFilter::DoOnClipboardIsFormatAvailable, format, |
| 187 buffer, reply_msg)); |
| 188 } |
| 189 |
| 190 // Called on the IO thread. |
| 191 void ResourceMessageFilter::OnClipboardReadText(Clipboard::Buffer buffer, |
| 192 IPC::Message* reply_msg) { |
| 193 ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 194 this, &ResourceMessageFilter::DoOnClipboardReadText, buffer, |
183 reply_msg)); | 195 reply_msg)); |
184 } | 196 } |
185 | 197 |
186 // Called on the IO thread. | 198 // Called on the IO thread. |
187 void ResourceMessageFilter::OnClipboardReadText(IPC::Message* reply_msg) { | 199 void ResourceMessageFilter::OnClipboardReadAsciiText(Clipboard::Buffer buffer, |
| 200 IPC::Message* reply_msg) { |
188 ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 201 ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
189 this, &ResourceMessageFilter::DoOnClipboardReadText, reply_msg)); | 202 this, &ResourceMessageFilter::DoOnClipboardReadAsciiText, buffer, |
| 203 reply_msg)); |
190 } | 204 } |
191 | 205 |
192 // Called on the IO thread. | 206 // Called on the IO thread. |
193 void ResourceMessageFilter::OnClipboardReadAsciiText(IPC::Message* reply_msg) { | 207 void ResourceMessageFilter::OnClipboardReadHTML(Clipboard::Buffer buffer, |
| 208 IPC::Message* reply_msg) { |
194 ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 209 ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
195 this, &ResourceMessageFilter::DoOnClipboardReadAsciiText, reply_msg)); | 210 this, &ResourceMessageFilter::DoOnClipboardReadHTML, buffer, |
| 211 reply_msg)); |
196 } | 212 } |
197 | |
198 // Called on the IO thread. | |
199 void ResourceMessageFilter::OnClipboardReadHTML(IPC::Message* reply_msg) { | |
200 ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( | |
201 this, &ResourceMessageFilter::DoOnClipboardReadHTML, reply_msg)); | |
202 } | |
OLD | NEW |