| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 typedef std::map<PP_Instance, PluginDispatcher*> InstanceToDispatcherMap; | 35 typedef std::map<PP_Instance, PluginDispatcher*> InstanceToDispatcherMap; |
| 36 InstanceToDispatcherMap* g_instance_to_dispatcher = NULL; | 36 InstanceToDispatcherMap* g_instance_to_dispatcher = NULL; |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle, | 40 PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle, |
| 41 GetInterfaceFunc get_interface) | 41 GetInterfaceFunc get_interface) |
| 42 : Dispatcher(remote_process_handle, get_interface), | 42 : Dispatcher(remote_process_handle, get_interface), |
| 43 plugin_delegate_(NULL) { | 43 plugin_delegate_(NULL), |
| 44 received_preferences_(false) { |
| 44 SetSerializationRules(new PluginVarSerializationRules); | 45 SetSerializationRules(new PluginVarSerializationRules); |
| 45 | 46 |
| 46 // As a plugin, we always support the PPP_Class interface. There's no | 47 // As a plugin, we always support the PPP_Class interface. There's no |
| 47 // GetInterface call or name for it, so we insert it into our table now. | 48 // GetInterface call or name for it, so we insert it into our table now. |
| 48 target_proxies_[INTERFACE_ID_PPP_CLASS].reset(new PPP_Class_Proxy(this)); | 49 target_proxies_[INTERFACE_ID_PPP_CLASS].reset(new PPP_Class_Proxy(this)); |
| 49 | 50 |
| 50 ::ppapi::TrackerBase::Init( | 51 ::ppapi::TrackerBase::Init( |
| 51 &PluginResourceTracker::GetTrackerBaseInstance); | 52 &PluginResourceTracker::GetTrackerBaseInstance); |
| 52 } | 53 } |
| 53 | 54 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 "Line", IPC_MESSAGE_ID_LINE(msg.type())); | 116 "Line", IPC_MESSAGE_ID_LINE(msg.type())); |
| 116 // Handle common control messages. | 117 // Handle common control messages. |
| 117 if (Dispatcher::OnMessageReceived(msg)) | 118 if (Dispatcher::OnMessageReceived(msg)) |
| 118 return true; | 119 return true; |
| 119 | 120 |
| 120 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 121 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
| 121 // Handle some plugin-specific control messages. | 122 // Handle some plugin-specific control messages. |
| 122 bool handled = true; | 123 bool handled = true; |
| 123 IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) | 124 IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) |
| 124 IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) | 125 IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) |
| 126 IPC_MESSAGE_HANDLER(PpapiMsg_SetPreferences, OnMsgSetPreferences) |
| 125 IPC_END_MESSAGE_MAP() | 127 IPC_END_MESSAGE_MAP() |
| 126 return handled; | 128 return handled; |
| 127 } | 129 } |
| 128 | 130 |
| 129 if (msg.routing_id() <= 0 && msg.routing_id() >= INTERFACE_ID_COUNT) { | 131 if (msg.routing_id() <= 0 && msg.routing_id() >= INTERFACE_ID_COUNT) { |
| 130 // Host is sending us garbage. Since it's supposed to be trusted, this | 132 // Host is sending us garbage. Since it's supposed to be trusted, this |
| 131 // isn't supposed to happen. Crash here in all builds in case the renderer | 133 // isn't supposed to happen. Crash here in all builds in case the renderer |
| 132 // is compromised. | 134 // is compromised. |
| 133 CHECK(false); | 135 CHECK(false); |
| 134 return true; | 136 return true; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 269 |
| 268 // Query the plugin & cache the result. | 270 // Query the plugin & cache the result. |
| 269 const void* interface_functions = GetLocalInterface(interface_name.c_str()); | 271 const void* interface_functions = GetLocalInterface(interface_name.c_str()); |
| 270 if (!interface_functions) | 272 if (!interface_functions) |
| 271 return; | 273 return; |
| 272 target_proxies_[info->id].reset( | 274 target_proxies_[info->id].reset( |
| 273 info->create_proxy(this, interface_functions)); | 275 info->create_proxy(this, interface_functions)); |
| 274 *result = true; | 276 *result = true; |
| 275 } | 277 } |
| 276 | 278 |
| 279 void PluginDispatcher::OnMsgSetPreferences(const ::ppapi::Preferences& prefs) { |
| 280 // The renderer may send us preferences more than once (currently this |
| 281 // happens every time a new plugin instance is created). Since we don't have |
| 282 // a way to signal to the plugin that the preferences have changed, changing |
| 283 // the default fonts and such in the middle of a running plugin could be |
| 284 // confusing to it. As a result, we never allow the preferences to be changed |
| 285 // once they're set. The user will have to restart to get new font prefs |
| 286 // propogated to plugins. |
| 287 if (!received_preferences_) { |
| 288 received_preferences_ = true; |
| 289 preferences_ = prefs; |
| 290 } |
| 291 } |
| 292 |
| 277 } // namespace proxy | 293 } // namespace proxy |
| 278 } // namespace pp | 294 } // namespace pp |
| 279 | 295 |
| OLD | NEW |