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

Unified Diff: ppapi/host/ppapi_host.cc

Issue 10803050: Hook up the PPB_Flash_Print interface to new host system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/host/ppapi_host.cc
diff --git a/ppapi/host/ppapi_host.cc b/ppapi/host/ppapi_host.cc
index 87545019e1a88abc7927f3ffa54958487d8fc0f4..d641bd147492ea0c404f19ee90e598513476e161 100644
--- a/ppapi/host/ppapi_host.cc
+++ b/ppapi/host/ppapi_host.cc
@@ -8,6 +8,7 @@
#include "ppapi/c/pp_errors.h"
#include "ppapi/host/host_factory.h"
#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/instance_message_filter.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/resource_message_params.h"
@@ -33,6 +34,9 @@ PpapiHost::PpapiHost(IPC::Sender* sender,
}
PpapiHost::~PpapiHost() {
+ FOR_EACH_OBSERVER(InstanceMessageFilter,
+ instance_message_filters_,
+ CallPpapiHostDestroyed());
}
bool PpapiHost::Send(IPC::Message* msg) {
@@ -50,6 +54,23 @@ bool PpapiHost::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgResourceDestroyed)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
+
+ if (!handled) {
+ // Custom implementation of FOR_EACH_OBSERVER to allow for filter
+ // functionality.
+ if (instance_message_filters_.might_have_observers()) {
+ ObserverListBase<InstanceMessageFilter>::Iterator it(
+ instance_message_filters_);
+ InstanceMessageFilter* obs;
+ while ((obs = it.GetNext()) != NULL) {
+ if (obs->OnInstanceMessageReceived(msg)) {
+ handled = true;
+ break;
+ }
+ }
+ }
+ }
+
return handled;
}
@@ -58,6 +79,15 @@ void PpapiHost::SendReply(const proxy::ResourceMessageReplyParams& params,
Send(new PpapiPluginMsg_ResourceReply(params, msg));
}
+
+void PpapiHost::AddInstanceMessageFilter(InstanceMessageFilter* filter) {
+ instance_message_filters_.AddObserver(filter);
+}
+
+void PpapiHost::RemoveInstanceMessageFilter(InstanceMessageFilter* filter) {
+ instance_message_filters_.RemoveObserver(filter);
+}
+
void PpapiHost::OnHostMsgResourceCall(
const proxy::ResourceMessageCallParams& params,
const IPC::Message& nested_msg) {
@@ -100,8 +130,7 @@ void PpapiHost::OnHostMsgResourceCreated(
return;
scoped_ptr<ResourceHost> resource_host(
- host_factory_->CreateResourceHost(this, params, instance,
- nested_msg));
+ host_factory_->CreateResourceHost(this, params, instance, nested_msg));
if (!resource_host.get()) {
NOTREACHED();
return;

Powered by Google App Engine
This is Rietveld 408576698