Index: content/renderer/pepper/pepper_plugin_delegate_impl.cc |
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc |
index 427af74c99d081004e09de9cc007e99cf83ac605..d805f91f1fa2934e61285263e13fac3170812a86 100644 |
--- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc |
+++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc |
@@ -477,6 +477,7 @@ bool PepperPluginDelegateImpl::StopWaitingForBrokerConnection( |
return true; |
} |
} |
+ |
return false; |
} |
@@ -810,28 +811,53 @@ PepperPluginDelegateImpl::ConnectToBroker( |
webkit::ppapi::PPB_Broker_Impl* client) { |
DCHECK(client); |
- // If a broker needs to be created, this will ensure it does not get deleted |
- // before Connect() adds a reference. |
- scoped_refptr<PepperBrokerImpl> broker_impl; |
- |
webkit::ppapi::PluginModule* plugin_module = |
webkit::ppapi::ResourceHelper::GetPluginModule(client); |
if (!plugin_module) |
return NULL; |
- webkit::ppapi::PluginDelegate::Broker* broker = plugin_module->GetBroker(); |
- if (!broker) { |
- broker_impl = CreateBroker(plugin_module); |
- if (!broker_impl.get()) |
+ scoped_refptr<PepperBrokerImpl> broker = |
+ static_cast<PepperBrokerImpl*>(plugin_module->GetBroker()); |
+ if (!broker.get()) { |
+ broker = CreateBroker(plugin_module); |
+ if (!broker.get()) |
return NULL; |
- broker = broker_impl; |
} |
- // Adds a reference, ensuring not deleted when broker_impl goes out of scope. |
- broker->Connect(client); |
+ int request_id = pending_permission_requests_.Add( |
+ new base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>(client->AsWeakPtr())); |
+ if (!render_view_->Send( |
+ new ViewHostMsg_RequestPpapiBrokerPermission( |
+ render_view_->routing_id(), |
+ request_id, |
+ client->GetDocumentUrl(), |
+ plugin_module->path()))) { |
+ return NULL; |
+ } |
+ |
+ // Adds a reference, ensuring that the broker is not deleted when |
+ // |broker| goes out of scope. |
+ broker->AddPendingConnect(client); |
+ |
return broker; |
} |
+void PepperPluginDelegateImpl::OnPpapiBrokerPermissionResult( |
+ int request_id, |
+ bool result) { |
+ base::WeakPtr<webkit::ppapi::PPB_Broker_Impl> client = |
+ *(pending_permission_requests_.Lookup(request_id)); |
+ if (client) { |
+ webkit::ppapi::PluginModule* plugin_module = |
+ webkit::ppapi::ResourceHelper::GetPluginModule(client); |
brettw
2012/08/20 05:29:47
You may want to null check this. Could the plugin
Bernhard Bauer
2012/08/20 14:43:20
Done. Presumably the client would have gone away a
|
+ PepperBrokerImpl* broker = |
+ static_cast<PepperBrokerImpl*>(plugin_module->GetBroker()); |
+ broker->OnBrokerPermissionResult(client, result); |
+ } |
+ |
+ pending_permission_requests_.Remove(request_id); |
+} |
+ |
bool PepperPluginDelegateImpl::AsyncOpenFile( |
const FilePath& path, |
int flags, |