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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "extensions/shell/browser/shell_browser_pepper_host_factory.h"
6
7 #include "content/public/browser/browser_ppapi_host.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "ppapi/host/dispatch_host_message.h"
10 #include "ppapi/host/message_filter_host.h"
11 #include "ppapi/host/ppapi_host.h"
12 #include "ppapi/host/resource_host.h"
13 #include "ppapi/host/resource_message_filter.h"
14 #include "ppapi/proxy/ppapi_messages.h"
15 #include "ppapi/shared_impl/ppapi_permissions.h"
16
17 using content::BrowserPpapiHost;
18 using content::BrowserThread;
19 using ppapi::host::HostMessageContext;
20 using ppapi::host::MessageFilterHost;
21 using ppapi::host::ResourceHost;
22 using ppapi::host::ResourceMessageFilter;
23
24 namespace extensions {
25 namespace {
26
27 // This filter handles messages for the PepperBrokerHost on the UI thread.
28 class PepperBrokerMessageFilter : public ResourceMessageFilter {
29 public:
30 PepperBrokerMessageFilter() {}
31
32 private:
33 // Class is ref-counted.
34 virtual ~PepperBrokerMessageFilter() {}
35
36 // ppapi::host::ResourceMessageFilter overrides.
37 virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
38 const IPC::Message& message) OVERRIDE {
39 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
40 }
41
42 virtual int32_t OnResourceMessageReceived(
43 const IPC::Message& msg,
44 HostMessageContext* context) OVERRIDE {
45 PPAPI_BEGIN_MESSAGE_MAP(PepperBrokerMessageFilter, msg)
46 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Broker_IsAllowed,
47 OnIsAllowed)
48 PPAPI_END_MESSAGE_MAP()
49 return PP_ERROR_FAILED;
50 }
51
52 int32_t OnIsAllowed(HostMessageContext* context) {
53 // 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.
54 return PP_OK;
55 }
56
57 DISALLOW_COPY_AND_ASSIGN(PepperBrokerMessageFilter);
58 };
59
60 } // namespace
61
62 ShellBrowserPepperHostFactory::ShellBrowserPepperHostFactory(
63 content::BrowserPpapiHost* host)
64 : host_(host) {
65 }
66
67 ShellBrowserPepperHostFactory::~ShellBrowserPepperHostFactory() {}
68
69 scoped_ptr<ResourceHost> ShellBrowserPepperHostFactory::CreateResourceHost(
70 ppapi::host::PpapiHost* host,
71 const ppapi::proxy::ResourceMessageCallParams& params,
72 PP_Instance instance,
73 const IPC::Message& message) {
74 DCHECK(host == host_->GetPpapiHost());
75
76 // Make sure the plugin is giving us a valid instance for this resource.
77 if (!host_->IsValidInstance(instance))
78 return scoped_ptr<ResourceHost>();
79
80 // Private interfaces.
81 if (host_->GetPpapiHost()->permissions().HasPermission(
82 ppapi::PERMISSION_PRIVATE)) {
83 switch (message.type()) {
84 case PpapiHostMsg_Broker_Create::ID: {
85 scoped_refptr<ResourceMessageFilter> broker_filter(
86 new PepperBrokerMessageFilter);
87 return scoped_ptr<ResourceHost>(
88 new MessageFilterHost(host_->GetPpapiHost(),
89 instance,
90 params.pp_resource(),
91 broker_filter));
92 }
93 }
94 }
95
96 // app_shell does not support the custom messages for:
97 // * Flash
98 // * Android Runtime for Chrome
99 // * Content protected output
100 // * Platform verification
101 // See ChromeBrowserPepperHostFactory for how Chrome handles those.
102 return scoped_ptr<ResourceHost>();
103 }
104
105 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698