| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 browser_plugin_manager()->RemoveBrowserPlugin(browser_plugin_instance_id_); | 88 browser_plugin_manager()->RemoveBrowserPlugin(browser_plugin_instance_id_); |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { | 91 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { |
| 92 bool handled = true; | 92 bool handled = true; |
| 93 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) | 93 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) |
| 94 IPC_MESSAGE_HANDLER(BrowserPluginMsg_Attach_ACK, OnAttachACK) | 94 IPC_MESSAGE_HANDLER(BrowserPluginMsg_Attach_ACK, OnAttachACK) |
| 95 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) | 95 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) |
| 96 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, | 96 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, |
| 97 OnCompositorFrameSwapped(message)) | 97 OnCompositorFrameSwapped(message)) |
| 98 IPC_MESSAGE_HANDLER(BrowserPluginMsg_CopyFromCompositingSurface, | |
| 99 OnCopyFromCompositingSurface) | |
| 100 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) | 98 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) |
| 101 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetContentsOpaque, OnSetContentsOpaque) | 99 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetContentsOpaque, OnSetContentsOpaque) |
| 102 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) | 100 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) |
| 103 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) | 101 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) |
| 104 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetTooltipText, OnSetTooltipText) | 102 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetTooltipText, OnSetTooltipText) |
| 105 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, | 103 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, |
| 106 OnShouldAcceptTouchEvents) | 104 OnShouldAcceptTouchEvents) |
| 107 IPC_MESSAGE_UNHANDLED(handled = false) | 105 IPC_MESSAGE_UNHANDLED(handled = false) |
| 108 IPC_END_MESSAGE_MAP() | 106 IPC_END_MESSAGE_MAP() |
| 109 return handled; | 107 return handled; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 param.b.frame.AssignTo(frame.get()); | 182 param.b.frame.AssignTo(frame.get()); |
| 185 | 183 |
| 186 EnableCompositing(true); | 184 EnableCompositing(true); |
| 187 compositing_helper_->OnCompositorFrameSwapped(frame.Pass(), | 185 compositing_helper_->OnCompositorFrameSwapped(frame.Pass(), |
| 188 param.b.producing_route_id, | 186 param.b.producing_route_id, |
| 189 param.b.output_surface_id, | 187 param.b.output_surface_id, |
| 190 param.b.producing_host_id, | 188 param.b.producing_host_id, |
| 191 param.b.shared_memory_handle); | 189 param.b.shared_memory_handle); |
| 192 } | 190 } |
| 193 | 191 |
| 194 void BrowserPlugin::OnCopyFromCompositingSurface(int browser_plugin_instance_id, | |
| 195 int request_id, | |
| 196 gfx::Rect source_rect, | |
| 197 gfx::Size dest_size) { | |
| 198 if (!compositing_helper_.get()) { | |
| 199 browser_plugin_manager()->Send( | |
| 200 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( | |
| 201 render_view_routing_id_, | |
| 202 browser_plugin_instance_id_, | |
| 203 request_id, | |
| 204 SkBitmap())); | |
| 205 return; | |
| 206 } | |
| 207 compositing_helper_->CopyFromCompositingSurface(request_id, source_rect, | |
| 208 dest_size); | |
| 209 } | |
| 210 | |
| 211 void BrowserPlugin::OnGuestGone(int browser_plugin_instance_id) { | 192 void BrowserPlugin::OnGuestGone(int browser_plugin_instance_id) { |
| 212 guest_crashed_ = true; | 193 guest_crashed_ = true; |
| 213 | 194 |
| 214 // Turn off compositing so we can display the sad graphic. Changes to | 195 // Turn off compositing so we can display the sad graphic. Changes to |
| 215 // compositing state will show up at a later time after a layout and commit. | 196 // compositing state will show up at a later time after a layout and commit. |
| 216 EnableCompositing(false); | 197 EnableCompositing(false); |
| 217 | 198 |
| 218 // Queue up showing the sad graphic to give content embedders an opportunity | 199 // Queue up showing the sad graphic to give content embedders an opportunity |
| 219 // to fire their listeners and potentially overlay the webview with custom | 200 // to fire their listeners and potentially overlay the webview with custom |
| 220 // behavior. If the BrowserPlugin is destroyed in the meantime, then the | 201 // behavior. If the BrowserPlugin is destroyed in the meantime, then the |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 canvas->drawRect(image_data_rect, paint); | 402 canvas->drawRect(image_data_rect, paint); |
| 422 } | 403 } |
| 423 | 404 |
| 424 // static | 405 // static |
| 425 bool BrowserPlugin::ShouldForwardToBrowserPlugin( | 406 bool BrowserPlugin::ShouldForwardToBrowserPlugin( |
| 426 const IPC::Message& message) { | 407 const IPC::Message& message) { |
| 427 switch (message.type()) { | 408 switch (message.type()) { |
| 428 case BrowserPluginMsg_Attach_ACK::ID: | 409 case BrowserPluginMsg_Attach_ACK::ID: |
| 429 case BrowserPluginMsg_AdvanceFocus::ID: | 410 case BrowserPluginMsg_AdvanceFocus::ID: |
| 430 case BrowserPluginMsg_CompositorFrameSwapped::ID: | 411 case BrowserPluginMsg_CompositorFrameSwapped::ID: |
| 431 case BrowserPluginMsg_CopyFromCompositingSurface::ID: | |
| 432 case BrowserPluginMsg_GuestGone::ID: | 412 case BrowserPluginMsg_GuestGone::ID: |
| 433 case BrowserPluginMsg_SetContentsOpaque::ID: | 413 case BrowserPluginMsg_SetContentsOpaque::ID: |
| 434 case BrowserPluginMsg_SetCursor::ID: | 414 case BrowserPluginMsg_SetCursor::ID: |
| 435 case BrowserPluginMsg_SetMouseLock::ID: | 415 case BrowserPluginMsg_SetMouseLock::ID: |
| 436 case BrowserPluginMsg_SetTooltipText::ID: | 416 case BrowserPluginMsg_SetTooltipText::ID: |
| 437 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: | 417 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: |
| 438 return true; | 418 return true; |
| 439 default: | 419 default: |
| 440 break; | 420 break; |
| 441 } | 421 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 const blink::WebMouseEvent& event) { | 646 const blink::WebMouseEvent& event) { |
| 667 browser_plugin_manager()->Send( | 647 browser_plugin_manager()->Send( |
| 668 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 648 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
| 669 browser_plugin_instance_id_, | 649 browser_plugin_instance_id_, |
| 670 plugin_rect_, | 650 plugin_rect_, |
| 671 &event)); | 651 &event)); |
| 672 return true; | 652 return true; |
| 673 } | 653 } |
| 674 | 654 |
| 675 } // namespace content | 655 } // namespace content |
| OLD | NEW |