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/renderer/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "content/common/browser_plugin_messages.h" | 12 #include "content/common/browser_plugin_messages.h" |
13 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
14 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
15 #include "content/public/renderer/content_renderer_client.h" | 15 #include "content/public/renderer/content_renderer_client.h" |
16 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" | 16 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
| 17 #include "content/renderer/browser_plugin/browser_plugin_compositing_helper.h" |
17 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 18 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
18 #include "content/renderer/render_process_impl.h" | 19 #include "content/renderer/render_process_impl.h" |
19 #include "content/renderer/render_thread_impl.h" | 20 #include "content/renderer/render_thread_impl.h" |
20 #include "content/renderer/v8_value_converter_impl.h" | 21 #include "content/renderer/v8_value_converter_impl.h" |
21 #include "skia/ext/platform_canvas.h" | 22 #include "skia/ext/platform_canvas.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMCustomEvent.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMCustomEvent.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 browser_plugin_manager()->Send( | 146 browser_plugin_manager()->Send( |
146 new BrowserPluginHostMsg_PluginDestroyed( | 147 new BrowserPluginHostMsg_PluginDestroyed( |
147 render_view_routing_id_, | 148 render_view_routing_id_, |
148 instance_id_)); | 149 instance_id_)); |
149 } | 150 } |
150 | 151 |
151 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { | 152 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { |
152 bool handled = true; | 153 bool handled = true; |
153 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) | 154 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) |
154 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) | 155 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) |
| 156 IPC_MESSAGE_HANDLER(BrowserPluginMsg_BuffersSwapped, OnBuffersSwapped) |
155 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady, | 157 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady, |
156 OnGuestContentWindowReady) | 158 OnGuestContentWindowReady) |
157 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) | 159 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) |
158 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestResponsive, OnGuestResponsive) | 160 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestResponsive, OnGuestResponsive) |
159 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestUnresponsive, OnGuestUnresponsive) | 161 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestUnresponsive, OnGuestUnresponsive) |
160 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadAbort, OnLoadAbort) | 162 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadAbort, OnLoadAbort) |
161 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadCommit, OnLoadCommit) | 163 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadCommit, OnLoadCommit) |
162 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadRedirect, OnLoadRedirect) | 164 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadRedirect, OnLoadRedirect) |
163 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStart, OnLoadStart) | 165 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStart, OnLoadStart) |
164 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStop, OnLoadStop) | 166 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStop, OnLoadStop) |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 if (!pending_damage_buffer_.get()) | 313 if (!pending_damage_buffer_.get()) |
312 return false; | 314 return false; |
313 return damage_buffer_sequence_id_ == params.damage_buffer_sequence_id; | 315 return damage_buffer_sequence_id_ == params.damage_buffer_sequence_id; |
314 } | 316 } |
315 | 317 |
316 void BrowserPlugin::OnAdvanceFocus(int instance_id, bool reverse) { | 318 void BrowserPlugin::OnAdvanceFocus(int instance_id, bool reverse) { |
317 DCHECK(render_view_); | 319 DCHECK(render_view_); |
318 render_view_->GetWebView()->advanceFocus(reverse); | 320 render_view_->GetWebView()->advanceFocus(reverse); |
319 } | 321 } |
320 | 322 |
| 323 void BrowserPlugin::OnBuffersSwapped(int instance_id, |
| 324 const gfx::Size& size, |
| 325 std::string mailbox_name, |
| 326 int gpu_route_id, |
| 327 int gpu_host_id) { |
| 328 DCHECK(instance_id == instance_id_); |
| 329 EnableCompositing(true); |
| 330 |
| 331 compositing_helper_->OnBuffersSwapped(size, |
| 332 mailbox_name, |
| 333 gpu_route_id, |
| 334 gpu_host_id); |
| 335 } |
| 336 |
321 void BrowserPlugin::OnGuestContentWindowReady(int instance_id, | 337 void BrowserPlugin::OnGuestContentWindowReady(int instance_id, |
322 int content_window_routing_id) { | 338 int content_window_routing_id) { |
323 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); | 339 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); |
324 content_window_routing_id_ = content_window_routing_id; | 340 content_window_routing_id_ = content_window_routing_id; |
325 } | 341 } |
326 | 342 |
327 void BrowserPlugin::OnGuestGone(int instance_id, int process_id, int status) { | 343 void BrowserPlugin::OnGuestGone(int instance_id, int process_id, int status) { |
328 // We fire the event listeners before painting the sad graphic to give the | 344 // We fire the event listeners before painting the sad graphic to give the |
329 // developer an opportunity to display an alternative overlay image on crash. | 345 // developer an opportunity to display an alternative overlay image on crash. |
330 std::string termination_status = TerminationStatusToString( | 346 std::string termination_status = TerminationStatusToString( |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 return container_; | 806 return container_; |
791 } | 807 } |
792 | 808 |
793 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 809 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
794 container_ = container; | 810 container_ = container; |
795 container_->setWantsWheelEvents(true); | 811 container_->setWantsWheelEvents(true); |
796 return true; | 812 return true; |
797 } | 813 } |
798 | 814 |
799 void BrowserPlugin::EnableCompositing(bool enable) { | 815 void BrowserPlugin::EnableCompositing(bool enable) { |
800 if (enable) { | 816 if (compositing_enabled_ == enable) |
801 LOG(ERROR) << "BrowserPlugin compositing not yet implemented."; | |
802 return; | 817 return; |
| 818 |
| 819 if (enable && !compositing_helper_) { |
| 820 compositing_helper_.reset(new BrowserPluginCompositingHelper( |
| 821 container_, |
| 822 render_view_routing_id_)); |
803 } | 823 } |
804 | 824 |
| 825 compositing_helper_->EnableCompositing(enable); |
805 compositing_enabled_ = enable; | 826 compositing_enabled_ = enable; |
806 } | 827 } |
807 | 828 |
808 void BrowserPlugin::destroy() { | 829 void BrowserPlugin::destroy() { |
809 // The BrowserPlugin's WebPluginContainer is deleted immediately after this | 830 // The BrowserPlugin's WebPluginContainer is deleted immediately after this |
810 // call returns, so let's not keep a reference to it around. | 831 // call returns, so let's not keep a reference to it around. |
811 container_ = NULL; | 832 container_ = NULL; |
| 833 compositing_helper_.reset(); |
812 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 834 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
813 } | 835 } |
814 | 836 |
815 NPObject* BrowserPlugin::scriptableObject() { | 837 NPObject* BrowserPlugin::scriptableObject() { |
816 NPObject* browser_plugin_np_object(bindings_->np_object()); | 838 NPObject* browser_plugin_np_object(bindings_->np_object()); |
817 // The object is expected to be retained before it is returned. | 839 // The object is expected to be retained before it is returned. |
818 WebKit::WebBindings::retainObject(browser_plugin_np_object); | 840 WebKit::WebBindings::retainObject(browser_plugin_np_object); |
819 return browser_plugin_np_object; | 841 return browser_plugin_np_object; |
820 } | 842 } |
821 | 843 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 void* notify_data) { | 1095 void* notify_data) { |
1074 } | 1096 } |
1075 | 1097 |
1076 void BrowserPlugin::didFailLoadingFrameRequest( | 1098 void BrowserPlugin::didFailLoadingFrameRequest( |
1077 const WebKit::WebURL& url, | 1099 const WebKit::WebURL& url, |
1078 void* notify_data, | 1100 void* notify_data, |
1079 const WebKit::WebURLError& error) { | 1101 const WebKit::WebURLError& error) { |
1080 } | 1102 } |
1081 | 1103 |
1082 } // namespace content | 1104 } // namespace content |
OLD | NEW |