| OLD | NEW |
| 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 // Need to include this before most other files because it defines | 9 // Need to include this before most other files because it defines |
| 10 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define | 10 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 virtual IPC::Sender* GetBrowserSender() OVERRIDE; | 69 virtual IPC::Sender* GetBrowserSender() OVERRIDE; |
| 70 virtual std::string GetUILanguage() OVERRIDE; | 70 virtual std::string GetUILanguage() OVERRIDE; |
| 71 virtual void PreCacheFont(const void* logfontw) OVERRIDE; | 71 virtual void PreCacheFont(const void* logfontw) OVERRIDE; |
| 72 virtual void SetActiveURL(const std::string& url) OVERRIDE; | 72 virtual void SetActiveURL(const std::string& url) OVERRIDE; |
| 73 | 73 |
| 74 // IPC::Listener implementation. | 74 // IPC::Listener implementation. |
| 75 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 75 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 void OnMsgCreateNaClChannel(int renderer_id, | 78 void OnMsgCreateNaClChannel(int renderer_id, |
| 79 const ppapi::PpapiPermissions& permissions, |
| 79 bool incognito, | 80 bool incognito, |
| 80 SerializedHandle handle); | 81 SerializedHandle handle); |
| 81 void OnPluginDispatcherMessageReceived(const IPC::Message& msg); | 82 void OnPluginDispatcherMessageReceived(const IPC::Message& msg); |
| 82 | 83 |
| 83 std::set<PP_Instance> instances_; | 84 std::set<PP_Instance> instances_; |
| 84 std::map<uint32, PluginDispatcher*> plugin_dispatchers_; | 85 std::map<uint32, PluginDispatcher*> plugin_dispatchers_; |
| 85 uint32 next_plugin_dispatcher_id_; | 86 uint32 next_plugin_dispatcher_id_; |
| 86 scoped_refptr<base::MessageLoopProxy> message_loop_; | 87 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 87 base::WaitableEvent shutdown_event_; | 88 base::WaitableEvent shutdown_event_; |
| 88 }; | 89 }; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBUDPSocket_RecvFromACK, | 176 IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBUDPSocket_RecvFromACK, |
| 176 OnPluginDispatcherMessageReceived(msg)) | 177 OnPluginDispatcherMessageReceived(msg)) |
| 177 IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBUDPSocket_SendToACK, | 178 IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBUDPSocket_SendToACK, |
| 178 OnPluginDispatcherMessageReceived(msg)) | 179 OnPluginDispatcherMessageReceived(msg)) |
| 179 IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBUDPSocket_BindACK, | 180 IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBUDPSocket_BindACK, |
| 180 OnPluginDispatcherMessageReceived(msg)) | 181 OnPluginDispatcherMessageReceived(msg)) |
| 181 IPC_END_MESSAGE_MAP() | 182 IPC_END_MESSAGE_MAP() |
| 182 return true; | 183 return true; |
| 183 } | 184 } |
| 184 | 185 |
| 185 void PpapiDispatcher::OnMsgCreateNaClChannel(int renderer_id, | 186 void PpapiDispatcher::OnMsgCreateNaClChannel( |
| 186 bool incognito, | 187 int renderer_id, |
| 187 SerializedHandle handle) { | 188 const ppapi::PpapiPermissions& permissions, |
| 189 bool incognito, |
| 190 SerializedHandle handle) { |
| 191 // Tell the process-global GetInterface which interfaces it can return to the |
| 192 // plugin. |
| 193 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions( |
| 194 permissions); |
| 195 |
| 188 PluginDispatcher* dispatcher = | 196 PluginDispatcher* dispatcher = |
| 189 new PluginDispatcher(::PPP_GetInterface, incognito); | 197 new PluginDispatcher(::PPP_GetInterface, permissions, incognito); |
| 190 // The channel handle's true name is not revealed here. | 198 // The channel handle's true name is not revealed here. |
| 191 IPC::ChannelHandle channel_handle("nacl", handle.descriptor()); | 199 IPC::ChannelHandle channel_handle("nacl", handle.descriptor()); |
| 192 if (!dispatcher->InitPluginWithChannel(this, channel_handle, false)) { | 200 if (!dispatcher->InitPluginWithChannel(this, channel_handle, false)) { |
| 193 delete dispatcher; | 201 delete dispatcher; |
| 194 return; | 202 return; |
| 195 } | 203 } |
| 196 // From here, the dispatcher will manage its own lifetime according to the | 204 // From here, the dispatcher will manage its own lifetime according to the |
| 197 // lifetime of the attached channel. | 205 // lifetime of the attached channel. |
| 198 } | 206 } |
| 199 | 207 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); | 270 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); |
| 263 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); | 271 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); |
| 264 | 272 |
| 265 loop.Run(); | 273 loop.Run(); |
| 266 | 274 |
| 267 NaClSrpcModuleFini(); | 275 NaClSrpcModuleFini(); |
| 268 | 276 |
| 269 return 0; | 277 return 0; |
| 270 } | 278 } |
| 271 | 279 |
| OLD | NEW |