1// Copyright (c) 2014 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 "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h"
6
7#include "ppapi/c/pp_errors.h"
8#include "ppapi/c/pp_module.h"
9#include "ppapi/c/ppb.h"
10#include "ppapi/cpp/module.h"
11#include "ppapi/cpp/private/internal_module.h"
12#include "ppapi/native_client/src/trusted/plugin/module_ppapi.h"
13
14namespace nacl_plugin {
15
16int32_t PPP_InitializeModule(PP_Module module_id,
17                             PPB_GetInterface get_browser_interface) {
18  plugin::ModulePpapi* module = new plugin::ModulePpapi();
19  if (!module->InternalInit(module_id, get_browser_interface)) {
20    delete module;
21    return PP_ERROR_FAILED;
22  }
23
24  pp::InternalSetModuleSingleton(module);
25  return PP_OK;
26}
27
28void PPP_ShutdownModule() {
29  delete pp::Module::Get();
30  pp::InternalSetModuleSingleton(NULL);
31}
32
33const void* PPP_GetInterface(const char* interface_name) {
34  if (!pp::Module::Get())
35    return NULL;
36  return pp::Module::Get()->GetPluginInterface(interface_name);
37}
38
39}  // namespace nacl_plugin
40