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 #include "content/plugin/webplugin_delegate_stub.h" | 5 #include "content/plugin/webplugin_delegate_stub.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 AddRef(); | 92 AddRef(); |
93 | 93 |
94 bool handled = true; | 94 bool handled = true; |
95 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg) | 95 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg) |
96 IPC_MESSAGE_HANDLER(PluginMsg_Init, OnInit) | 96 IPC_MESSAGE_HANDLER(PluginMsg_Init, OnInit) |
97 IPC_MESSAGE_HANDLER(PluginMsg_WillSendRequest, OnWillSendRequest) | 97 IPC_MESSAGE_HANDLER(PluginMsg_WillSendRequest, OnWillSendRequest) |
98 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveResponse, OnDidReceiveResponse) | 98 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveResponse, OnDidReceiveResponse) |
99 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveData, OnDidReceiveData) | 99 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveData, OnDidReceiveData) |
100 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishLoading, OnDidFinishLoading) | 100 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishLoading, OnDidFinishLoading) |
101 IPC_MESSAGE_HANDLER(PluginMsg_DidFail, OnDidFail) | 101 IPC_MESSAGE_HANDLER(PluginMsg_DidFail, OnDidFail) |
102 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishLoadWithReason, | |
103 OnDidFinishLoadWithReason) | |
104 IPC_MESSAGE_HANDLER(PluginMsg_SetFocus, OnSetFocus) | 102 IPC_MESSAGE_HANDLER(PluginMsg_SetFocus, OnSetFocus) |
105 IPC_MESSAGE_HANDLER(PluginMsg_HandleInputEvent, OnHandleInputEvent) | 103 IPC_MESSAGE_HANDLER(PluginMsg_HandleInputEvent, OnHandleInputEvent) |
106 IPC_MESSAGE_HANDLER(PluginMsg_Paint, OnPaint) | 104 IPC_MESSAGE_HANDLER(PluginMsg_Paint, OnPaint) |
107 IPC_MESSAGE_HANDLER(PluginMsg_DidPaint, OnDidPaint) | 105 IPC_MESSAGE_HANDLER(PluginMsg_DidPaint, OnDidPaint) |
108 IPC_MESSAGE_HANDLER(PluginMsg_GetPluginScriptableObject, | 106 IPC_MESSAGE_HANDLER(PluginMsg_GetPluginScriptableObject, |
109 OnGetPluginScriptableObject) | 107 OnGetPluginScriptableObject) |
110 IPC_MESSAGE_HANDLER(PluginMsg_GetFormValue, OnGetFormValue) | 108 IPC_MESSAGE_HANDLER(PluginMsg_GetFormValue, OnGetFormValue) |
111 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometry, OnUpdateGeometry) | 109 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometry, OnUpdateGeometry) |
112 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometrySync, OnUpdateGeometry) | 110 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometrySync, OnUpdateGeometry) |
113 IPC_MESSAGE_HANDLER(PluginMsg_SendJavaScriptStream, | |
114 OnSendJavaScriptStream) | |
115 IPC_MESSAGE_HANDLER(PluginMsg_SetContentAreaFocus, OnSetContentAreaFocus) | 111 IPC_MESSAGE_HANDLER(PluginMsg_SetContentAreaFocus, OnSetContentAreaFocus) |
116 #if defined(OS_WIN) && !defined(USE_AURA) | 112 #if defined(OS_WIN) && !defined(USE_AURA) |
117 IPC_MESSAGE_HANDLER(PluginMsg_ImeCompositionUpdated, | 113 IPC_MESSAGE_HANDLER(PluginMsg_ImeCompositionUpdated, |
118 OnImeCompositionUpdated) | 114 OnImeCompositionUpdated) |
119 IPC_MESSAGE_HANDLER(PluginMsg_ImeCompositionCompleted, | 115 IPC_MESSAGE_HANDLER(PluginMsg_ImeCompositionCompleted, |
120 OnImeCompositionCompleted) | 116 OnImeCompositionCompleted) |
121 #endif | 117 #endif |
122 #if defined(OS_MACOSX) | 118 #if defined(OS_MACOSX) |
123 IPC_MESSAGE_HANDLER(PluginMsg_SetWindowFocus, OnSetWindowFocus) | 119 IPC_MESSAGE_HANDLER(PluginMsg_SetWindowFocus, OnSetWindowFocus) |
124 IPC_MESSAGE_HANDLER(PluginMsg_ContainerHidden, OnContainerHidden) | 120 IPC_MESSAGE_HANDLER(PluginMsg_ContainerHidden, OnContainerHidden) |
125 IPC_MESSAGE_HANDLER(PluginMsg_ContainerShown, OnContainerShown) | 121 IPC_MESSAGE_HANDLER(PluginMsg_ContainerShown, OnContainerShown) |
126 IPC_MESSAGE_HANDLER(PluginMsg_WindowFrameChanged, OnWindowFrameChanged) | 122 IPC_MESSAGE_HANDLER(PluginMsg_WindowFrameChanged, OnWindowFrameChanged) |
127 IPC_MESSAGE_HANDLER(PluginMsg_ImeCompositionCompleted, | 123 IPC_MESSAGE_HANDLER(PluginMsg_ImeCompositionCompleted, |
128 OnImeCompositionCompleted) | 124 OnImeCompositionCompleted) |
129 #endif | 125 #endif |
130 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveManualResponse, | |
131 OnDidReceiveManualResponse) | |
132 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveManualData, OnDidReceiveManualData) | |
133 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishManualLoading, | |
134 OnDidFinishManualLoading) | |
135 IPC_MESSAGE_HANDLER(PluginMsg_DidManualLoadFail, OnDidManualLoadFail) | |
136 IPC_MESSAGE_HANDLER(PluginMsg_HandleURLRequestReply, | |
137 OnHandleURLRequestReply) | |
138 IPC_MESSAGE_HANDLER(PluginMsg_HTTPRangeRequestReply, | |
139 OnHTTPRangeRequestReply) | |
140 IPC_MESSAGE_HANDLER(PluginMsg_FetchURL, OnFetchURL) | |
141 IPC_MESSAGE_UNHANDLED(handled = false) | 126 IPC_MESSAGE_UNHANDLED(handled = false) |
142 IPC_END_MESSAGE_MAP() | 127 IPC_END_MESSAGE_MAP() |
143 | 128 |
144 if (!in_destructor_) | 129 if (!in_destructor_) |
145 Release(); | 130 Release(); |
146 | 131 |
147 DCHECK(handled); | 132 DCHECK(handled); |
148 return handled; | 133 return handled; |
149 } | 134 } |
150 | 135 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 225 } |
241 | 226 |
242 void WebPluginDelegateStub::OnDidFail(int id) { | 227 void WebPluginDelegateStub::OnDidFail(int id) { |
243 WebPluginResourceClient* client = webplugin_->GetResourceClient(id); | 228 WebPluginResourceClient* client = webplugin_->GetResourceClient(id); |
244 if (!client) | 229 if (!client) |
245 return; | 230 return; |
246 | 231 |
247 client->DidFail(id); | 232 client->DidFail(id); |
248 } | 233 } |
249 | 234 |
250 void WebPluginDelegateStub::OnDidFinishLoadWithReason( | |
251 const GURL& url, int reason, int notify_id) { | |
252 delegate_->DidFinishLoadWithReason(url, reason, notify_id); | |
253 } | |
254 | |
255 void WebPluginDelegateStub::OnSetFocus(bool focused) { | 235 void WebPluginDelegateStub::OnSetFocus(bool focused) { |
256 delegate_->SetFocus(focused); | 236 delegate_->SetFocus(focused); |
257 #if defined(OS_WIN) && !defined(USE_AURA) | 237 #if defined(OS_WIN) && !defined(USE_AURA) |
258 if (focused) | 238 if (focused) |
259 webplugin_->UpdateIMEStatus(); | 239 webplugin_->UpdateIMEStatus(); |
260 #endif | 240 #endif |
261 } | 241 } |
262 | 242 |
263 void WebPluginDelegateStub::OnHandleInputEvent( | 243 void WebPluginDelegateStub::OnHandleInputEvent( |
264 const blink::WebInputEvent *event, | 244 const blink::WebInputEvent *event, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 } | 286 } |
307 | 287 |
308 void WebPluginDelegateStub::OnGetFormValue(base::string16* value, | 288 void WebPluginDelegateStub::OnGetFormValue(base::string16* value, |
309 bool* success) { | 289 bool* success) { |
310 *success = false; | 290 *success = false; |
311 if (!delegate_) | 291 if (!delegate_) |
312 return; | 292 return; |
313 *success = delegate_->GetFormValue(value); | 293 *success = delegate_->GetFormValue(value); |
314 } | 294 } |
315 | 295 |
316 void WebPluginDelegateStub::OnSendJavaScriptStream(const GURL& url, | |
317 const std::string& result, | |
318 bool success, | |
319 int notify_id) { | |
320 delegate_->SendJavaScriptStream(url, result, success, notify_id); | |
321 } | |
322 | |
323 void WebPluginDelegateStub::OnSetContentAreaFocus(bool has_focus) { | 296 void WebPluginDelegateStub::OnSetContentAreaFocus(bool has_focus) { |
324 if (delegate_) | 297 if (delegate_) |
325 delegate_->SetContentAreaHasFocus(has_focus); | 298 delegate_->SetContentAreaHasFocus(has_focus); |
326 } | 299 } |
327 | 300 |
328 #if defined(OS_WIN) && !defined(USE_AURA) | 301 #if defined(OS_WIN) && !defined(USE_AURA) |
329 void WebPluginDelegateStub::OnImeCompositionUpdated( | 302 void WebPluginDelegateStub::OnImeCompositionUpdated( |
330 const base::string16& text, | 303 const base::string16& text, |
331 const std::vector<int>& clauses, | 304 const std::vector<int>& clauses, |
332 const std::vector<int>& target, | 305 const std::vector<int>& target, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 delegate_->WindowFrameChanged(window_frame, view_frame); | 343 delegate_->WindowFrameChanged(window_frame, view_frame); |
371 } | 344 } |
372 | 345 |
373 void WebPluginDelegateStub::OnImeCompositionCompleted( | 346 void WebPluginDelegateStub::OnImeCompositionCompleted( |
374 const base::string16& text) { | 347 const base::string16& text) { |
375 if (delegate_) | 348 if (delegate_) |
376 delegate_->ImeCompositionCompleted(text); | 349 delegate_->ImeCompositionCompleted(text); |
377 } | 350 } |
378 #endif // OS_MACOSX | 351 #endif // OS_MACOSX |
379 | 352 |
380 void WebPluginDelegateStub::OnDidReceiveManualResponse( | |
381 const GURL& url, | |
382 const PluginMsg_DidReceiveResponseParams& params) { | |
383 delegate_->DidReceiveManualResponse(url, params.mime_type, params.headers, | |
384 params.expected_length, | |
385 params.last_modified); | |
386 } | |
387 | |
388 void WebPluginDelegateStub::OnDidReceiveManualData( | |
389 const std::vector<char>& buffer) { | |
390 delegate_->DidReceiveManualData(&buffer.front(), | |
391 static_cast<int>(buffer.size())); | |
392 } | |
393 | |
394 void WebPluginDelegateStub::OnDidFinishManualLoading() { | |
395 delegate_->DidFinishManualLoading(); | |
396 } | |
397 | |
398 void WebPluginDelegateStub::OnDidManualLoadFail() { | |
399 delegate_->DidManualLoadFail(); | |
400 } | |
401 | |
402 void WebPluginDelegateStub::OnHandleURLRequestReply( | |
403 unsigned long resource_id, const GURL& url, int notify_id) { | |
404 WebPluginResourceClient* resource_client = | |
405 delegate_->CreateResourceClient(resource_id, url, notify_id); | |
406 webplugin_->OnResourceCreated(resource_id, resource_client); | |
407 } | |
408 | |
409 void WebPluginDelegateStub::OnHTTPRangeRequestReply( | |
410 unsigned long resource_id, int range_request_id) { | |
411 WebPluginResourceClient* resource_client = | |
412 delegate_->CreateSeekableResourceClient(resource_id, range_request_id); | |
413 webplugin_->OnResourceCreated(resource_id, resource_client); | |
414 } | |
415 | |
416 void WebPluginDelegateStub::OnFetchURL( | |
417 const PluginMsg_FetchURL_Params& params) { | |
418 const char* data = NULL; | |
419 if (params.post_data.size()) | |
420 data = ¶ms.post_data[0]; | |
421 | |
422 delegate_->FetchURL(params.resource_id, | |
423 params.notify_id, | |
424 params.url, | |
425 params.first_party_for_cookies, | |
426 params.method, | |
427 data, | |
428 static_cast<unsigned int>(params.post_data.size()), | |
429 Referrer(params.referrer, params.referrer_policy), | |
430 params.notify_redirect, | |
431 params.is_plugin_src_load, | |
432 channel_->renderer_id(), | |
433 params.render_frame_id, | |
434 webplugin_->host_render_view_routing_id()); | |
435 } | |
436 | |
437 } // namespace content | 353 } // namespace content |
OLD | NEW |