1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file.
4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/logging.h"
6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/nacl/loader/nonsfi/irt_interfaces.h"
7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ppapi/c/ppp.h"
8c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#include "ppapi/nacl_irt/plugin_main.h"
9c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#include "ppapi/nacl_irt/public/irt_ppapi.h"
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace nacl {
12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace nonsfi {
13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace {
14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)struct PP_StartFunctions g_pp_functions;
16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)int IrtPpapiStart(const struct PP_StartFunctions* funcs) {
18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  g_pp_functions = *funcs;
19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return PpapiPluginMain();
20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}  // namespace
23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)const struct nacl_irt_ppapihook kIrtPpapiHook = {
25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  IrtPpapiStart,
26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  PpapiPluginRegisterThreadCreator,
27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)};
28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}  // namespace nonsfi
30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}  // namespace nacl
31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)int32_t PPP_InitializeModule(PP_Module module_id,
33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                             PPB_GetInterface get_browser_interface) {
34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return nacl::nonsfi::g_pp_functions.PPP_InitializeModule(
35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      module_id, get_browser_interface);
36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
37a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void PPP_ShutdownModule(void) {
39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  nacl::nonsfi::g_pp_functions.PPP_ShutdownModule();
40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)const void *PPP_GetInterface(const char *interface_name) {
43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return nacl::nonsfi::g_pp_functions.PPP_GetInterface(interface_name);
44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
45