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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 std::map<std::string, base::Value*> props; | 443 std::map<std::string, base::Value*> props; |
444 // Fill in the info provided by the browser. | 444 // Fill in the info provided by the browser. |
445 for (DictionaryValue::Iterator iter(message_info); !iter.IsAtEnd(); | 445 for (DictionaryValue::Iterator iter(message_info); !iter.IsAtEnd(); |
446 iter.Advance()) { | 446 iter.Advance()) { |
447 props[iter.key()] = iter.value().DeepCopy(); | 447 props[iter.key()] = iter.value().DeepCopy(); |
448 } | 448 } |
449 TriggerEvent(browser_plugin::kEventConsoleMessage, &props); | 449 TriggerEvent(browser_plugin::kEventConsoleMessage, &props); |
450 } | 450 } |
451 | 451 |
452 void BrowserPlugin::OnAdvanceFocus(int guest_instance_id, bool reverse) { | 452 void BrowserPlugin::OnAdvanceFocus(int guest_instance_id, bool reverse) { |
453 DCHECK(render_view_); | 453 DCHECK(render_view_.get()); |
454 render_view_->GetWebView()->advanceFocus(reverse); | 454 render_view_->GetWebView()->advanceFocus(reverse); |
455 } | 455 } |
456 | 456 |
457 void BrowserPlugin::OnAttachACK( | 457 void BrowserPlugin::OnAttachACK( |
458 int guest_instance_id, | 458 int guest_instance_id, |
459 const BrowserPluginMsg_Attach_ACK_Params& params) { | 459 const BrowserPluginMsg_Attach_ACK_Params& params) { |
460 // Update BrowserPlugin attributes to match the state of the guest. | 460 // Update BrowserPlugin attributes to match the state of the guest. |
461 if (!params.name.empty()) | 461 if (!params.name.empty()) |
462 OnUpdatedName(guest_instance_id, params.name); | 462 OnUpdatedName(guest_instance_id, params.name); |
463 if (!params.storage_partition_id.empty()) { | 463 if (!params.storage_partition_id.empty()) { |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 // TODO(mthiesse): Handle errors here? | 929 // TODO(mthiesse): Handle errors here? |
930 std::string error; | 930 std::string error; |
931 ParsePartitionAttribute(&error); | 931 ParsePartitionAttribute(&error); |
932 | 932 |
933 // Parse the 'src' attribute last, as it will set the has_navigated_ flag to | 933 // Parse the 'src' attribute last, as it will set the has_navigated_ flag to |
934 // true, which prevents changing the 'partition' attribute. | 934 // true, which prevents changing the 'partition' attribute. |
935 ParseSrcAttribute(&error); | 935 ParseSrcAttribute(&error); |
936 } | 936 } |
937 | 937 |
938 float BrowserPlugin::GetDeviceScaleFactor() const { | 938 float BrowserPlugin::GetDeviceScaleFactor() const { |
939 if (!render_view_) | 939 if (!render_view_.get()) |
940 return 1.0f; | 940 return 1.0f; |
941 return render_view_->GetWebView()->deviceScaleFactor(); | 941 return render_view_->GetWebView()->deviceScaleFactor(); |
942 } | 942 } |
943 | 943 |
944 void BrowserPlugin::UpdateDeviceScaleFactor(float device_scale_factor) { | 944 void BrowserPlugin::UpdateDeviceScaleFactor(float device_scale_factor) { |
945 if (last_device_scale_factor_ == device_scale_factor || !resize_ack_received_) | 945 if (last_device_scale_factor_ == device_scale_factor || !resize_ack_received_) |
946 return; | 946 return; |
947 | 947 |
948 BrowserPluginHostMsg_ResizeGuest_Params params; | 948 BrowserPluginHostMsg_ResizeGuest_Params params; |
949 PopulateResizeGuestParameters(¶ms, plugin_rect()); | 949 PopulateResizeGuestParameters(¶ms, plugin_rect()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 v8::Isolate* isolate, v8::Persistent<v8::Value>* object, void* param) { | 1029 v8::Isolate* isolate, v8::Persistent<v8::Value>* object, void* param) { |
1030 | 1030 |
1031 AliveV8PermissionRequestItem* item_ptr = | 1031 AliveV8PermissionRequestItem* item_ptr = |
1032 static_cast<AliveV8PermissionRequestItem*>(param); | 1032 static_cast<AliveV8PermissionRequestItem*>(param); |
1033 int request_id = item_ptr->first; | 1033 int request_id = item_ptr->first; |
1034 base::WeakPtr<BrowserPlugin> plugin = item_ptr->second; | 1034 base::WeakPtr<BrowserPlugin> plugin = item_ptr->second; |
1035 delete item_ptr; | 1035 delete item_ptr; |
1036 | 1036 |
1037 object->Dispose(); | 1037 object->Dispose(); |
1038 | 1038 |
1039 if (plugin) { | 1039 if (plugin.get()) { |
1040 // Asynchronously remove item from |alive_v8_permission_request_objects_|. | 1040 // Asynchronously remove item from |alive_v8_permission_request_objects_|. |
1041 // Note that we are using weak pointer for the following PostTask, so we | 1041 // Note that we are using weak pointer for the following PostTask, so we |
1042 // don't need to worry about BrowserPlugin going away. | 1042 // don't need to worry about BrowserPlugin going away. |
1043 base::MessageLoop::current()->PostTask( | 1043 base::MessageLoop::current()->PostTask( |
1044 FROM_HERE, | 1044 FROM_HERE, |
1045 base::Bind(&BrowserPlugin::OnRequestObjectGarbageCollected, | 1045 base::Bind(&BrowserPlugin::OnRequestObjectGarbageCollected, |
1046 plugin, | 1046 plugin, |
1047 request_id)); | 1047 request_id)); |
1048 } | 1048 } |
1049 } | 1049 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 return; | 1102 return; |
1103 bool should_be_focused = ShouldGuestBeFocused(); | 1103 bool should_be_focused = ShouldGuestBeFocused(); |
1104 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus( | 1104 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus( |
1105 render_view_routing_id_, | 1105 render_view_routing_id_, |
1106 guest_instance_id_, | 1106 guest_instance_id_, |
1107 should_be_focused)); | 1107 should_be_focused)); |
1108 } | 1108 } |
1109 | 1109 |
1110 bool BrowserPlugin::ShouldGuestBeFocused() const { | 1110 bool BrowserPlugin::ShouldGuestBeFocused() const { |
1111 bool embedder_focused = false; | 1111 bool embedder_focused = false; |
1112 if (render_view_) | 1112 if (render_view_.get()) |
1113 embedder_focused = render_view_->has_focus(); | 1113 embedder_focused = render_view_->has_focus(); |
1114 return plugin_focused_ && embedder_focused; | 1114 return plugin_focused_ && embedder_focused; |
1115 } | 1115 } |
1116 | 1116 |
1117 WebKit::WebPluginContainer* BrowserPlugin::container() const { | 1117 WebKit::WebPluginContainer* BrowserPlugin::container() const { |
1118 return container_; | 1118 return container_; |
1119 } | 1119 } |
1120 | 1120 |
1121 void BrowserPlugin::RespondPermission( | 1121 void BrowserPlugin::RespondPermission( |
1122 BrowserPluginPermissionType permission_type, int request_id, bool allow) { | 1122 BrowserPluginPermissionType permission_type, int request_id, bool allow) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 if (container_) | 1212 if (container_) |
1213 container_->clearScriptObjects(); | 1213 container_->clearScriptObjects(); |
1214 | 1214 |
1215 // The BrowserPlugin's WebPluginContainer is deleted immediately after this | 1215 // The BrowserPlugin's WebPluginContainer is deleted immediately after this |
1216 // call returns, so let's not keep a reference to it around. | 1216 // call returns, so let's not keep a reference to it around. |
1217 g_plugin_container_map.Get().erase(container_); | 1217 g_plugin_container_map.Get().erase(container_); |
1218 container_ = NULL; | 1218 container_ = NULL; |
1219 if (compositing_helper_.get()) | 1219 if (compositing_helper_.get()) |
1220 compositing_helper_->OnContainerDestroy(); | 1220 compositing_helper_->OnContainerDestroy(); |
1221 // Will be a no-op if the mouse is not currently locked. | 1221 // Will be a no-op if the mouse is not currently locked. |
1222 if (render_view_) | 1222 if (render_view_.get()) |
1223 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); | 1223 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); |
1224 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1224 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1225 } | 1225 } |
1226 | 1226 |
1227 NPObject* BrowserPlugin::scriptableObject() { | 1227 NPObject* BrowserPlugin::scriptableObject() { |
1228 if (!bindings_) | 1228 if (!bindings_) |
1229 return NULL; | 1229 return NULL; |
1230 | 1230 |
1231 NPObject* browser_plugin_np_object(bindings_->np_object()); | 1231 NPObject* browser_plugin_np_object(bindings_->np_object()); |
1232 // The object is expected to be retained before it is returned. | 1232 // The object is expected to be retained before it is returned. |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 const WebKit::WebMouseEvent& event) { | 1617 const WebKit::WebMouseEvent& event) { |
1618 browser_plugin_manager()->Send( | 1618 browser_plugin_manager()->Send( |
1619 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1619 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
1620 guest_instance_id_, | 1620 guest_instance_id_, |
1621 plugin_rect_, | 1621 plugin_rect_, |
1622 &event)); | 1622 &event)); |
1623 return true; | 1623 return true; |
1624 } | 1624 } |
1625 | 1625 |
1626 } // namespace content | 1626 } // namespace content |
OLD | NEW |