| 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_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "content/common/browser_plugin_messages.h" | 11 #include "content/common/browser_plugin_messages.h" |
| 12 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
| 13 #include "content/public/common/content_client.h" | 13 #include "content/public/common/content_client.h" |
| 14 #include "content/public/renderer/content_renderer_client.h" | 14 #include "content/public/renderer/content_renderer_client.h" |
| 15 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" | 15 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
| 16 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 16 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
| 17 #include "content/renderer/render_process_impl.h" | 17 #include "content/renderer/render_process_impl.h" |
| 18 #include "content/renderer/render_thread_impl.h" | 18 #include "content/renderer/render_thread_impl.h" |
| 19 #include "content/renderer/v8_value_converter_impl.h" | 19 #include "content/renderer/v8_value_converter_impl.h" |
| 20 #include "skia/ext/platform_canvas.h" | 20 #include "skia/ext/platform_canvas.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMCustomEvent.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMCustomEvent.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | |
| 31 #include "webkit/plugins/sad_plugin.h" | 31 #include "webkit/plugins/sad_plugin.h" |
| 32 | 32 |
| 33 #if defined (OS_WIN) | 33 #if defined (OS_WIN) |
| 34 #include "base/sys_info.h" | 34 #include "base/sys_info.h" |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 using WebKit::WebCanvas; | 37 using WebKit::WebCanvas; |
| 38 using WebKit::WebPluginContainer; | 38 using WebKit::WebPluginContainer; |
| 39 using WebKit::WebPluginParams; | 39 using WebKit::WebPluginParams; |
| 40 using WebKit::WebPoint; | 40 using WebKit::WebPoint; |
| 41 using WebKit::WebRect; | 41 using WebKit::WebRect; |
| 42 using WebKit::WebURL; | 42 using WebKit::WebURL; |
| 43 using WebKit::WebVector; | 43 using WebKit::WebVector; |
| 44 | 44 |
| 45 namespace content { | 45 namespace content { |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 // Events. | 49 // Events. |
| 50 const char kEventExit[] = "exit"; | 50 const char kEventExit[] = "exit"; |
| 51 const char kEventLoadAbort[] = "loadabort"; | 51 const char kEventLoadAbort[] = "loadabort"; |
| 52 const char kEventLoadCommit[] = "loadcommit"; | 52 const char kEventLoadCommit[] = "loadcommit"; |
| 53 const char kEventLoadRedirect[] = "loadredirect"; | 53 const char kEventLoadRedirect[] = "loadredirect"; |
| 54 const char kEventLoadStart[] = "loadstart"; | 54 const char kEventLoadStart[] = "loadstart"; |
| 55 const char kEventLoadStop[] = "loadstop"; | 55 const char kEventLoadStop[] = "loadstop"; |
| 56 const char kEventRequestPermission[] = "permissionrequest"; |
| 56 const char kEventSizeChanged[] = "sizechanged"; | 57 const char kEventSizeChanged[] = "sizechanged"; |
| 57 | 58 |
| 58 // Parameters/properties on events. | 59 // Parameters/properties on events. |
| 59 const char kIsTopLevel[] = "isTopLevel"; | 60 const char kIsTopLevel[] = "isTopLevel"; |
| 60 const char kNewURL[] = "newUrl"; | 61 const char kNewURL[] = "newUrl"; |
| 61 const char kNewHeight[] = "newHeight"; | 62 const char kNewHeight[] = "newHeight"; |
| 62 const char kNewWidth[] = "newWidth"; | 63 const char kNewWidth[] = "newWidth"; |
| 63 const char kOldURL[] = "oldUrl"; | 64 const char kOldURL[] = "oldUrl"; |
| 64 const char kOldHeight[] = "oldHeight"; | 65 const char kOldHeight[] = "oldHeight"; |
| 65 const char kOldWidth[] = "oldWidth"; | 66 const char kOldWidth[] = "oldWidth"; |
| 66 const char kPartition[] = "partition"; | 67 const char kPartition[] = "partition"; |
| 68 const char kPermissionTypeMedia[] = "media"; |
| 67 const char kPersistPrefix[] = "persist:"; | 69 const char kPersistPrefix[] = "persist:"; |
| 68 const char kProcessId[] = "processId"; | 70 const char kProcessId[] = "processId"; |
| 71 const char kReason[] = "reason"; |
| 72 const char kRequestId[] = "request_id"; |
| 69 const char kSrc[] = "src"; | 73 const char kSrc[] = "src"; |
| 70 const char kReason[] = "reason"; | |
| 71 const char kURL[] = "url"; | 74 const char kURL[] = "url"; |
| 72 | 75 |
| 73 // Error messages. | 76 // Error messages. |
| 74 const char kErrorAlreadyNavigated[] = | 77 const char kErrorAlreadyNavigated[] = |
| 75 "The object has already navigated, so its partition cannot be changed."; | 78 "The object has already navigated, so its partition cannot be changed."; |
| 76 const char kErrorInvalidPartition[] = | 79 const char kErrorInvalidPartition[] = |
| 77 "Invalid partition attribute."; | 80 "Invalid partition attribute."; |
| 78 | 81 |
| 79 static std::string TerminationStatusToString(base::TerminationStatus status) { | 82 static std::string TerminationStatusToString(base::TerminationStatus status) { |
| 80 switch (status) { | 83 switch (status) { |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 void BrowserPlugin::LoadAbort(const GURL& url, | 636 void BrowserPlugin::LoadAbort(const GURL& url, |
| 634 bool is_top_level, | 637 bool is_top_level, |
| 635 const std::string& type) { | 638 const std::string& type) { |
| 636 std::map<std::string, base::Value*> props; | 639 std::map<std::string, base::Value*> props; |
| 637 props[kURL] = base::Value::CreateStringValue(url.spec()); | 640 props[kURL] = base::Value::CreateStringValue(url.spec()); |
| 638 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); | 641 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); |
| 639 props[kReason] = base::Value::CreateStringValue(type); | 642 props[kReason] = base::Value::CreateStringValue(type); |
| 640 TriggerEvent(kEventLoadAbort, &props); | 643 TriggerEvent(kEventLoadAbort, &props); |
| 641 } | 644 } |
| 642 | 645 |
| 646 void BrowserPlugin::RequestMediaAccess(int request_id) { |
| 647 std::map<std::string, base::Value*> props; |
| 648 props[kReason] = base::Value::CreateStringValue(kPermissionTypeMedia); |
| 649 props[kRequestId] = base::Value::CreateIntegerValue(request_id); |
| 650 TriggerEvent(kEventRequestPermission, &props); |
| 651 } |
| 652 |
| 643 void BrowserPlugin::LoadRedirect(const GURL& old_url, | 653 void BrowserPlugin::LoadRedirect(const GURL& old_url, |
| 644 const GURL& new_url, | 654 const GURL& new_url, |
| 645 bool is_top_level) { | 655 bool is_top_level) { |
| 646 std::map<std::string, base::Value*> props; | 656 std::map<std::string, base::Value*> props; |
| 647 props[kOldURL] = base::Value::CreateStringValue(old_url.spec()); | 657 props[kOldURL] = base::Value::CreateStringValue(old_url.spec()); |
| 648 props[kNewURL] = base::Value::CreateStringValue(new_url.spec()); | 658 props[kNewURL] = base::Value::CreateStringValue(new_url.spec()); |
| 649 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); | 659 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); |
| 650 TriggerEvent(kEventLoadRedirect, &props); | 660 TriggerEvent(kEventLoadRedirect, &props); |
| 651 } | 661 } |
| 652 | 662 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 } | 696 } |
| 687 | 697 |
| 688 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { | 698 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { |
| 689 if (container()) { | 699 if (container()) { |
| 690 container()->requestTouchEventType(accept ? | 700 container()->requestTouchEventType(accept ? |
| 691 WebKit::WebPluginContainer::TouchEventRequestTypeRaw : | 701 WebKit::WebPluginContainer::TouchEventRequestTypeRaw : |
| 692 WebKit::WebPluginContainer::TouchEventRequestTypeNone); | 702 WebKit::WebPluginContainer::TouchEventRequestTypeNone); |
| 693 } | 703 } |
| 694 } | 704 } |
| 695 | 705 |
| 706 void BrowserPlugin::RespondMediaAccess(int request_id, bool allow) { |
| 707 browser_plugin_manager()->Send( |
| 708 new BrowserPluginHostMsg_AllowMediaAccess(render_view_->GetRoutingID(), |
| 709 instance_id_, |
| 710 request_id, |
| 711 allow)); |
| 712 } |
| 713 |
| 696 WebKit::WebPluginContainer* BrowserPlugin::container() const { | 714 WebKit::WebPluginContainer* BrowserPlugin::container() const { |
| 697 return container_; | 715 return container_; |
| 698 } | 716 } |
| 699 | 717 |
| 700 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 718 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
| 701 container_ = container; | 719 container_ = container; |
| 702 return true; | 720 return true; |
| 703 } | 721 } |
| 704 | 722 |
| 705 void BrowserPlugin::destroy() { | 723 void BrowserPlugin::destroy() { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 void* notify_data) { | 996 void* notify_data) { |
| 979 } | 997 } |
| 980 | 998 |
| 981 void BrowserPlugin::didFailLoadingFrameRequest( | 999 void BrowserPlugin::didFailLoadingFrameRequest( |
| 982 const WebKit::WebURL& url, | 1000 const WebKit::WebURL& url, |
| 983 void* notify_data, | 1001 void* notify_data, |
| 984 const WebKit::WebURLError& error) { | 1002 const WebKit::WebURLError& error) { |
| 985 } | 1003 } |
| 986 | 1004 |
| 987 } // namespace content | 1005 } // namespace content |
| OLD | NEW |