OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/renderer/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { | 100 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { |
101 bool handled = true; | 101 bool handled = true; |
102 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) | 102 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) |
103 IPC_MESSAGE_HANDLER(BrowserPluginMsg_Attach_ACK, OnAttachACK) | 103 IPC_MESSAGE_HANDLER(BrowserPluginMsg_Attach_ACK, OnAttachACK) |
104 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) | 104 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) |
105 IPC_MESSAGE_HANDLER(BrowserPluginMsg_BuffersSwapped, OnBuffersSwapped) | 105 IPC_MESSAGE_HANDLER(BrowserPluginMsg_BuffersSwapped, OnBuffersSwapped) |
106 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, | 106 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, |
107 OnCompositorFrameSwapped(message)) | 107 OnCompositorFrameSwapped(message)) |
108 IPC_MESSAGE_HANDLER(BrowserPluginMsg_CopyFromCompositingSurface, | 108 IPC_MESSAGE_HANDLER(BrowserPluginMsg_CopyFromCompositingSurface, |
109 OnCopyFromCompositingSurface) | 109 OnCopyFromCompositingSurface) |
110 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady, | |
111 OnGuestContentWindowReady) | |
112 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) | 110 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) |
113 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) | 111 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) |
114 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) | 112 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) |
115 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, | 113 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, |
116 OnShouldAcceptTouchEvents) | 114 OnShouldAcceptTouchEvents) |
117 IPC_MESSAGE_UNHANDLED(handled = false) | 115 IPC_MESSAGE_UNHANDLED(handled = false) |
118 IPC_END_MESSAGE_MAP() | 116 IPC_END_MESSAGE_MAP() |
119 return handled; | 117 return handled; |
120 } | 118 } |
121 | 119 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 render_view_routing_id_, | 266 render_view_routing_id_, |
269 browser_plugin_instance_id_, | 267 browser_plugin_instance_id_, |
270 request_id, | 268 request_id, |
271 SkBitmap())); | 269 SkBitmap())); |
272 return; | 270 return; |
273 } | 271 } |
274 compositing_helper_->CopyFromCompositingSurface(request_id, source_rect, | 272 compositing_helper_->CopyFromCompositingSurface(request_id, source_rect, |
275 dest_size); | 273 dest_size); |
276 } | 274 } |
277 | 275 |
278 void BrowserPlugin::OnGuestContentWindowReady(int browser_plugin_instance_id, | |
279 int content_window_routing_id) { | |
280 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); | |
281 content_window_routing_id_ = content_window_routing_id; | |
282 } | |
283 | |
284 void BrowserPlugin::OnGuestGone(int browser_plugin_instance_id) { | 276 void BrowserPlugin::OnGuestGone(int browser_plugin_instance_id) { |
285 guest_crashed_ = true; | 277 guest_crashed_ = true; |
286 | 278 |
287 // Turn off compositing so we can display the sad graphic. Changes to | 279 // Turn off compositing so we can display the sad graphic. Changes to |
288 // compositing state will show up at a later time after a layout and commit. | 280 // compositing state will show up at a later time after a layout and commit. |
289 EnableCompositing(false); | 281 EnableCompositing(false); |
290 | 282 |
291 // Queue up showing the sad graphic to give content embedders an opportunity | 283 // Queue up showing the sad graphic to give content embedders an opportunity |
292 // to fire their listeners and potentially overlay the webview with custom | 284 // to fire their listeners and potentially overlay the webview with custom |
293 // behavior. If the BrowserPlugin is destroyed in the meantime, then the | 285 // behavior. If the BrowserPlugin is destroyed in the meantime, then the |
(...skipping 26 matching lines...) Expand all Loading... |
320 | 312 |
321 void BrowserPlugin::OnShouldAcceptTouchEvents(int browser_plugin_instance_id, | 313 void BrowserPlugin::OnShouldAcceptTouchEvents(int browser_plugin_instance_id, |
322 bool accept) { | 314 bool accept) { |
323 if (container()) { | 315 if (container()) { |
324 container()->requestTouchEventType( | 316 container()->requestTouchEventType( |
325 accept ? WebPluginContainer::TouchEventRequestTypeRaw | 317 accept ? WebPluginContainer::TouchEventRequestTypeRaw |
326 : WebPluginContainer::TouchEventRequestTypeNone); | 318 : WebPluginContainer::TouchEventRequestTypeNone); |
327 } | 319 } |
328 } | 320 } |
329 | 321 |
330 NPObject* BrowserPlugin::GetContentWindow() const { | |
331 if (content_window_routing_id_ == MSG_ROUTING_NONE) | |
332 return NULL; | |
333 RenderViewImpl* guest_render_view = RenderViewImpl::FromRoutingID( | |
334 content_window_routing_id_); | |
335 if (!guest_render_view) | |
336 return NULL; | |
337 blink::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); | |
338 return guest_frame->windowObject(); | |
339 } | |
340 | |
341 void BrowserPlugin::ShowSadGraphic() { | 322 void BrowserPlugin::ShowSadGraphic() { |
342 // If the BrowserPlugin is scheduled to be deleted, then container_ will be | 323 // If the BrowserPlugin is scheduled to be deleted, then container_ will be |
343 // NULL so we shouldn't attempt to access it. | 324 // NULL so we shouldn't attempt to access it. |
344 if (container_) | 325 if (container_) |
345 container_->invalidate(); | 326 container_->invalidate(); |
346 } | 327 } |
347 | 328 |
348 float BrowserPlugin::GetDeviceScaleFactor() const { | 329 float BrowserPlugin::GetDeviceScaleFactor() const { |
349 if (!render_view_) | 330 if (!render_view_) |
350 return 1.0f; | 331 return 1.0f; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 | 493 |
513 // static | 494 // static |
514 bool BrowserPlugin::ShouldForwardToBrowserPlugin( | 495 bool BrowserPlugin::ShouldForwardToBrowserPlugin( |
515 const IPC::Message& message) { | 496 const IPC::Message& message) { |
516 switch (message.type()) { | 497 switch (message.type()) { |
517 case BrowserPluginMsg_Attach_ACK::ID: | 498 case BrowserPluginMsg_Attach_ACK::ID: |
518 case BrowserPluginMsg_AdvanceFocus::ID: | 499 case BrowserPluginMsg_AdvanceFocus::ID: |
519 case BrowserPluginMsg_BuffersSwapped::ID: | 500 case BrowserPluginMsg_BuffersSwapped::ID: |
520 case BrowserPluginMsg_CompositorFrameSwapped::ID: | 501 case BrowserPluginMsg_CompositorFrameSwapped::ID: |
521 case BrowserPluginMsg_CopyFromCompositingSurface::ID: | 502 case BrowserPluginMsg_CopyFromCompositingSurface::ID: |
522 case BrowserPluginMsg_GuestContentWindowReady::ID: | |
523 case BrowserPluginMsg_GuestGone::ID: | 503 case BrowserPluginMsg_GuestGone::ID: |
524 case BrowserPluginMsg_SetCursor::ID: | 504 case BrowserPluginMsg_SetCursor::ID: |
525 case BrowserPluginMsg_SetMouseLock::ID: | 505 case BrowserPluginMsg_SetMouseLock::ID: |
526 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: | 506 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: |
527 return true; | 507 return true; |
528 default: | 508 default: |
529 break; | 509 break; |
530 } | 510 } |
531 return false; | 511 return false; |
532 } | 512 } |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 const blink::WebMouseEvent& event) { | 730 const blink::WebMouseEvent& event) { |
751 browser_plugin_manager()->Send( | 731 browser_plugin_manager()->Send( |
752 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 732 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
753 browser_plugin_instance_id_, | 733 browser_plugin_instance_id_, |
754 plugin_rect_, | 734 plugin_rect_, |
755 &event)); | 735 &event)); |
756 return true; | 736 return true; |
757 } | 737 } |
758 | 738 |
759 } // namespace content | 739 } // namespace content |
OLD | NEW |