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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 persist_storage_(false), | 121 persist_storage_(false), |
121 valid_partition_id_(true), | 122 valid_partition_id_(true), |
122 content_window_routing_id_(MSG_ROUTING_NONE), | 123 content_window_routing_id_(MSG_ROUTING_NONE), |
123 plugin_focused_(false), | 124 plugin_focused_(false), |
124 embedder_focused_(false), | 125 embedder_focused_(false), |
125 visible_(true), | 126 visible_(true), |
126 size_changed_in_flight_(false), | 127 size_changed_in_flight_(false), |
127 browser_plugin_manager_(render_view->browser_plugin_manager()), | 128 browser_plugin_manager_(render_view->browser_plugin_manager()), |
128 current_nav_entry_index_(0), | 129 current_nav_entry_index_(0), |
129 nav_entry_count_(0), | 130 nav_entry_count_(0), |
130 compositing_enabled_(false) { | 131 compositing_enabled_(false), |
132 compositing_helper_(0) { | |
piman
2013/01/09 22:38:57
nit: we don't use 0 for NULL in chrome code. Becau
alexst (slow to review)
2013/01/09 23:16:05
Done.
| |
131 browser_plugin_manager()->AddBrowserPlugin(instance_id, this); | 133 browser_plugin_manager()->AddBrowserPlugin(instance_id, this); |
132 bindings_.reset(new BrowserPluginBindings(this)); | 134 bindings_.reset(new BrowserPluginBindings(this)); |
133 | 135 |
134 ParseAttributes(params); | 136 ParseAttributes(params); |
135 } | 137 } |
136 | 138 |
137 BrowserPlugin::~BrowserPlugin() { | 139 BrowserPlugin::~BrowserPlugin() { |
138 browser_plugin_manager()->RemoveBrowserPlugin(instance_id_); | 140 browser_plugin_manager()->RemoveBrowserPlugin(instance_id_); |
139 browser_plugin_manager()->Send( | 141 browser_plugin_manager()->Send( |
140 new BrowserPluginHostMsg_PluginDestroyed( | 142 new BrowserPluginHostMsg_PluginDestroyed( |
(...skipping 12 matching lines...) Expand all Loading... | |
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) |
159 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, | 161 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, |
160 OnShouldAcceptTouchEvents) | 162 OnShouldAcceptTouchEvents) |
161 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) | 163 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) |
162 IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdateRect, OnUpdateRect) | 164 IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdateRect, OnUpdateRect) |
165 IPC_MESSAGE_HANDLER(BrowserPluginMsg_BuffersSwapped, OnBuffersSwapped) | |
Fady Samuel
2013/01/09 21:23:38
Please order alphabetically.
alexst (slow to review)
2013/01/09 21:43:39
Done.
| |
163 IPC_MESSAGE_UNHANDLED(handled = false) | 166 IPC_MESSAGE_UNHANDLED(handled = false) |
164 IPC_END_MESSAGE_MAP() | 167 IPC_END_MESSAGE_MAP() |
165 return handled; | 168 return handled; |
166 } | 169 } |
167 | 170 |
168 void BrowserPlugin::UpdateDOMAttribute( | 171 void BrowserPlugin::UpdateDOMAttribute( |
169 const std::string& attribute_name, | 172 const std::string& attribute_name, |
170 const std::string& attribute_value) { | 173 const std::string& attribute_value) { |
171 if (!container()) | 174 if (!container()) |
172 return; | 175 return; |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 return container_; | 758 return container_; |
756 } | 759 } |
757 | 760 |
758 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 761 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
759 container_ = container; | 762 container_ = container; |
760 container_->setWantsWheelEvents(true); | 763 container_->setWantsWheelEvents(true); |
761 return true; | 764 return true; |
762 } | 765 } |
763 | 766 |
764 void BrowserPlugin::EnableCompositing(bool enable) { | 767 void BrowserPlugin::EnableCompositing(bool enable) { |
765 if (enable) { | 768 if (compositing_enabled_ == enable) |
766 LOG(ERROR) << "BrowserPlugin compositing not yet implemented."; | |
767 return; | 769 return; |
770 | |
771 if (enable && !compositing_helper_) { | |
772 compositing_helper_.reset(new BrowserPluginCompositingHelper( | |
773 container_, | |
774 render_view_routing_id_)); | |
768 } | 775 } |
769 | 776 |
777 compositing_helper_->EnableCompositing(enable); | |
770 compositing_enabled_ = enable; | 778 compositing_enabled_ = enable; |
771 } | 779 } |
772 | 780 |
773 void BrowserPlugin::destroy() { | 781 void BrowserPlugin::destroy() { |
774 // The BrowserPlugin's WebPluginContainer is deleted immediately after this | 782 // The BrowserPlugin's WebPluginContainer is deleted immediately after this |
775 // call returns, so let's not keep a reference to it around. | 783 // call returns, so let's not keep a reference to it around. |
776 container_ = NULL; | 784 container_ = NULL; |
piman
2013/01/09 22:38:57
compositing_helper_ still has a reference to the c
alexst (slow to review)
2013/01/09 23:16:05
Done.
| |
777 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 785 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
778 } | 786 } |
779 | 787 |
780 NPObject* BrowserPlugin::scriptableObject() { | 788 NPObject* BrowserPlugin::scriptableObject() { |
781 NPObject* browser_plugin_np_object(bindings_->np_object()); | 789 NPObject* browser_plugin_np_object(bindings_->np_object()); |
782 // The object is expected to be retained before it is returned. | 790 // The object is expected to be retained before it is returned. |
783 WebKit::WebBindings::retainObject(browser_plugin_np_object); | 791 WebKit::WebBindings::retainObject(browser_plugin_np_object); |
784 return browser_plugin_np_object; | 792 return browser_plugin_np_object; |
785 } | 793 } |
786 | 794 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1038 void BrowserPlugin::didFinishLoadingFrameRequest(const WebKit::WebURL& url, | 1046 void BrowserPlugin::didFinishLoadingFrameRequest(const WebKit::WebURL& url, |
1039 void* notify_data) { | 1047 void* notify_data) { |
1040 } | 1048 } |
1041 | 1049 |
1042 void BrowserPlugin::didFailLoadingFrameRequest( | 1050 void BrowserPlugin::didFailLoadingFrameRequest( |
1043 const WebKit::WebURL& url, | 1051 const WebKit::WebURL& url, |
1044 void* notify_data, | 1052 void* notify_data, |
1045 const WebKit::WebURLError& error) { | 1053 const WebKit::WebURLError& error) { |
1046 } | 1054 } |
1047 | 1055 |
1056 void BrowserPlugin::OnBuffersSwapped(int instance_id, | |
Fady Samuel
2013/01/09 21:23:38
Please place this in alphabetical order.
alexst (slow to review)
2013/01/09 21:43:39
Done.
| |
1057 const gfx::Size& size, | |
1058 std::string mailbox_name, | |
1059 int gpu_route_id, | |
1060 int gpu_host_id) { | |
1061 DCHECK(instance_id == instance_id_); | |
1062 if (!compositing_enabled_) | |
1063 EnableCompositing(true); | |
piman
2013/01/09 22:38:57
nit: You can skip the if since it's guarded agains
alexst (slow to review)
2013/01/09 23:16:05
Done.
| |
1064 | |
1065 compositing_helper_->OnBuffersSwapped(size, | |
Fady Samuel
2013/01/09 21:23:38
I don't want to block this patch but I think we ca
alexst (slow to review)
2013/01/09 21:43:39
Sounds good.
| |
1066 mailbox_name, | |
1067 gpu_route_id, | |
1068 gpu_host_id); | |
1069 } | |
1070 | |
1048 } // namespace content | 1071 } // namespace content |
OLD | NEW |