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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 // Schedule a SizeChanged instead of calling it directly to ensure that | 725 // Schedule a SizeChanged instead of calling it directly to ensure that |
726 // the backing store has been updated before the developer attempts to | 726 // the backing store has been updated before the developer attempts to |
727 // resize to avoid flicker. |size_changed_in_flight_| acts as a form of | 727 // resize to avoid flicker. |size_changed_in_flight_| acts as a form of |
728 // flow control for SizeChanged events. If the guest's view size is changing | 728 // flow control for SizeChanged events. If the guest's view size is changing |
729 // rapidly before a SizeChanged event fires, then we avoid scheduling | 729 // rapidly before a SizeChanged event fires, then we avoid scheduling |
730 // another SizeChanged event. SizeChanged reads the new size from | 730 // another SizeChanged event. SizeChanged reads the new size from |
731 // |last_view_size_| so we can be sure that it always fires an event | 731 // |last_view_size_| so we can be sure that it always fires an event |
732 // with the last seen view size. | 732 // with the last seen view size. |
733 if (container_ && !size_changed_in_flight_) { | 733 if (container_ && !size_changed_in_flight_) { |
734 size_changed_in_flight_ = true; | 734 size_changed_in_flight_ = true; |
735 MessageLoop::current()->PostTask( | 735 base::MessageLoop::current()->PostTask( |
736 FROM_HERE, | 736 FROM_HERE, |
737 base::Bind(&BrowserPlugin::SizeChangedDueToAutoSize, | 737 base::Bind(&BrowserPlugin::SizeChangedDueToAutoSize, |
738 base::Unretained(this), | 738 base::Unretained(this), |
739 old_view_size)); | 739 old_view_size)); |
740 } | 740 } |
741 } | 741 } |
742 | 742 |
743 // No more work to do since the guest is no longer using a damage buffer. | 743 // No more work to do since the guest is no longer using a damage buffer. |
744 if (!UsesDamageBuffer(params)) | 744 if (!UsesDamageBuffer(params)) |
745 return; | 745 return; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 base::WeakPtr<BrowserPlugin> plugin = item_ptr->second; | 1005 base::WeakPtr<BrowserPlugin> plugin = item_ptr->second; |
1006 delete item_ptr; | 1006 delete item_ptr; |
1007 | 1007 |
1008 persistent_object.Dispose(isolate); | 1008 persistent_object.Dispose(isolate); |
1009 persistent_object.Clear(); | 1009 persistent_object.Clear(); |
1010 | 1010 |
1011 if (plugin) { | 1011 if (plugin) { |
1012 // Asynchronously remove item from |alive_v8_permission_request_objects_|. | 1012 // Asynchronously remove item from |alive_v8_permission_request_objects_|. |
1013 // Note that we are using weak pointer for the following PostTask, so we | 1013 // Note that we are using weak pointer for the following PostTask, so we |
1014 // don't need to worry about BrowserPlugin going away. | 1014 // don't need to worry about BrowserPlugin going away. |
1015 MessageLoop::current()->PostTask( | 1015 base::MessageLoop::current()->PostTask( |
1016 FROM_HERE, | 1016 FROM_HERE, |
1017 base::Bind(&BrowserPlugin::OnRequestObjectGarbageCollected, | 1017 base::Bind(&BrowserPlugin::OnRequestObjectGarbageCollected, |
1018 plugin, request_id)); | 1018 plugin, |
| 1019 request_id)); |
1019 } | 1020 } |
1020 } | 1021 } |
1021 | 1022 |
1022 void BrowserPlugin::Back() { | 1023 void BrowserPlugin::Back() { |
1023 if (!HasGuest()) | 1024 if (!HasGuest()) |
1024 return; | 1025 return; |
1025 browser_plugin_manager()->Send( | 1026 browser_plugin_manager()->Send( |
1026 new BrowserPluginHostMsg_Go(render_view_routing_id_, | 1027 new BrowserPluginHostMsg_Go(render_view_routing_id_, |
1027 instance_id_, -1)); | 1028 instance_id_, -1)); |
1028 } | 1029 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 void BrowserPlugin::destroy() { | 1176 void BrowserPlugin::destroy() { |
1176 // The BrowserPlugin's WebPluginContainer is deleted immediately after this | 1177 // The BrowserPlugin's WebPluginContainer is deleted immediately after this |
1177 // call returns, so let's not keep a reference to it around. | 1178 // call returns, so let's not keep a reference to it around. |
1178 g_plugin_container_map.Get().erase(container_); | 1179 g_plugin_container_map.Get().erase(container_); |
1179 container_ = NULL; | 1180 container_ = NULL; |
1180 if (compositing_helper_) | 1181 if (compositing_helper_) |
1181 compositing_helper_->OnContainerDestroy(); | 1182 compositing_helper_->OnContainerDestroy(); |
1182 // Will be a no-op if the mouse is not currently locked. | 1183 // Will be a no-op if the mouse is not currently locked. |
1183 if (render_view_) | 1184 if (render_view_) |
1184 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); | 1185 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); |
1185 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1186 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1186 } | 1187 } |
1187 | 1188 |
1188 NPObject* BrowserPlugin::scriptableObject() { | 1189 NPObject* BrowserPlugin::scriptableObject() { |
1189 if (!bindings_) | 1190 if (!bindings_) |
1190 return NULL; | 1191 return NULL; |
1191 | 1192 |
1192 NPObject* browser_plugin_np_object(bindings_->np_object()); | 1193 NPObject* browser_plugin_np_object(bindings_->np_object()); |
1193 // The object is expected to be retained before it is returned. | 1194 // The object is expected to be retained before it is returned. |
1194 WebKit::WebBindings::retainObject(browser_plugin_np_object); | 1195 WebKit::WebBindings::retainObject(browser_plugin_np_object); |
1195 return browser_plugin_np_object; | 1196 return browser_plugin_np_object; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 const WebKit::WebMouseEvent& event) { | 1546 const WebKit::WebMouseEvent& event) { |
1546 browser_plugin_manager()->Send( | 1547 browser_plugin_manager()->Send( |
1547 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1548 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
1548 instance_id_, | 1549 instance_id_, |
1549 plugin_rect_, | 1550 plugin_rect_, |
1550 &event)); | 1551 &event)); |
1551 return true; | 1552 return true; |
1552 } | 1553 } |
1553 | 1554 |
1554 } // namespace content | 1555 } // namespace content |
OLD | NEW |