| 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 /// This project is for use with the testing framework | |
| 6 /// of the Visual Studio Add-in. | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "ppapi/cpp/instance.h" | |
| 11 #include "ppapi/cpp/module.h" | |
| 12 #include "ppapi/cpp/var.h" | |
| 13 | |
| 14 class DummyInstance : public pp::Instance { | |
| 15 public: | |
| 16 /// The constructor creates the plugin-side instance. | |
| 17 /// @param[in] instance the handle to the browser-side plugin instance. | |
| 18 explicit DummyInstance(PP_Instance instance) | |
| 19 : pp::Instance(instance) { | |
| 20 } | |
| 21 | |
| 22 virtual ~DummyInstance() { | |
| 23 } | |
| 24 | |
| 25 virtual bool Init(uint32_t /*argc*/, const char* /*argn*/[], | |
| 26 const char* /*argv*/[]) { | |
| 27 // Start chain of message relaying. | |
| 28 PostMessage(pp::Var("relay1")); | |
| 29 return true; | |
| 30 } | |
| 31 | |
| 32 private: | |
| 33 virtual void HandleMessage(const pp::Var& var_message) { | |
| 34 // Simply relay back to javascript the message we just received. | |
| 35 if (!var_message.is_string()) | |
| 36 return; | |
| 37 std::string msg = var_message.AsString(); | |
| 38 PostMessage(pp::Var(msg)); | |
| 39 } | |
| 40 }; | |
| 41 | |
| 42 /// The Module class. The browser calls the CreateInstance() method to create | |
| 43 /// an instance of your NaCl module on the web page. The browser creates a new | |
| 44 /// instance for each <embed> tag with type="application/x-nacl". | |
| 45 class DummyModule : public pp::Module { | |
| 46 public: | |
| 47 DummyModule() : pp::Module() {} | |
| 48 virtual ~DummyModule() {} | |
| 49 | |
| 50 /// Create and return a FileIoInstance object. | |
| 51 /// @param[in] instance The browser-side instance. | |
| 52 /// @return the plugin-side instance. | |
| 53 virtual pp::Instance* CreateInstance(PP_Instance instance) { | |
| 54 return new DummyInstance(instance); | |
| 55 } | |
| 56 }; | |
| 57 | |
| 58 namespace pp { | |
| 59 Module* CreateModule() { | |
| 60 return new DummyModule(); | |
| 61 } | |
| 62 } // namespace pp | |
| 63 | |
| OLD | NEW |