Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: content/renderer/pepper/pepper_plugin_delegate_impl.cc

Issue 10854040: Add hooks to content to request permission to connect to the PPAPI broker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/pepper/pepper_plugin_delegate_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <cstddef> 8 #include <cstddef>
9 #include <map> 9 #include <map>
10 #include <queue> 10 #include <queue>
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 const FilePath& broker_path = plugin_module->path(); 406 const FilePath& broker_path = plugin_module->path();
407 407
408 scoped_refptr<PepperBrokerImpl> broker = 408 scoped_refptr<PepperBrokerImpl> broker =
409 new PepperBrokerImpl(plugin_module, this); 409 new PepperBrokerImpl(plugin_module, this);
410 410
411 int request_id = 411 int request_id =
412 pending_connect_broker_.Add(new scoped_refptr<PepperBrokerImpl>(broker)); 412 pending_connect_broker_.Add(new scoped_refptr<PepperBrokerImpl>(broker));
413 413
414 // Have the browser start the broker process for us. 414 // Have the browser start the broker process for us.
415 IPC::Message* msg = 415 IPC::Message* msg =
416 new ViewHostMsg_OpenChannelToPpapiBroker(render_view_->routing_id(), 416 new ViewHostMsg_OpenChannelToPpapiBroker(render_view_->routing_id(),
ddorwin 2012/08/12 22:51:16 Ideally, this would cause the user prompt. Instant
Bernhard Bauer 2012/08/13 09:02:12 I guess that would mean using a new channel for ev
ddorwin 2012/08/13 22:27:04 You would need to somehow be able to refcount the
417 request_id, 417 request_id,
418 broker_path); 418 broker_path);
419 if (!render_view_->Send(msg)) { 419 if (!render_view_->Send(msg)) {
420 pending_connect_broker_.Remove(request_id); 420 pending_connect_broker_.Remove(request_id);
421 return scoped_refptr<PepperBrokerImpl>(); 421 return scoped_refptr<PepperBrokerImpl>();
422 } 422 }
423 423
424 return broker; 424 return broker;
425 } 425 }
426 426
(...skipping 21 matching lines...) Expand all
448 // the raw pointer to the broker. Assumes maximum of one copy of broker exists. 448 // the raw pointer to the broker. Assumes maximum of one copy of broker exists.
449 bool PepperPluginDelegateImpl::StopWaitingForBrokerConnection( 449 bool PepperPluginDelegateImpl::StopWaitingForBrokerConnection(
450 PepperBrokerImpl* broker) { 450 PepperBrokerImpl* broker) {
451 for (BrokerMap::iterator i(&pending_connect_broker_); 451 for (BrokerMap::iterator i(&pending_connect_broker_);
452 !i.IsAtEnd(); i.Advance()) { 452 !i.IsAtEnd(); i.Advance()) {
453 if (i.GetCurrentValue()->get() == broker) { 453 if (i.GetCurrentValue()->get() == broker) {
454 pending_connect_broker_.Remove(i.GetCurrentKey()); 454 pending_connect_broker_.Remove(i.GetCurrentKey());
455 return true; 455 return true;
456 } 456 }
457 } 457 }
458
458 return false; 459 return false;
459 } 460 }
460 461
461 void PepperPluginDelegateImpl::ViewWillInitiatePaint() { 462 void PepperPluginDelegateImpl::ViewWillInitiatePaint() {
462 // Notify all of our instances that we started painting. This is used for 463 // Notify all of our instances that we started painting. This is used for
463 // internal bookkeeping only, so we know that the set can not change under 464 // internal bookkeeping only, so we know that the set can not change under
464 // us. 465 // us.
465 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = 466 for (std::set<webkit::ppapi::PluginInstance*>::iterator i =
466 active_instances_.begin(); 467 active_instances_.begin();
467 i != active_instances_.end(); ++i) 468 i != active_instances_.end(); ++i)
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 AsWeakPtr(), device_id, static_cast<int>(sample_rate), 782 AsWeakPtr(), device_id, static_cast<int>(sample_rate),
782 static_cast<int>(sample_count), client); 783 static_cast<int>(sample_count), client);
783 } 784 }
784 785
785 // If a broker has not already been created for this plugin, creates one. 786 // If a broker has not already been created for this plugin, creates one.
786 webkit::ppapi::PluginDelegate::Broker* 787 webkit::ppapi::PluginDelegate::Broker*
787 PepperPluginDelegateImpl::ConnectToBroker( 788 PepperPluginDelegateImpl::ConnectToBroker(
788 webkit::ppapi::PPB_Broker_Impl* client) { 789 webkit::ppapi::PPB_Broker_Impl* client) {
789 DCHECK(client); 790 DCHECK(client);
790 791
791 // If a broker needs to be created, this will ensure it does not get deleted
792 // before Connect() adds a reference.
793 scoped_refptr<PepperBrokerImpl> broker_impl;
794
795 webkit::ppapi::PluginModule* plugin_module = 792 webkit::ppapi::PluginModule* plugin_module =
796 webkit::ppapi::ResourceHelper::GetPluginModule(client); 793 webkit::ppapi::ResourceHelper::GetPluginModule(client);
797 if (!plugin_module) 794 if (!plugin_module)
798 return NULL; 795 return NULL;
799 796
800 webkit::ppapi::PluginDelegate::Broker* broker = plugin_module->GetBroker(); 797 scoped_refptr<PepperBrokerImpl> broker =
801 if (!broker) { 798 static_cast<PepperBrokerImpl*>(plugin_module->GetBroker());
802 broker_impl = CreateBroker(plugin_module); 799 if (!broker.get()) {
803 if (!broker_impl.get()) 800 broker = CreateBroker(plugin_module);
801 if (!broker.get())
804 return NULL; 802 return NULL;
805 broker = broker_impl;
806 } 803 }
807 804
808 // Adds a reference, ensuring not deleted when broker_impl goes out of scope. 805 int request_id = pending_permission_requests_.Add(
806 new base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>(client->AsWeakPtr()));
807 if (!render_view_->Send(
808 new ViewHostMsg_RequestPpapiBrokerPermission(
ddorwin 2012/08/12 22:51:16 Ideally, this would instantiate the broker if nece
809 render_view_->routing_id(),
810 request_id,
811 client->GetDocumentUrl(),
812 plugin_module->path()))) {
813 return NULL;
814 }
815
816 // Adds a reference, ensuring that the broker is not deleted when
817 // |broker| goes out of scope.
809 broker->Connect(client); 818 broker->Connect(client);
819
810 return broker; 820 return broker;
811 } 821 }
812 822
823 void PepperPluginDelegateImpl::OnPpapiBrokerPermissionResult(
824 int request_id,
825 bool result) {
826 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl> client =
827 *(pending_permission_requests_.Lookup(request_id));
828 if (client) {
829 webkit::ppapi::PluginModule* plugin_module =
830 webkit::ppapi::ResourceHelper::GetPluginModule(client);
831 PepperBrokerImpl* broker =
832 static_cast<PepperBrokerImpl*>(plugin_module->GetBroker());
833 broker->OnBrokerPermissionResult(client, result);
834 }
835
836 pending_permission_requests_.Remove(request_id);
837 }
838
813 bool PepperPluginDelegateImpl::AsyncOpenFile( 839 bool PepperPluginDelegateImpl::AsyncOpenFile(
814 const FilePath& path, 840 const FilePath& path,
815 int flags, 841 int flags,
816 const AsyncOpenFileCallback& callback) { 842 const AsyncOpenFileCallback& callback) {
817 int message_id = pending_async_open_files_.Add( 843 int message_id = pending_async_open_files_.Add(
818 new AsyncOpenFileCallback(callback)); 844 new AsyncOpenFileCallback(callback));
819 IPC::Message* msg = new ViewHostMsg_AsyncOpenFile( 845 IPC::Message* msg = new ViewHostMsg_AsyncOpenFile(
820 render_view_->routing_id(), path, flags, message_id); 846 render_view_->routing_id(), path, flags, message_id);
821 return render_view_->Send(msg); 847 return render_view_->Send(msg);
822 } 848 }
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 else 1803 else
1778 return render_view_->mouse_lock_dispatcher(); 1804 return render_view_->mouse_lock_dispatcher();
1779 } 1805 }
1780 1806
1781 webkit_glue::ClipboardClient* 1807 webkit_glue::ClipboardClient*
1782 PepperPluginDelegateImpl::CreateClipboardClient() const { 1808 PepperPluginDelegateImpl::CreateClipboardClient() const {
1783 return new RendererClipboardClient; 1809 return new RendererClipboardClient;
1784 } 1810 }
1785 1811
1786 } // namespace content 1812 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698