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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 browser_plugin_manager()->Send( | 140 browser_plugin_manager()->Send( |
140 new BrowserPluginHostMsg_PluginDestroyed( | 141 new BrowserPluginHostMsg_PluginDestroyed( |
141 render_view_routing_id_, | 142 render_view_routing_id_, |
142 instance_id_)); | 143 instance_id_)); |
143 } | 144 } |
144 | 145 |
145 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { | 146 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { |
146 bool handled = true; | 147 bool handled = true; |
147 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) | 148 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) |
148 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) | 149 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) |
150 IPC_MESSAGE_HANDLER(BrowserPluginMsg_BuffersSwapped, OnBuffersSwapped) | |
149 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady, | 151 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady, |
150 OnGuestContentWindowReady) | 152 OnGuestContentWindowReady) |
151 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) | 153 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) |
152 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestResponsive, OnGuestResponsive) | 154 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestResponsive, OnGuestResponsive) |
153 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestUnresponsive, OnGuestUnresponsive) | 155 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestUnresponsive, OnGuestUnresponsive) |
154 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadAbort, OnLoadAbort) | 156 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadAbort, OnLoadAbort) |
155 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadCommit, OnLoadCommit) | 157 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadCommit, OnLoadCommit) |
156 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadRedirect, OnLoadRedirect) | 158 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadRedirect, OnLoadRedirect) |
157 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStart, OnLoadStart) | 159 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStart, OnLoadStart) |
158 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStop, OnLoadStop) | 160 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStop, OnLoadStop) |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 if (!pending_damage_buffer_.get()) | 290 if (!pending_damage_buffer_.get()) |
289 return false; | 291 return false; |
290 return damage_buffer_sequence_id_ == params.damage_buffer_sequence_id; | 292 return damage_buffer_sequence_id_ == params.damage_buffer_sequence_id; |
291 } | 293 } |
292 | 294 |
293 void BrowserPlugin::OnAdvanceFocus(int instance_id, bool reverse) { | 295 void BrowserPlugin::OnAdvanceFocus(int instance_id, bool reverse) { |
294 DCHECK(render_view_); | 296 DCHECK(render_view_); |
295 render_view_->GetWebView()->advanceFocus(reverse); | 297 render_view_->GetWebView()->advanceFocus(reverse); |
296 } | 298 } |
297 | 299 |
300 void BrowserPlugin::OnBuffersSwapped(int instance_id, | |
301 const gfx::Size& size, | |
302 std::string mailbox_name, | |
303 int gpu_route_id, | |
304 int gpu_host_id) { | |
305 DCHECK(instance_id == instance_id_); | |
306 EnableCompositing(true); | |
307 | |
308 compositing_helper_->OnBuffersSwapped(size, | |
309 mailbox_name, | |
310 gpu_route_id, | |
311 gpu_host_id); | |
312 } | |
313 | |
298 void BrowserPlugin::OnGuestContentWindowReady(int instance_id, | 314 void BrowserPlugin::OnGuestContentWindowReady(int instance_id, |
299 int content_window_routing_id) { | 315 int content_window_routing_id) { |
300 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); | 316 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); |
301 content_window_routing_id_ = content_window_routing_id; | 317 content_window_routing_id_ = content_window_routing_id; |
302 } | 318 } |
303 | 319 |
304 void BrowserPlugin::OnGuestGone(int instance_id, int process_id, int status) { | 320 void BrowserPlugin::OnGuestGone(int instance_id, int process_id, int status) { |
305 // We fire the event listeners before painting the sad graphic to give the | 321 // We fire the event listeners before painting the sad graphic to give the |
306 // developer an opportunity to display an alternative overlay image on crash. | 322 // developer an opportunity to display an alternative overlay image on crash. |
307 std::string termination_status = TerminationStatusToString( | 323 std::string termination_status = TerminationStatusToString( |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 return container_; | 771 return container_; |
756 } | 772 } |
757 | 773 |
758 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 774 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
759 container_ = container; | 775 container_ = container; |
760 container_->setWantsWheelEvents(true); | 776 container_->setWantsWheelEvents(true); |
761 return true; | 777 return true; |
762 } | 778 } |
763 | 779 |
764 void BrowserPlugin::EnableCompositing(bool enable) { | 780 void BrowserPlugin::EnableCompositing(bool enable) { |
765 if (enable) { | 781 if (compositing_enabled_ == enable) |
766 LOG(ERROR) << "BrowserPlugin compositing not yet implemented."; | |
767 return; | 782 return; |
783 | |
784 if (enable && !compositing_helper_) { | |
785 compositing_helper_.reset(new BrowserPluginCompositingHelper( | |
786 container_, | |
rjkroege
2013/01/10 17:03:21
should align with new?
alexst (slow to review)
2013/01/10 18:56:31
All the new statements in the function parameters
rjkroege
2013/01/10 19:03:53
sgtm.
| |
787 render_view_routing_id_)); | |
768 } | 788 } |
769 | 789 |
790 compositing_helper_->EnableCompositing(enable); | |
770 compositing_enabled_ = enable; | 791 compositing_enabled_ = enable; |
771 } | 792 } |
772 | 793 |
773 void BrowserPlugin::destroy() { | 794 void BrowserPlugin::destroy() { |
774 // The BrowserPlugin's WebPluginContainer is deleted immediately after this | 795 // The BrowserPlugin's WebPluginContainer is deleted immediately after this |
775 // call returns, so let's not keep a reference to it around. | 796 // call returns, so let's not keep a reference to it around. |
776 container_ = NULL; | 797 container_ = NULL; |
798 compositing_helper_.reset(); | |
777 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 799 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
778 } | 800 } |
779 | 801 |
780 NPObject* BrowserPlugin::scriptableObject() { | 802 NPObject* BrowserPlugin::scriptableObject() { |
781 NPObject* browser_plugin_np_object(bindings_->np_object()); | 803 NPObject* browser_plugin_np_object(bindings_->np_object()); |
782 // The object is expected to be retained before it is returned. | 804 // The object is expected to be retained before it is returned. |
783 WebKit::WebBindings::retainObject(browser_plugin_np_object); | 805 WebKit::WebBindings::retainObject(browser_plugin_np_object); |
784 return browser_plugin_np_object; | 806 return browser_plugin_np_object; |
785 } | 807 } |
786 | 808 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1039 void* notify_data) { | 1061 void* notify_data) { |
1040 } | 1062 } |
1041 | 1063 |
1042 void BrowserPlugin::didFailLoadingFrameRequest( | 1064 void BrowserPlugin::didFailLoadingFrameRequest( |
1043 const WebKit::WebURL& url, | 1065 const WebKit::WebURL& url, |
1044 void* notify_data, | 1066 void* notify_data, |
1045 const WebKit::WebURLError& error) { | 1067 const WebKit::WebURLError& error) { |
1046 } | 1068 } |
1047 | 1069 |
1048 } // namespace content | 1070 } // namespace content |
OLD | NEW |