15f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Copyright (c) 2014 The Chromium Authors. All rights reserved.
25f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// found in the LICENSE file.
45f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
55f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h"
65f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
75f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ppapi/c/pp_errors.h"
85f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ppapi/c/pp_module.h"
95f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ppapi/c/ppb.h"
105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ppapi/cpp/module.h"
115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ppapi/cpp/private/internal_module.h"
125f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ppapi/native_client/src/trusted/plugin/module_ppapi.h"
135f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace nacl_plugin {
155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
165f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)int32_t PPP_InitializeModule(PP_Module module_id,
175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                             PPB_GetInterface get_browser_interface) {
185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  plugin::ModulePpapi* module = new plugin::ModulePpapi();
195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  if (!module->InternalInit(module_id, get_browser_interface)) {
205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    delete module;
215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    return PP_ERROR_FAILED;
225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  pp::InternalSetModuleSingleton(module);
255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  return PP_OK;
265f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
275f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)void PPP_ShutdownModule() {
295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  delete pp::Module::Get();
305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  pp::InternalSetModuleSingleton(NULL);
315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)const void* PPP_GetInterface(const char* interface_name) {
345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  if (!pp::Module::Get())
355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    return NULL;
365f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  return pp::Module::Get()->GetPluginInterface(interface_name);
375f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
385f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
395f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}  // namespace nacl_plugin
40