| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 browser_plugin_manager()->Send( | 95 browser_plugin_manager()->Send( |
| 96 new BrowserPluginHostMsg_PluginDestroyed(render_view_routing_id_, | 96 new BrowserPluginHostMsg_PluginDestroyed(render_view_routing_id_, |
| 97 browser_plugin_instance_id_)); | 97 browser_plugin_instance_id_)); |
| 98 } | 98 } |
| 99 | 99 |
| 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) | |
| 106 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, | 105 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, |
| 107 OnCompositorFrameSwapped(message)) | 106 OnCompositorFrameSwapped(message)) |
| 108 IPC_MESSAGE_HANDLER(BrowserPluginMsg_CopyFromCompositingSurface, | 107 IPC_MESSAGE_HANDLER(BrowserPluginMsg_CopyFromCompositingSurface, |
| 109 OnCopyFromCompositingSurface) | 108 OnCopyFromCompositingSurface) |
| 110 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) | 109 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) |
| 111 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) | 110 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) |
| 112 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) | 111 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) |
| 113 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, | 112 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, |
| 114 OnShouldAcceptTouchEvents) | 113 OnShouldAcceptTouchEvents) |
| 115 IPC_MESSAGE_UNHANDLED(handled = false) | 114 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 DCHECK(render_view_); | 216 DCHECK(render_view_); |
| 218 render_view_->GetWebView()->advanceFocus(reverse); | 217 render_view_->GetWebView()->advanceFocus(reverse); |
| 219 } | 218 } |
| 220 | 219 |
| 221 void BrowserPlugin::OnAttachACK(int browser_plugin_instance_id) { | 220 void BrowserPlugin::OnAttachACK(int browser_plugin_instance_id) { |
| 222 DCHECK(!attached()); | 221 DCHECK(!attached()); |
| 223 attached_ = true; | 222 attached_ = true; |
| 224 attach_pending_ = false; | 223 attach_pending_ = false; |
| 225 } | 224 } |
| 226 | 225 |
| 227 void BrowserPlugin::OnBuffersSwapped( | |
| 228 int instance_id, | |
| 229 const FrameMsg_BuffersSwapped_Params& params) { | |
| 230 EnableCompositing(true); | |
| 231 | |
| 232 compositing_helper_->OnBuffersSwapped(params.size, | |
| 233 params.mailbox, | |
| 234 params.gpu_route_id, | |
| 235 params.gpu_host_id, | |
| 236 GetDeviceScaleFactor()); | |
| 237 } | |
| 238 | |
| 239 void BrowserPlugin::OnCompositorFrameSwapped(const IPC::Message& message) { | 226 void BrowserPlugin::OnCompositorFrameSwapped(const IPC::Message& message) { |
| 240 BrowserPluginMsg_CompositorFrameSwapped::Param param; | 227 BrowserPluginMsg_CompositorFrameSwapped::Param param; |
| 241 if (!BrowserPluginMsg_CompositorFrameSwapped::Read(&message, ¶m)) | 228 if (!BrowserPluginMsg_CompositorFrameSwapped::Read(&message, ¶m)) |
| 242 return; | 229 return; |
| 243 | 230 |
| 244 // Note that there is no need to send ACK for this message. | 231 // Note that there is no need to send ACK for this message. |
| 245 // If the guest has updated pixels then it is no longer crashed. | 232 // If the guest has updated pixels then it is no longer crashed. |
| 246 guest_crashed_ = false; | 233 guest_crashed_ = false; |
| 247 | 234 |
| 248 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); | 235 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 paint.setColor(guest_crashed_ ? SK_ColorBLACK : SK_ColorWHITE); | 477 paint.setColor(guest_crashed_ ? SK_ColorBLACK : SK_ColorWHITE); |
| 491 canvas->drawRect(image_data_rect, paint); | 478 canvas->drawRect(image_data_rect, paint); |
| 492 } | 479 } |
| 493 | 480 |
| 494 // static | 481 // static |
| 495 bool BrowserPlugin::ShouldForwardToBrowserPlugin( | 482 bool BrowserPlugin::ShouldForwardToBrowserPlugin( |
| 496 const IPC::Message& message) { | 483 const IPC::Message& message) { |
| 497 switch (message.type()) { | 484 switch (message.type()) { |
| 498 case BrowserPluginMsg_Attach_ACK::ID: | 485 case BrowserPluginMsg_Attach_ACK::ID: |
| 499 case BrowserPluginMsg_AdvanceFocus::ID: | 486 case BrowserPluginMsg_AdvanceFocus::ID: |
| 500 case BrowserPluginMsg_BuffersSwapped::ID: | |
| 501 case BrowserPluginMsg_CompositorFrameSwapped::ID: | 487 case BrowserPluginMsg_CompositorFrameSwapped::ID: |
| 502 case BrowserPluginMsg_CopyFromCompositingSurface::ID: | 488 case BrowserPluginMsg_CopyFromCompositingSurface::ID: |
| 503 case BrowserPluginMsg_GuestGone::ID: | 489 case BrowserPluginMsg_GuestGone::ID: |
| 504 case BrowserPluginMsg_SetCursor::ID: | 490 case BrowserPluginMsg_SetCursor::ID: |
| 505 case BrowserPluginMsg_SetMouseLock::ID: | 491 case BrowserPluginMsg_SetMouseLock::ID: |
| 506 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: | 492 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: |
| 507 return true; | 493 return true; |
| 508 default: | 494 default: |
| 509 break; | 495 break; |
| 510 } | 496 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 const blink::WebMouseEvent& event) { | 716 const blink::WebMouseEvent& event) { |
| 731 browser_plugin_manager()->Send( | 717 browser_plugin_manager()->Send( |
| 732 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 718 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
| 733 browser_plugin_instance_id_, | 719 browser_plugin_instance_id_, |
| 734 plugin_rect_, | 720 plugin_rect_, |
| 735 &event)); | 721 &event)); |
| 736 return true; | 722 return true; |
| 737 } | 723 } |
| 738 | 724 |
| 739 } // namespace content | 725 } // namespace content |
| OLD | NEW |