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.h" | 9 #include "base/message_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 } | 502 } |
503 | 503 |
504 void BrowserPlugin::OnRequestPermission( | 504 void BrowserPlugin::OnRequestPermission( |
505 int guest_instance_id, | 505 int guest_instance_id, |
506 BrowserPluginPermissionType permission_type, | 506 BrowserPluginPermissionType permission_type, |
507 int request_id, | 507 int request_id, |
508 const base::DictionaryValue& request_info) { | 508 const base::DictionaryValue& request_info) { |
509 // The New Window API is very similiar to the permission API in structure, | 509 // The New Window API is very similiar to the permission API in structure, |
510 // but exposes a slightly different interface to the developer and so we put | 510 // but exposes a slightly different interface to the developer and so we put |
511 // it in a separate event. | 511 // it in a separate event. |
512 const char* event_name = | 512 const char* event_name = NULL; |
513 (permission_type == BrowserPluginPermissionTypeNewWindow) ? | 513 if (permission_type == BrowserPluginPermissionTypeNewWindow) { |
514 browser_plugin::kEventNewWindow : | 514 event_name = browser_plugin::kEventNewWindow; |
515 browser_plugin::kEventRequestPermission; | 515 } else if (permission_type == BrowserPluginPermissionTypeJavaScriptDialog) { |
516 | 516 event_name = browser_plugin::kEventDialog; |
| 517 } else { |
| 518 event_name = browser_plugin::kEventRequestPermission; |
| 519 } |
517 AddPermissionRequestToMap(request_id, permission_type); | 520 AddPermissionRequestToMap(request_id, permission_type); |
518 | 521 |
519 std::map<std::string, base::Value*> props; | 522 std::map<std::string, base::Value*> props; |
520 props[browser_plugin::kPermission] = | 523 props[browser_plugin::kPermission] = |
521 base::Value::CreateStringValue(PermissionTypeToString(permission_type)); | 524 base::Value::CreateStringValue(PermissionTypeToString(permission_type)); |
522 props[browser_plugin::kRequestId] = | 525 props[browser_plugin::kRequestId] = |
523 base::Value::CreateIntegerValue(request_id); | 526 base::Value::CreateIntegerValue(request_id); |
524 | 527 |
525 // Fill in the info provided by the browser. | 528 // Fill in the info provided by the browser. |
526 for (DictionaryValue::Iterator iter(request_info); !iter.IsAtEnd(); | 529 for (DictionaryValue::Iterator iter(request_info); !iter.IsAtEnd(); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 if (render_view_.get()) | 967 if (render_view_.get()) |
965 embedder_focused = render_view_->has_focus(); | 968 embedder_focused = render_view_->has_focus(); |
966 return plugin_focused_ && embedder_focused; | 969 return plugin_focused_ && embedder_focused; |
967 } | 970 } |
968 | 971 |
969 WebKit::WebPluginContainer* BrowserPlugin::container() const { | 972 WebKit::WebPluginContainer* BrowserPlugin::container() const { |
970 return container_; | 973 return container_; |
971 } | 974 } |
972 | 975 |
973 void BrowserPlugin::RespondPermission( | 976 void BrowserPlugin::RespondPermission( |
974 BrowserPluginPermissionType permission_type, int request_id, bool allow) { | 977 BrowserPluginPermissionType permission_type, |
| 978 int request_id, |
| 979 bool allow, |
| 980 const std::string& user_input) { |
975 if (permission_type == BrowserPluginPermissionTypePointerLock) | 981 if (permission_type == BrowserPluginPermissionTypePointerLock) |
976 RespondPermissionPointerLock(allow); | 982 RespondPermissionPointerLock(allow); |
977 else | 983 else |
978 browser_plugin_manager()->Send( | 984 browser_plugin_manager()->Send( |
979 new BrowserPluginHostMsg_RespondPermission( | 985 new BrowserPluginHostMsg_RespondPermission( |
980 render_view_routing_id_, guest_instance_id_, permission_type, | 986 render_view_routing_id_, guest_instance_id_, |
981 request_id, allow)); | 987 request_id, allow, user_input)); |
982 } | 988 } |
983 | 989 |
984 void BrowserPlugin::RespondPermissionPointerLock(bool allow) { | 990 void BrowserPlugin::RespondPermissionPointerLock(bool allow) { |
985 if (allow) | 991 if (allow) |
986 render_view_->mouse_lock_dispatcher()->LockMouse(this); | 992 render_view_->mouse_lock_dispatcher()->LockMouse(this); |
987 else | 993 else |
988 OnLockMouseACK(false); | 994 OnLockMouseACK(false); |
989 } | 995 } |
990 | 996 |
991 void BrowserPlugin::RespondPermissionIfRequestIsPending( | 997 void BrowserPlugin::RespondPermissionIfRequestIsPending( |
992 int request_id, bool allow) { | 998 int request_id, bool allow, const std::string& user_input) { |
993 PendingPermissionRequests::iterator iter = | 999 PendingPermissionRequests::iterator iter = |
994 pending_permission_requests_.find(request_id); | 1000 pending_permission_requests_.find(request_id); |
995 if (iter == pending_permission_requests_.end()) | 1001 if (iter == pending_permission_requests_.end()) |
996 return; | 1002 return; |
997 | 1003 |
998 BrowserPluginPermissionType permission_type = iter->second; | 1004 BrowserPluginPermissionType permission_type = iter->second; |
999 pending_permission_requests_.erase(iter); | 1005 pending_permission_requests_.erase(iter); |
1000 RespondPermission(permission_type, request_id, allow); | 1006 RespondPermission(permission_type, request_id, allow, user_input); |
1001 } | 1007 } |
1002 | 1008 |
1003 void BrowserPlugin::OnEmbedderDecidedPermission(int request_id, bool allow) { | 1009 void BrowserPlugin::OnEmbedderDecidedPermission(int request_id, |
1004 RespondPermissionIfRequestIsPending(request_id, allow); | 1010 bool allow, |
| 1011 const std::string& user_input) { |
| 1012 RespondPermissionIfRequestIsPending(request_id, allow, user_input); |
1005 } | 1013 } |
1006 | 1014 |
1007 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 1015 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
1008 if (!container) | 1016 if (!container) |
1009 return false; | 1017 return false; |
1010 | 1018 |
1011 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container)) | 1019 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container)) |
1012 return false; | 1020 return false; |
1013 | 1021 |
1014 // Tell |container| to allow this plugin to use script objects. | 1022 // Tell |container| to allow this plugin to use script objects. |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 const WebKit::WebMouseEvent& event) { | 1471 const WebKit::WebMouseEvent& event) { |
1464 browser_plugin_manager()->Send( | 1472 browser_plugin_manager()->Send( |
1465 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1473 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
1466 guest_instance_id_, | 1474 guest_instance_id_, |
1467 plugin_rect_, | 1475 plugin_rect_, |
1468 &event)); | 1476 &event)); |
1469 return true; | 1477 return true; |
1470 } | 1478 } |
1471 | 1479 |
1472 } // namespace content | 1480 } // namespace content |
OLD | NEW |