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 "webkit/plugins/ppapi/plugin_module.h" | 5 #include "webkit/plugins/ppapi/plugin_module.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 return ResourceTracker::Get()->GetLiveObjectsForInstance(instance_id); | 210 return ResourceTracker::Get()->GetLiveObjectsForInstance(instance_id); |
211 } | 211 } |
212 | 212 |
213 const PPB_Testing_Dev testing_interface = { | 213 const PPB_Testing_Dev testing_interface = { |
214 &ReadImageData, | 214 &ReadImageData, |
215 &RunMessageLoop, | 215 &RunMessageLoop, |
216 &QuitMessageLoop, | 216 &QuitMessageLoop, |
217 &GetLiveObjectsForInstance | 217 &GetLiveObjectsForInstance |
218 }; | 218 }; |
219 | 219 |
220 // Return the part of the interface name before the ';' separator. | |
221 // If there is no ';', just returns the whole string. | |
222 std::string GetInterfacePrefix(const std::string& interface_string) { | |
223 size_t separator_pos = interface_string.find_first_of(';'); | |
224 return interface_string.substr(0, separator_pos); | |
225 } | |
226 | |
227 // GetInterface ---------------------------------------------------------------- | 220 // GetInterface ---------------------------------------------------------------- |
228 | 221 |
229 const void* GetInterface(const char* name) { | 222 const void* GetInterface(const char* name) { |
230 // All interfaces should be used on the main thread. | 223 // All interfaces should be used on the main thread. |
231 DCHECK(IsMainThread()); | 224 DCHECK(IsMainThread()); |
232 | 225 |
233 std::string name_prefix(GetInterfacePrefix(name)); | |
234 | |
235 // Allow custom interface factories first stab at the GetInterface call. | 226 // Allow custom interface factories first stab at the GetInterface call. |
236 const void* custom_interface = | 227 const void* custom_interface = |
237 PpapiInterfaceFactoryManager::GetInstance()->GetInterface(name); | 228 PpapiInterfaceFactoryManager::GetInstance()->GetInterface(name); |
238 if (custom_interface) | 229 if (custom_interface) |
239 return custom_interface; | 230 return custom_interface; |
240 | 231 |
241 // Please keep alphabetized by interface macro name with "special" stuff at | 232 // Please keep alphabetized by interface macro name with "special" stuff at |
242 // the bottom. | 233 // the bottom. |
243 if (strcmp(name, PPB_AUDIO_CONFIG_INTERFACE) == 0) | 234 if (strcmp(name, PPB_AUDIO_CONFIG_INTERFACE) == 0) |
244 return ::ppapi::thunk::GetPPB_AudioConfig_Thunk(); | 235 return ::ppapi::thunk::GetPPB_AudioConfig_Thunk(); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 return &core_interface; | 476 return &core_interface; |
486 } | 477 } |
487 | 478 |
488 // static | 479 // static |
489 PluginModule::GetInterfaceFunc PluginModule::GetLocalGetInterfaceFunc() { | 480 PluginModule::GetInterfaceFunc PluginModule::GetLocalGetInterfaceFunc() { |
490 return &GetInterface; | 481 return &GetInterface; |
491 } | 482 } |
492 | 483 |
493 PluginInstance* PluginModule::CreateInstance(PluginDelegate* delegate) { | 484 PluginInstance* PluginModule::CreateInstance(PluginDelegate* delegate) { |
494 PluginInstance* instance(NULL); | 485 PluginInstance* instance(NULL); |
495 const void* plugin_instance_if = | 486 const void* ppp_instance = GetPluginInterface(PPP_INSTANCE_INTERFACE_0_5); |
496 GetPluginInterface(PPP_INSTANCE_INTERFACE_0_5); | 487 if (ppp_instance) { |
497 if (plugin_instance_if) { | 488 instance = PluginInstance::Create0_5(delegate, this, ppp_instance); |
498 instance = new PluginInstance(delegate, this, | |
499 PluginInstance::new_instance_interface<PPP_Instance_0_5>( | |
500 plugin_instance_if)); | |
501 } else { | 489 } else { |
502 // If the current interface is not supported, try retrieving older versions. | 490 // If the 0.5 interface is not supported, try retrieving 0.4. |
503 const void* instance_if_0_4 = | 491 ppp_instance = GetPluginInterface(PPP_INSTANCE_INTERFACE_0_4); |
504 GetPluginInterface(PPP_INSTANCE_INTERFACE_0_4); | 492 if (ppp_instance) |
505 if (instance_if_0_4) { | 493 instance = PluginInstance::Create0_4(delegate, this, ppp_instance); |
506 instance = new PluginInstance(delegate, this, | |
507 PluginInstance::new_instance_interface<PPP_Instance_0_4>( | |
508 instance_if_0_4)); | |
509 } | |
510 } | 494 } |
511 if (!instance) { | 495 if (!instance) { |
512 LOG(WARNING) << "Plugin doesn't support instance interface, failing."; | 496 LOG(WARNING) << "Plugin doesn't support instance interface, failing."; |
513 return NULL; | 497 return NULL; |
514 } | 498 } |
515 if (out_of_process_proxy_.get()) | 499 if (out_of_process_proxy_.get()) |
516 out_of_process_proxy_->AddInstance(instance->pp_instance()); | 500 out_of_process_proxy_->AddInstance(instance->pp_instance()); |
517 return instance; | 501 return instance; |
518 } | 502 } |
519 | 503 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 int retval = entry_points_.initialize_module(pp_module(), &GetInterface); | 576 int retval = entry_points_.initialize_module(pp_module(), &GetInterface); |
593 if (retval != 0) { | 577 if (retval != 0) { |
594 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; | 578 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; |
595 return false; | 579 return false; |
596 } | 580 } |
597 return true; | 581 return true; |
598 } | 582 } |
599 | 583 |
600 } // namespace ppapi | 584 } // namespace ppapi |
601 } // namespace webkit | 585 } // namespace webkit |
OLD | NEW |