Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / native_client_sdk / src / libraries / ppapi_simple_cpp / ps_entrypoints_cpp.cc
blob01760ae2bcdb8bdeb926b3edd1a69ed72b625506
1 // Copyright 2015 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.
5 #include <ppapi/c/pp_errors.h>
6 #include <ppapi/c/pp_module.h>
7 #include <ppapi/c/ppb.h>
8 #include <ppapi/c/ppp.h>
9 #include <ppapi/cpp/instance.h>
10 #include <ppapi/cpp/module.h>
12 #include "ppapi_simple/ps_interface.h"
13 #include "ppapi_simple/ps_internal.h"
15 class PSModule : public pp::Module {
16 public:
17 virtual pp::Instance* CreateInstance(PP_Instance instance) {
18 // Should not get here.
19 // This is only called by libppapi_cpp in Instance_DidCreate. That function
20 // is called by the PPP_Instance handler in libppapi_cpp, but we handle all
21 // plugin interfaces in ppapi_simple.
22 assert(0);
23 return NULL;
27 static PSModule* s_module;
29 namespace pp {
31 Module* Module::Get() {
32 return s_module;
35 // This shouldn't be called (it is only referenced by PPP_InitialzeModule in
36 // ppapi_cpp, which we override), but is needed to successfully link.
37 Module* CreateModule() {
38 assert(0);
39 return NULL;
42 } // namespace pp
44 extern "C" {
46 // This is defined to allow an executable to force inclusion of this object
47 // file. Otherwise PPP_* functions won't be linked in (because they are not
48 // needed until -lppapi on the link-line, which is usually last.
49 FORCE_LINK_THIS(ps_entry)
51 } // extern "C"
53 int32_t PPP_InitializeModule(PP_Module module_id,
54 PPB_GetInterface get_interface) {
55 g_ps_get_interface = get_interface;
56 PSInterfaceInit();
58 PSModule* module = new PSModule();
59 if (!module->InternalInit(module_id, get_interface)) {
60 delete s_module;
61 return PP_ERROR_FAILED;
63 s_module = module;
64 return PP_OK;
67 const void* PPP_GetInterface(const char* interface_name) {
68 return PSGetInterfaceImplementation(interface_name);
71 void PPP_ShutdownModule(void) {
72 delete s_module;
73 s_module = NULL;