| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } | 496 } |
| 497 | 497 |
| 498 void BrowserPlugin::OnRequestPermission( | 498 void BrowserPlugin::OnRequestPermission( |
| 499 int guest_instance_id, | 499 int guest_instance_id, |
| 500 BrowserPluginPermissionType permission_type, | 500 BrowserPluginPermissionType permission_type, |
| 501 int request_id, | 501 int request_id, |
| 502 const base::DictionaryValue& request_info) { | 502 const base::DictionaryValue& request_info) { |
| 503 // The New Window API is very similiar to the permission API in structure, | 503 // The New Window API is very similiar to the permission API in structure, |
| 504 // but exposes a slightly different interface to the developer and so we put | 504 // but exposes a slightly different interface to the developer and so we put |
| 505 // it in a separate event. | 505 // it in a separate event. |
| 506 const char* event_name = | 506 const char* event_name = NULL; |
| 507 (permission_type == BrowserPluginPermissionTypeNewWindow) ? | 507 if (permission_type == BrowserPluginPermissionTypeNewWindow) { |
| 508 browser_plugin::kEventNewWindow : | 508 event_name = browser_plugin::kEventNewWindow; |
| 509 browser_plugin::kEventRequestPermission; | 509 } else if (permission_type == BrowserPluginPermissionTypeJavaScriptDialog) { |
| 510 | 510 event_name = browser_plugin::kEventDialog; |
| 511 } else { |
| 512 event_name = browser_plugin::kEventRequestPermission; |
| 513 } |
| 511 AddPermissionRequestToSet(request_id); | 514 AddPermissionRequestToSet(request_id); |
| 512 | 515 |
| 513 std::map<std::string, base::Value*> props; | 516 std::map<std::string, base::Value*> props; |
| 514 props[browser_plugin::kPermission] = | 517 props[browser_plugin::kPermission] = |
| 515 base::Value::CreateStringValue(PermissionTypeToString(permission_type)); | 518 base::Value::CreateStringValue(PermissionTypeToString(permission_type)); |
| 516 props[browser_plugin::kRequestId] = | 519 props[browser_plugin::kRequestId] = |
| 517 base::Value::CreateIntegerValue(request_id); | 520 base::Value::CreateIntegerValue(request_id); |
| 518 | 521 |
| 519 // Fill in the info provided by the browser. | 522 // Fill in the info provided by the browser. |
| 520 for (DictionaryValue::Iterator iter(request_info); !iter.IsAtEnd(); | 523 for (DictionaryValue::Iterator iter(request_info); !iter.IsAtEnd(); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 bool embedder_focused = false; | 970 bool embedder_focused = false; |
| 968 if (render_view_.get()) | 971 if (render_view_.get()) |
| 969 embedder_focused = render_view_->has_focus(); | 972 embedder_focused = render_view_->has_focus(); |
| 970 return plugin_focused_ && embedder_focused; | 973 return plugin_focused_ && embedder_focused; |
| 971 } | 974 } |
| 972 | 975 |
| 973 WebKit::WebPluginContainer* BrowserPlugin::container() const { | 976 WebKit::WebPluginContainer* BrowserPlugin::container() const { |
| 974 return container_; | 977 return container_; |
| 975 } | 978 } |
| 976 | 979 |
| 977 void BrowserPlugin::RespondPermission(int request_id, bool allow) { | 980 void BrowserPlugin::RespondPermission( |
| 981 int request_id, bool allow, const std::string& user_input) { |
| 978 browser_plugin_manager()->Send( | 982 browser_plugin_manager()->Send( |
| 979 new BrowserPluginHostMsg_RespondPermission( | 983 new BrowserPluginHostMsg_RespondPermission( |
| 980 render_view_routing_id_, guest_instance_id_, request_id, allow)); | 984 render_view_routing_id_, guest_instance_id_, |
| 985 request_id, allow, user_input)); |
| 981 } | 986 } |
| 982 | 987 |
| 983 void BrowserPlugin::RespondPermissionIfRequestIsPending( | 988 void BrowserPlugin::RespondPermissionIfRequestIsPending( |
| 984 int request_id, bool allow) { | 989 int request_id, bool allow, const std::string& user_input) { |
| 985 PendingPermissionRequests::iterator iter = | 990 PendingPermissionRequests::iterator iter = |
| 986 pending_permission_requests_.find(request_id); | 991 pending_permission_requests_.find(request_id); |
| 987 if (iter == pending_permission_requests_.end()) | 992 if (iter == pending_permission_requests_.end()) |
| 988 return; | 993 return; |
| 989 | 994 |
| 990 pending_permission_requests_.erase(iter); | 995 pending_permission_requests_.erase(iter); |
| 991 RespondPermission(request_id, allow); | 996 RespondPermission(request_id, allow, user_input); |
| 992 } | 997 } |
| 993 | 998 |
| 994 void BrowserPlugin::OnEmbedderDecidedPermission(int request_id, bool allow) { | 999 void BrowserPlugin::OnEmbedderDecidedPermission(int request_id, |
| 995 RespondPermissionIfRequestIsPending(request_id, allow); | 1000 bool allow, |
| 1001 const std::string& user_input) { |
| 1002 RespondPermissionIfRequestIsPending(request_id, allow, user_input); |
| 996 } | 1003 } |
| 997 | 1004 |
| 998 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 1005 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
| 999 if (!container) | 1006 if (!container) |
| 1000 return false; | 1007 return false; |
| 1001 | 1008 |
| 1002 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container)) | 1009 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container)) |
| 1003 return false; | 1010 return false; |
| 1004 | 1011 |
| 1005 // Tell |container| to allow this plugin to use script objects. | 1012 // Tell |container| to allow this plugin to use script objects. |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 const WebKit::WebMouseEvent& event) { | 1464 const WebKit::WebMouseEvent& event) { |
| 1458 browser_plugin_manager()->Send( | 1465 browser_plugin_manager()->Send( |
| 1459 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1466 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
| 1460 guest_instance_id_, | 1467 guest_instance_id_, |
| 1461 plugin_rect_, | 1468 plugin_rect_, |
| 1462 &event)); | 1469 &event)); |
| 1463 return true; | 1470 return true; |
| 1464 } | 1471 } |
| 1465 | 1472 |
| 1466 } // namespace content | 1473 } // namespace content |
| OLD | NEW |