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