| OLD | NEW |
| (Empty) | |
| 1 /* Copyright (c) 2012 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 |
| 6 #include "ppapi/c/pp_instance.h" |
| 7 #include "ppapi/c/pp_module.h" |
| 8 |
| 9 #include "ppapi/cpp/instance.h" |
| 10 #include "ppapi/cpp/module.h" |
| 11 |
| 12 #include "ppapi_simple/ps.h" |
| 13 |
| 14 static pp::Instance* s_Instance = NULL; |
| 15 |
| 16 PP_Instance PSGetInstanceId() { |
| 17 return s_Instance->pp_instance(); |
| 18 } |
| 19 |
| 20 const void* PSGetInterface(const char *name) { |
| 21 return pp::Module::Get()->GetBrowserInterface(name); |
| 22 } |
| 23 |
| 24 |
| 25 // The Module class. The browser calls the CreateInstance() method to create |
| 26 // an instance of your NaCl module on the web page. The browser creates a new |
| 27 // instance for each <embed> tag with type="application/x-nacl". |
| 28 class PSModule : public pp::Module { |
| 29 public: |
| 30 PSModule() : pp::Module() {} |
| 31 virtual ~PSModule() {} |
| 32 |
| 33 virtual pp::Instance* CreateInstance(PP_Instance instance) { |
| 34 s_Instance = static_cast<pp::Instance*>(PSUserCreateInstance(instance)); |
| 35 return s_Instance; |
| 36 } |
| 37 }; |
| 38 |
| 39 namespace pp { |
| 40 |
| 41 // Factory function called by the browser when the module is first loaded. |
| 42 // The browser keeps a singleton of this module. It calls the |
| 43 // CreateInstance() method on the object you return to make instances. There |
| 44 // is one instance per <embed> tag on the page. This is the main binding |
| 45 // point for your NaCl module with the browser. |
| 46 Module* CreateModule() { |
| 47 return new PSModule(); |
| 48 } |
| 49 |
| 50 } // namespace pp |
| 51 |
| OLD | NEW |