Chromium Code Reviews| 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/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "content/common/browser_plugin_messages.h" | 12 #include "content/common/browser_plugin_messages.h" |
| 13 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
| 14 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
| 15 #include "content/public/renderer/content_renderer_client.h" | 15 #include "content/public/renderer/content_renderer_client.h" |
| 16 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" | 16 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
| 17 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 17 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
| 18 #include "content/renderer/render_process_impl.h" | 18 #include "content/renderer/render_process_impl.h" |
| 19 #include "content/renderer/render_thread_impl.h" | 19 #include "content/renderer/render_thread_impl.h" |
| 20 #include "content/renderer/v8_value_converter_impl.h" | 20 #include "content/renderer/v8_value_converter_impl.h" |
| 21 #include "skia/ext/platform_canvas.h" | 21 #include "skia/ext/platform_canvas.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMCustomEvent.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMCustomEvent.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
| 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | |
| 32 #include "webkit/plugins/sad_plugin.h" | 32 #include "webkit/plugins/sad_plugin.h" |
| 33 | 33 |
| 34 #if defined (OS_WIN) | 34 #if defined (OS_WIN) |
| 35 #include "base/sys_info.h" | 35 #include "base/sys_info.h" |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 using WebKit::WebCanvas; | 38 using WebKit::WebCanvas; |
| 39 using WebKit::WebPluginContainer; | 39 using WebKit::WebPluginContainer; |
| 40 using WebKit::WebPluginParams; | 40 using WebKit::WebPluginParams; |
| 41 using WebKit::WebPoint; | 41 using WebKit::WebPoint; |
| 42 using WebKit::WebRect; | 42 using WebKit::WebRect; |
| 43 using WebKit::WebURL; | 43 using WebKit::WebURL; |
| 44 using WebKit::WebVector; | 44 using WebKit::WebVector; |
| 45 | 45 |
| 46 namespace content { | 46 namespace content { |
| 47 | 47 |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 // Events. | 50 // Events. |
| 51 const char kEventExit[] = "exit"; | 51 const char kEventExit[] = "exit"; |
| 52 const char kEventLoadAbort[] = "loadabort"; | 52 const char kEventLoadAbort[] = "loadabort"; |
| 53 const char kEventLoadCommit[] = "loadcommit"; | 53 const char kEventLoadCommit[] = "loadcommit"; |
| 54 const char kEventLoadRedirect[] = "loadredirect"; | 54 const char kEventLoadRedirect[] = "loadredirect"; |
| 55 const char kEventLoadStart[] = "loadstart"; | 55 const char kEventLoadStart[] = "loadstart"; |
| 56 const char kEventLoadStop[] = "loadstop"; | 56 const char kEventLoadStop[] = "loadstop"; |
| 57 const char kEventRequestPermission[] = "permissionrequest"; | |
| 57 const char kEventSizeChanged[] = "sizechanged"; | 58 const char kEventSizeChanged[] = "sizechanged"; |
| 58 | 59 |
| 59 // Parameters/properties on events. | 60 // Parameters/properties on events. |
| 60 const char kIsTopLevel[] = "isTopLevel"; | 61 const char kIsTopLevel[] = "isTopLevel"; |
| 61 const char kNewURL[] = "newUrl"; | 62 const char kNewURL[] = "newUrl"; |
| 62 const char kNewHeight[] = "newHeight"; | 63 const char kNewHeight[] = "newHeight"; |
| 63 const char kNewWidth[] = "newWidth"; | 64 const char kNewWidth[] = "newWidth"; |
| 64 const char kOldURL[] = "oldUrl"; | 65 const char kOldURL[] = "oldUrl"; |
| 65 const char kOldHeight[] = "oldHeight"; | 66 const char kOldHeight[] = "oldHeight"; |
| 66 const char kOldWidth[] = "oldWidth"; | 67 const char kOldWidth[] = "oldWidth"; |
| 67 const char kPartition[] = "partition"; | 68 const char kPartition[] = "partition"; |
| 69 const char kPermissionTypeMedia[] = "media"; | |
| 68 const char kPersistPrefix[] = "persist:"; | 70 const char kPersistPrefix[] = "persist:"; |
| 69 const char kProcessId[] = "processId"; | 71 const char kProcessId[] = "processId"; |
| 70 const char kReason[] = "reason"; | 72 const char kReason[] = "reason"; |
| 73 const char kRequestId[] = "request_id"; | |
| 71 const char kSrc[] = "src"; | 74 const char kSrc[] = "src"; |
| 72 const char kURL[] = "url"; | 75 const char kURL[] = "url"; |
| 73 | 76 |
| 74 // Error messages. | 77 // Error messages. |
| 75 const char kErrorAlreadyNavigated[] = | 78 const char kErrorAlreadyNavigated[] = |
| 76 "The object has already navigated, so its partition cannot be changed."; | 79 "The object has already navigated, so its partition cannot be changed."; |
| 77 const char kErrorInvalidPartition[] = | 80 const char kErrorInvalidPartition[] = |
| 78 "Invalid partition attribute."; | 81 "Invalid partition attribute."; |
| 79 | 82 |
| 80 static std::string TerminationStatusToString(base::TerminationStatus status) { | 83 static std::string TerminationStatusToString(base::TerminationStatus status) { |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 void BrowserPlugin::LoadAbort(const GURL& url, | 660 void BrowserPlugin::LoadAbort(const GURL& url, |
| 658 bool is_top_level, | 661 bool is_top_level, |
| 659 const std::string& type) { | 662 const std::string& type) { |
| 660 std::map<std::string, base::Value*> props; | 663 std::map<std::string, base::Value*> props; |
| 661 props[kURL] = base::Value::CreateStringValue(url.spec()); | 664 props[kURL] = base::Value::CreateStringValue(url.spec()); |
| 662 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); | 665 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); |
| 663 props[kReason] = base::Value::CreateStringValue(type); | 666 props[kReason] = base::Value::CreateStringValue(type); |
| 664 TriggerEvent(kEventLoadAbort, &props); | 667 TriggerEvent(kEventLoadAbort, &props); |
| 665 } | 668 } |
| 666 | 669 |
| 670 void BrowserPlugin::RequestMediaAccess(int request_id) { | |
| 671 // TODO(lazyboy): Automatically deny the request if there are no event | |
| 672 // listeners for permissionrequest. Right now it is not possible to know about | |
|
Charlie Reis
2012/12/07 19:16:25
So what happens now if there's no listeners? Do w
lazyboy
2012/12/07 22:50:44
When there's no listeners, yes we end up with lost
| |
| 673 // this info directly from the plugin because the user facing event listeners | |
| 674 // are registered on the shim, not on the plugin. Also, there is always one | |
| 675 // listener registered on the plugin from the shim. | |
|
Charlie Reis
2012/12/07 19:16:25
One permissionrequest listener? I'm not sure I fo
lazyboy
2012/12/07 22:50:44
This is the one (and only one) '-internal-permissi
| |
| 676 std::map<std::string, base::Value*> props; | |
| 677 props[kReason] = base::Value::CreateStringValue(kPermissionTypeMedia); | |
| 678 props[kRequestId] = base::Value::CreateIntegerValue(request_id); | |
| 679 TriggerEvent(kEventRequestPermission, &props); | |
| 680 } | |
| 681 | |
| 667 void BrowserPlugin::LoadRedirect(const GURL& old_url, | 682 void BrowserPlugin::LoadRedirect(const GURL& old_url, |
| 668 const GURL& new_url, | 683 const GURL& new_url, |
| 669 bool is_top_level) { | 684 bool is_top_level) { |
| 670 std::map<std::string, base::Value*> props; | 685 std::map<std::string, base::Value*> props; |
| 671 props[kOldURL] = base::Value::CreateStringValue(old_url.spec()); | 686 props[kOldURL] = base::Value::CreateStringValue(old_url.spec()); |
| 672 props[kNewURL] = base::Value::CreateStringValue(new_url.spec()); | 687 props[kNewURL] = base::Value::CreateStringValue(new_url.spec()); |
| 673 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); | 688 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); |
| 674 TriggerEvent(kEventLoadRedirect, &props); | 689 TriggerEvent(kEventLoadRedirect, &props); |
| 675 } | 690 } |
| 676 | 691 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 } | 725 } |
| 711 | 726 |
| 712 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { | 727 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { |
| 713 if (container()) { | 728 if (container()) { |
| 714 container()->requestTouchEventType(accept ? | 729 container()->requestTouchEventType(accept ? |
| 715 WebKit::WebPluginContainer::TouchEventRequestTypeRaw : | 730 WebKit::WebPluginContainer::TouchEventRequestTypeRaw : |
| 716 WebKit::WebPluginContainer::TouchEventRequestTypeNone); | 731 WebKit::WebPluginContainer::TouchEventRequestTypeNone); |
| 717 } | 732 } |
| 718 } | 733 } |
| 719 | 734 |
| 735 void BrowserPlugin::RespondMediaAccess(int request_id, bool allow) { | |
| 736 browser_plugin_manager()->Send( | |
| 737 new BrowserPluginHostMsg_AllowMediaAccess(render_view_->GetRoutingID(), | |
| 738 instance_id_, | |
| 739 request_id, | |
| 740 allow)); | |
| 741 } | |
| 742 | |
| 720 WebKit::WebPluginContainer* BrowserPlugin::container() const { | 743 WebKit::WebPluginContainer* BrowserPlugin::container() const { |
| 721 return container_; | 744 return container_; |
| 722 } | 745 } |
| 723 | 746 |
| 724 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 747 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
| 725 container_ = container; | 748 container_ = container; |
| 726 return true; | 749 return true; |
| 727 } | 750 } |
| 728 | 751 |
| 729 void BrowserPlugin::destroy() { | 752 void BrowserPlugin::destroy() { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1002 void* notify_data) { | 1025 void* notify_data) { |
| 1003 } | 1026 } |
| 1004 | 1027 |
| 1005 void BrowserPlugin::didFailLoadingFrameRequest( | 1028 void BrowserPlugin::didFailLoadingFrameRequest( |
| 1006 const WebKit::WebURL& url, | 1029 const WebKit::WebURL& url, |
| 1007 void* notify_data, | 1030 void* notify_data, |
| 1008 const WebKit::WebURLError& error) { | 1031 const WebKit::WebURLError& error) { |
| 1009 } | 1032 } |
| 1010 | 1033 |
| 1011 } // namespace content | 1034 } // namespace content |
| OLD | NEW |