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

Unified Diff: extensions/shell/browser/shell_browser_pepper_host_factory.cc

Issue 437503004: Add NaCl support to app_shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (nacl-init) rebase Created 6 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 side-by-side diff with in-line comments
Download patch
Index: extensions/shell/browser/shell_browser_pepper_host_factory.cc
diff --git a/extensions/shell/browser/shell_browser_pepper_host_factory.cc b/extensions/shell/browser/shell_browser_pepper_host_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f9d4e010f791553c1c68edd562cf9bf188550f75
--- /dev/null
+++ b/extensions/shell/browser/shell_browser_pepper_host_factory.cc
@@ -0,0 +1,105 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "extensions/shell/browser/shell_browser_pepper_host_factory.h"
+
+#include "content/public/browser/browser_ppapi_host.h"
+#include "content/public/browser/browser_thread.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/message_filter_host.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/host/resource_message_filter.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/ppapi_permissions.h"
+
+using content::BrowserPpapiHost;
+using content::BrowserThread;
+using ppapi::host::HostMessageContext;
+using ppapi::host::MessageFilterHost;
+using ppapi::host::ResourceHost;
+using ppapi::host::ResourceMessageFilter;
+
+namespace extensions {
+namespace {
+
+// This filter handles messages for the PepperBrokerHost on the UI thread.
+class PepperBrokerMessageFilter : public ResourceMessageFilter {
+ public:
+ PepperBrokerMessageFilter() {}
+
+ private:
+ // Class is ref-counted.
+ virtual ~PepperBrokerMessageFilter() {}
+
+ // ppapi::host::ResourceMessageFilter overrides.
+ virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
+ const IPC::Message& message) OVERRIDE {
+ return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
+ }
+
+ virtual int32_t OnResourceMessageReceived(
+ const IPC::Message& msg,
+ HostMessageContext* context) OVERRIDE {
+ PPAPI_BEGIN_MESSAGE_MAP(PepperBrokerMessageFilter, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Broker_IsAllowed,
+ OnIsAllowed)
+ PPAPI_END_MESSAGE_MAP()
+ return PP_ERROR_FAILED;
+ }
+
+ int32_t OnIsAllowed(HostMessageContext* context) {
+ // app_shell always allows access to private APIs.
teravest 2014/08/12 15:48:31 I don't understand this comment. PpapiHostMsg_Bro
James Cook 2014/08/12 18:17:06 Yeah, I don't need this at all. Removed.
+ return PP_OK;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(PepperBrokerMessageFilter);
+};
+
+} // namespace
+
+ShellBrowserPepperHostFactory::ShellBrowserPepperHostFactory(
+ content::BrowserPpapiHost* host)
+ : host_(host) {
+}
+
+ShellBrowserPepperHostFactory::~ShellBrowserPepperHostFactory() {}
+
+scoped_ptr<ResourceHost> ShellBrowserPepperHostFactory::CreateResourceHost(
+ ppapi::host::PpapiHost* host,
+ const ppapi::proxy::ResourceMessageCallParams& params,
+ PP_Instance instance,
+ const IPC::Message& message) {
+ DCHECK(host == host_->GetPpapiHost());
+
+ // Make sure the plugin is giving us a valid instance for this resource.
+ if (!host_->IsValidInstance(instance))
+ return scoped_ptr<ResourceHost>();
+
+ // Private interfaces.
+ if (host_->GetPpapiHost()->permissions().HasPermission(
+ ppapi::PERMISSION_PRIVATE)) {
+ switch (message.type()) {
+ case PpapiHostMsg_Broker_Create::ID: {
+ scoped_refptr<ResourceMessageFilter> broker_filter(
+ new PepperBrokerMessageFilter);
+ return scoped_ptr<ResourceHost>(
+ new MessageFilterHost(host_->GetPpapiHost(),
+ instance,
+ params.pp_resource(),
+ broker_filter));
+ }
+ }
+ }
+
+ // app_shell does not support the custom messages for:
+ // * Flash
+ // * Android Runtime for Chrome
+ // * Content protected output
+ // * Platform verification
+ // See ChromeBrowserPepperHostFactory for how Chrome handles those.
+ return scoped_ptr<ResourceHost>();
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698