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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 case BrowserPluginPermissionTypeDownload: | 64 case BrowserPluginPermissionTypeDownload: |
65 return browser_plugin::kPermissionTypeDownload; | 65 return browser_plugin::kPermissionTypeDownload; |
66 case BrowserPluginPermissionTypeGeolocation: | 66 case BrowserPluginPermissionTypeGeolocation: |
67 return browser_plugin::kPermissionTypeGeolocation; | 67 return browser_plugin::kPermissionTypeGeolocation; |
68 case BrowserPluginPermissionTypeMedia: | 68 case BrowserPluginPermissionTypeMedia: |
69 return browser_plugin::kPermissionTypeMedia; | 69 return browser_plugin::kPermissionTypeMedia; |
70 case BrowserPluginPermissionTypeNewWindow: | 70 case BrowserPluginPermissionTypeNewWindow: |
71 return browser_plugin::kPermissionTypeNewWindow; | 71 return browser_plugin::kPermissionTypeNewWindow; |
72 case BrowserPluginPermissionTypePointerLock: | 72 case BrowserPluginPermissionTypePointerLock: |
73 return browser_plugin::kPermissionTypePointerLock; | 73 return browser_plugin::kPermissionTypePointerLock; |
| 74 case BrowserPluginPermissionTypeJavaScriptDialog: |
| 75 return browser_plugin::kPermissionTypeDialog; |
74 case BrowserPluginPermissionTypeUnknown: | 76 case BrowserPluginPermissionTypeUnknown: |
75 default: | 77 default: |
76 NOTREACHED(); | 78 NOTREACHED(); |
77 break; | 79 break; |
78 } | 80 } |
79 return std::string(); | 81 return std::string(); |
80 } | 82 } |
81 | 83 |
82 typedef std::map<WebKit::WebPluginContainer*, | 84 typedef std::map<WebKit::WebPluginContainer*, |
83 BrowserPlugin*> PluginContainerMap; | 85 BrowserPlugin*> PluginContainerMap; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 } | 498 } |
497 | 499 |
498 void BrowserPlugin::OnRequestPermission( | 500 void BrowserPlugin::OnRequestPermission( |
499 int guest_instance_id, | 501 int guest_instance_id, |
500 BrowserPluginPermissionType permission_type, | 502 BrowserPluginPermissionType permission_type, |
501 int request_id, | 503 int request_id, |
502 const base::DictionaryValue& request_info) { | 504 const base::DictionaryValue& request_info) { |
503 // The New Window API is very similiar to the permission API in structure, | 505 // 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 | 506 // but exposes a slightly different interface to the developer and so we put |
505 // it in a separate event. | 507 // it in a separate event. |
506 const char* event_name = | 508 const char* event_name = NULL; |
507 (permission_type == BrowserPluginPermissionTypeNewWindow) ? | 509 if (permission_type == BrowserPluginPermissionTypeNewWindow) { |
508 browser_plugin::kEventNewWindow : | 510 event_name = browser_plugin::kEventNewWindow; |
509 browser_plugin::kEventRequestPermission; | 511 } else if (permission_type == BrowserPluginPermissionTypeJavaScriptDialog) { |
510 | 512 event_name = browser_plugin::kEventDialog; |
| 513 } else { |
| 514 event_name = browser_plugin::kEventRequestPermission; |
| 515 } |
511 AddPermissionRequestToSet(request_id); | 516 AddPermissionRequestToSet(request_id); |
512 | 517 |
513 std::map<std::string, base::Value*> props; | 518 std::map<std::string, base::Value*> props; |
514 props[browser_plugin::kPermission] = | 519 props[browser_plugin::kPermission] = |
515 base::Value::CreateStringValue(PermissionTypeToString(permission_type)); | 520 base::Value::CreateStringValue(PermissionTypeToString(permission_type)); |
516 props[browser_plugin::kRequestId] = | 521 props[browser_plugin::kRequestId] = |
517 base::Value::CreateIntegerValue(request_id); | 522 base::Value::CreateIntegerValue(request_id); |
518 | 523 |
519 // Fill in the info provided by the browser. | 524 // Fill in the info provided by the browser. |
520 for (DictionaryValue::Iterator iter(request_info); !iter.IsAtEnd(); | 525 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; | 972 bool embedder_focused = false; |
968 if (render_view_.get()) | 973 if (render_view_.get()) |
969 embedder_focused = render_view_->has_focus(); | 974 embedder_focused = render_view_->has_focus(); |
970 return plugin_focused_ && embedder_focused; | 975 return plugin_focused_ && embedder_focused; |
971 } | 976 } |
972 | 977 |
973 WebKit::WebPluginContainer* BrowserPlugin::container() const { | 978 WebKit::WebPluginContainer* BrowserPlugin::container() const { |
974 return container_; | 979 return container_; |
975 } | 980 } |
976 | 981 |
977 void BrowserPlugin::RespondPermission(int request_id, bool allow) { | 982 void BrowserPlugin::RespondPermission( |
| 983 int request_id, bool allow, const std::string& user_input) { |
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_, request_id, allow)); | 986 render_view_routing_id_, guest_instance_id_, |
| 987 request_id, allow, user_input)); |
981 } | 988 } |
982 | 989 |
983 void BrowserPlugin::RespondPermissionIfRequestIsPending( | 990 void BrowserPlugin::RespondPermissionIfRequestIsPending( |
984 int request_id, bool allow) { | 991 int request_id, bool allow, const std::string& user_input) { |
985 PendingPermissionRequests::iterator iter = | 992 PendingPermissionRequests::iterator iter = |
986 pending_permission_requests_.find(request_id); | 993 pending_permission_requests_.find(request_id); |
987 if (iter == pending_permission_requests_.end()) | 994 if (iter == pending_permission_requests_.end()) |
988 return; | 995 return; |
989 | 996 |
990 pending_permission_requests_.erase(iter); | 997 pending_permission_requests_.erase(iter); |
991 RespondPermission(request_id, allow); | 998 RespondPermission(request_id, allow, user_input); |
992 } | 999 } |
993 | 1000 |
994 void BrowserPlugin::OnEmbedderDecidedPermission(int request_id, bool allow) { | 1001 void BrowserPlugin::OnEmbedderDecidedPermission(int request_id, |
995 RespondPermissionIfRequestIsPending(request_id, allow); | 1002 bool allow, |
| 1003 const std::string& user_input) { |
| 1004 RespondPermissionIfRequestIsPending(request_id, allow, user_input); |
996 } | 1005 } |
997 | 1006 |
998 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 1007 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
999 if (!container) | 1008 if (!container) |
1000 return false; | 1009 return false; |
1001 | 1010 |
1002 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container)) | 1011 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container)) |
1003 return false; | 1012 return false; |
1004 | 1013 |
1005 // Tell |container| to allow this plugin to use script objects. | 1014 // 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) { | 1466 const WebKit::WebMouseEvent& event) { |
1458 browser_plugin_manager()->Send( | 1467 browser_plugin_manager()->Send( |
1459 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1468 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
1460 guest_instance_id_, | 1469 guest_instance_id_, |
1461 plugin_rect_, | 1470 plugin_rect_, |
1462 &event)); | 1471 &event)); |
1463 return true; | 1472 return true; |
1464 } | 1473 } |
1465 | 1474 |
1466 } // namespace content | 1475 } // namespace content |
OLD | NEW |