| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/pepper_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper_plugin_delegate_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 63 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 64 #include "webkit/glue/context_menu.h" | 64 #include "webkit/glue/context_menu.h" |
| 65 #include "webkit/plugins/npapi/webplugin.h" | 65 #include "webkit/plugins/npapi/webplugin.h" |
| 66 #include "webkit/plugins/ppapi/file_path.h" | 66 #include "webkit/plugins/ppapi/file_path.h" |
| 67 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" | 67 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" |
| 68 #include "webkit/plugins/ppapi/plugin_module.h" | 68 #include "webkit/plugins/ppapi/plugin_module.h" |
| 69 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 69 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 70 #include "webkit/plugins/ppapi/ppb_broker_impl.h" | 70 #include "webkit/plugins/ppapi/ppb_broker_impl.h" |
| 71 #include "webkit/plugins/ppapi/ppb_flash_impl.h" | 71 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
| 72 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" | 72 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" |
| 73 #include "webkit/plugins/ppapi/resource_helper.h" |
| 73 #include "webkit/plugins/webplugininfo.h" | 74 #include "webkit/plugins/webplugininfo.h" |
| 74 | 75 |
| 75 using WebKit::WebView; | 76 using WebKit::WebView; |
| 76 | 77 |
| 77 namespace { | 78 namespace { |
| 78 | 79 |
| 79 int32_t PlatformFileToInt(base::PlatformFile handle) { | 80 int32_t PlatformFileToInt(base::PlatformFile handle) { |
| 80 #if defined(OS_WIN) | 81 #if defined(OS_WIN) |
| 81 return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle)); | 82 return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle)); |
| 82 #elif defined(OS_POSIX) | 83 #elif defined(OS_POSIX) |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 base::SyncSocket::Handle plugin_handle = base::kInvalidPlatformFileValue; | 620 base::SyncSocket::Handle plugin_handle = base::kInvalidPlatformFileValue; |
| 620 int32_t result = PP_OK; | 621 int32_t result = PP_OK; |
| 621 | 622 |
| 622 base::SyncSocket* sockets[2] = {0}; | 623 base::SyncSocket* sockets[2] = {0}; |
| 623 if (base::SyncSocket::CreatePair(sockets)) { | 624 if (base::SyncSocket::CreatePair(sockets)) { |
| 624 // The socket objects will be deleted when this function exits, closing the | 625 // The socket objects will be deleted when this function exits, closing the |
| 625 // handles. Any uses of the socket must duplicate them. | 626 // handles. Any uses of the socket must duplicate them. |
| 626 scoped_ptr<base::SyncSocket> broker_socket(sockets[0]); | 627 scoped_ptr<base::SyncSocket> broker_socket(sockets[0]); |
| 627 scoped_ptr<base::SyncSocket> plugin_socket(sockets[1]); | 628 scoped_ptr<base::SyncSocket> plugin_socket(sockets[1]); |
| 628 | 629 |
| 629 result = dispatcher_->SendHandleToBroker(client->instance()->pp_instance(), | 630 result = dispatcher_->SendHandleToBroker(client->pp_instance(), |
| 630 broker_socket->handle()); | 631 broker_socket->handle()); |
| 631 | 632 |
| 632 // If the broker has its pipe handle, duplicate the plugin's handle. | 633 // If the broker has its pipe handle, duplicate the plugin's handle. |
| 633 // Otherwise, the plugin's handle will be automatically closed. | 634 // Otherwise, the plugin's handle will be automatically closed. |
| 634 if (result == PP_OK) | 635 if (result == PP_OK) |
| 635 plugin_handle = DuplicateHandle(plugin_socket->handle()); | 636 plugin_handle = DuplicateHandle(plugin_socket->handle()); |
| 636 } else { | 637 } else { |
| 637 result = PP_ERROR_FAILED; | 638 result = PP_ERROR_FAILED; |
| 638 } | 639 } |
| 639 | 640 |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 // If a broker has not already been created for this plugin, creates one. | 956 // If a broker has not already been created for this plugin, creates one. |
| 956 webkit::ppapi::PluginDelegate::PpapiBroker* | 957 webkit::ppapi::PluginDelegate::PpapiBroker* |
| 957 PepperPluginDelegateImpl::ConnectToPpapiBroker( | 958 PepperPluginDelegateImpl::ConnectToPpapiBroker( |
| 958 webkit::ppapi::PPB_Broker_Impl* client) { | 959 webkit::ppapi::PPB_Broker_Impl* client) { |
| 959 CHECK(client); | 960 CHECK(client); |
| 960 | 961 |
| 961 // If a broker needs to be created, this will ensure it does not get deleted | 962 // If a broker needs to be created, this will ensure it does not get deleted |
| 962 // before Connect() adds a reference. | 963 // before Connect() adds a reference. |
| 963 scoped_refptr<PpapiBrokerImpl> broker_impl; | 964 scoped_refptr<PpapiBrokerImpl> broker_impl; |
| 964 | 965 |
| 965 webkit::ppapi::PluginModule* plugin_module = client->instance()->module(); | 966 webkit::ppapi::PluginModule* plugin_module = |
| 967 webkit::ppapi::ResourceHelper::GetPluginModule(client); |
| 966 PpapiBroker* broker = plugin_module->GetBroker(); | 968 PpapiBroker* broker = plugin_module->GetBroker(); |
| 967 if (!broker) { | 969 if (!broker) { |
| 968 broker_impl = CreatePpapiBroker(plugin_module); | 970 broker_impl = CreatePpapiBroker(plugin_module); |
| 969 if (!broker_impl.get()) | 971 if (!broker_impl.get()) |
| 970 return NULL; | 972 return NULL; |
| 971 broker = broker_impl; | 973 broker = broker_impl; |
| 972 } | 974 } |
| 973 | 975 |
| 974 // Adds a reference, ensuring not deleted when broker_impl goes out of scope. | 976 // Adds a reference, ensuring not deleted when broker_impl goes out of scope. |
| 975 broker->Connect(client); | 977 broker->Connect(client); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1475 | 1477 |
| 1476 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { | 1478 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { |
| 1477 return ppapi::Preferences(render_view_->webkit_preferences()); | 1479 return ppapi::Preferences(render_view_->webkit_preferences()); |
| 1478 } | 1480 } |
| 1479 | 1481 |
| 1480 void PepperPluginDelegateImpl::PublishInitialPolicy( | 1482 void PepperPluginDelegateImpl::PublishInitialPolicy( |
| 1481 scoped_refptr<webkit::ppapi::PluginInstance> instance, | 1483 scoped_refptr<webkit::ppapi::PluginInstance> instance, |
| 1482 const std::string& policy) { | 1484 const std::string& policy) { |
| 1483 instance->HandlePolicyUpdate(policy); | 1485 instance->HandlePolicyUpdate(policy); |
| 1484 } | 1486 } |
| OLD | NEW |