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 3 // found in the LICENSE file. 4 5 #include "remoting/client/plugin/pepper_entrypoints.h" 6 7 #include "base/message_loop/message_loop.h" 8 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_instance.h" 10 #include "ppapi/c/pp_module.h" 11 #include "ppapi/c/ppb_instance.h" 12 #include "ppapi/cpp/instance.h" 13 #include "ppapi/cpp/module.h" 14 #include "remoting/client/plugin/chromoting_instance.h" 15 16 static pp::Module* g_module_singleton = NULL; 17 18 namespace pp { 19 20 Module* Module::Get() { 21 return g_module_singleton; 22 } 23 24 } // namespace pp 25 26 namespace remoting { 27 28 class ChromotingModule : public pp::Module { 29 protected: 30 virtual ChromotingInstance* CreateInstance(PP_Instance instance) OVERRIDE { 31 return new ChromotingInstance(instance); 32 } 33 }; 34 35 // Implementation of Global PPP functions --------------------------------- 36 int32_t PPP_InitializeModule(PP_Module module_id, 37 PPB_GetInterface get_browser_interface) { 38 ChromotingModule* module = new ChromotingModule(); 39 if (!module) 40 return PP_ERROR_FAILED; 41 42 if (!module->InternalInit(module_id, get_browser_interface)) { 43 delete module; 44 return PP_ERROR_FAILED; 45 } 46 47 #if !defined(NDEBUG) 48 // Register a global log handler, but only in Debug builds. 49 ChromotingInstance::RegisterLogMessageHandler(); 50 #endif 51 52 g_module_singleton = module; 53 return PP_OK; 54 } 55 56 void PPP_ShutdownModule() { 57 delete pp::Module::Get(); 58 g_module_singleton = NULL; 59 } 60 61 const void* PPP_GetInterface(const char* interface_name) { 62 if (!pp::Module::Get()) 63 return NULL; 64 return pp::Module::Get()->GetPluginInterface(interface_name); 65 } 66 67 const void* PPP_GetBrowserInterface(const char* interface_name) { 68 if (!pp::Module::Get()) 69 return NULL; 70 return pp::Module::Get()->GetBrowserInterface(interface_name); 71 } 72 73 } // namespace remoting 74