| 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 "ppapi/proxy/plugin_dispatcher.h" | 5 #include "ppapi/proxy/plugin_dispatcher.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // plugin making pepper calls on a different thread. | 216 // plugin making pepper calls on a different thread. |
| 217 ProxyAutoLock lock; | 217 ProxyAutoLock lock; |
| 218 TRACE_EVENT2("ppapi proxy", "PluginDispatcher::OnMessageReceived", | 218 TRACE_EVENT2("ppapi proxy", "PluginDispatcher::OnMessageReceived", |
| 219 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), | 219 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), |
| 220 "Line", IPC_MESSAGE_ID_LINE(msg.type())); | 220 "Line", IPC_MESSAGE_ID_LINE(msg.type())); |
| 221 | 221 |
| 222 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 222 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
| 223 // Handle some plugin-specific control messages. | 223 // Handle some plugin-specific control messages. |
| 224 bool handled = true; | 224 bool handled = true; |
| 225 IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) | 225 IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) |
| 226 IPC_MESSAGE_HANDLER(PpapiMsg_IsInterfaceSupported, | 226 IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) |
| 227 OnMsgIsInterfaceSupported) | |
| 228 IPC_MESSAGE_HANDLER(PpapiMsg_SetPreferences, OnMsgSetPreferences) | 227 IPC_MESSAGE_HANDLER(PpapiMsg_SetPreferences, OnMsgSetPreferences) |
| 229 IPC_MESSAGE_UNHANDLED(handled = false); | 228 IPC_MESSAGE_UNHANDLED(handled = false); |
| 230 IPC_END_MESSAGE_MAP() | 229 IPC_END_MESSAGE_MAP() |
| 231 if (handled) | 230 if (handled) |
| 232 return true; | 231 return true; |
| 233 } | 232 } |
| 234 return Dispatcher::OnMessageReceived(msg); | 233 return Dispatcher::OnMessageReceived(msg); |
| 235 } | 234 } |
| 236 | 235 |
| 237 void PluginDispatcher::OnChannelError() { | 236 void PluginDispatcher::OnChannelError() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 i != temp_map.end(); ++i) { | 290 i != temp_map.end(); ++i) { |
| 292 if (i->second == this) { | 291 if (i->second == this) { |
| 293 // Synthesize an "instance destroyed" message, this will notify the | 292 // Synthesize an "instance destroyed" message, this will notify the |
| 294 // plugin and also remove it from our list of tracked plugins. | 293 // plugin and also remove it from our list of tracked plugins. |
| 295 PpapiMsg_PPPInstance_DidDestroy msg(API_ID_PPP_INSTANCE, i->first); | 294 PpapiMsg_PPPInstance_DidDestroy msg(API_ID_PPP_INSTANCE, i->first); |
| 296 OnMessageReceived(msg); | 295 OnMessageReceived(msg); |
| 297 } | 296 } |
| 298 } | 297 } |
| 299 } | 298 } |
| 300 | 299 |
| 301 void PluginDispatcher::OnMsgIsInterfaceSupported( | 300 void PluginDispatcher::OnMsgSupportsInterface( |
| 302 const std::string& interface_name, | 301 const std::string& interface_name, |
| 303 bool* result) { | 302 bool* result) { |
| 304 *result = !!GetPluginInterface(interface_name); | 303 *result = !!GetPluginInterface(interface_name); |
| 305 | 304 |
| 306 // Do fallback for PPP_Instance. This is a hack here and if we have more | 305 // Do fallback for PPP_Instance. This is a hack here and if we have more |
| 307 // cases like this it should be generalized. The PPP_Instance proxy always | 306 // cases like this it should be generalized. The PPP_Instance proxy always |
| 308 // proxies the 1.1 interface, and then does fallback to 1.0 inside the | 307 // proxies the 1.1 interface, and then does fallback to 1.0 inside the |
| 309 // plugin process (see PPP_Instance_Proxy). So here we return true for | 308 // plugin process (see PPP_Instance_Proxy). So here we return true for |
| 310 // supporting the 1.1 interface if either 1.1 or 1.0 is supported. | 309 // supporting the 1.1 interface if either 1.1 or 1.0 is supported. |
| 311 if (!*result && interface_name == PPP_INSTANCE_INTERFACE) | 310 if (!*result && interface_name == PPP_INSTANCE_INTERFACE) |
| 312 *result = !!GetPluginInterface(PPP_INSTANCE_INTERFACE_1_0); | 311 *result = !!GetPluginInterface(PPP_INSTANCE_INTERFACE_1_0); |
| 313 } | 312 } |
| 314 | 313 |
| 315 void PluginDispatcher::OnMsgSetPreferences(const Preferences& prefs) { | 314 void PluginDispatcher::OnMsgSetPreferences(const Preferences& prefs) { |
| 316 // The renderer may send us preferences more than once (currently this | 315 // The renderer may send us preferences more than once (currently this |
| 317 // happens every time a new plugin instance is created). Since we don't have | 316 // happens every time a new plugin instance is created). Since we don't have |
| 318 // a way to signal to the plugin that the preferences have changed, changing | 317 // a way to signal to the plugin that the preferences have changed, changing |
| 319 // the default fonts and such in the middle of a running plugin could be | 318 // the default fonts and such in the middle of a running plugin could be |
| 320 // confusing to it. As a result, we never allow the preferences to be changed | 319 // confusing to it. As a result, we never allow the preferences to be changed |
| 321 // once they're set. The user will have to restart to get new font prefs | 320 // once they're set. The user will have to restart to get new font prefs |
| 322 // propogated to plugins. | 321 // propogated to plugins. |
| 323 if (!received_preferences_) { | 322 if (!received_preferences_) { |
| 324 received_preferences_ = true; | 323 received_preferences_ = true; |
| 325 preferences_ = prefs; | 324 preferences_ = prefs; |
| 326 } | 325 } |
| 327 } | 326 } |
| 328 | 327 |
| 329 } // namespace proxy | 328 } // namespace proxy |
| 330 } // namespace ppapi | 329 } // namespace ppapi |
| OLD | NEW |