PPAPI


  1. Download the Native Client SDK
  2. 创建一个vs2013工程:
    • 新建一个Win32项目,类型选DLL
    • 去掉预编译头文件stdafx.h和stdafx.cpp
    • 在项目属性–>配置属性–>C/C++–>预编译头,把预编译头选项的值设置为不使用预编译头。
  3. 将一下代码粘贴到项目中。
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/var.h"/// The Instance class.  One of these exists for each instance of your NaCl
/// module on the web page.  The browser will ask the Module object to create
/// a new Instance for each occurrence of the <embed> tag that has these
/// attributes:
///     src="hello_tutorial.nmf"
///     type="application/x-pnacl"
/// To communicate with the browser, you must override HandleMessage() to
/// receive messages from the browser, and use PostMessage() to send messages
/// back to the browser.  Note that this interface is asynchronous.
class HelloTutorialInstance : public pp::Instance {public:/// The constructor creates the plugin-side instance./// @param[in] instance the handle to the browser-side plugin instance.explicit HelloTutorialInstance(PP_Instance instance) : pp::Instance(instance){pp::Var var_reply = pp::Var("hello from Pepper Plugin");PostMessage(var_reply);}virtual ~HelloTutorialInstance() {}/// Handler for messages coming in from the browser via postMessage().  The/// @a var_message can contain be any pp:Var type; for example int, string/// Array or Dictinary. Please see the pp:Var documentation for more details./// @param[in] var_message The message posted by the browser.virtual void HandleMessage(const pp::Var& var_message) {// TODO(sdk_user): 1. Make this function handle the incoming message.}
};/// The Module class.  The browser calls the CreateInstance() method to create
/// an instance of your NaCl module on the web page.  The browser creates a new
/// instance for each <embed> tag with type="application/x-pnacl".
class HelloTutorialModule : public pp::Module {public:HelloTutorialModule() : pp::Module() {}virtual ~HelloTutorialModule() {}/// Create and return a HelloTutorialInstance object./// @param[in] instance The browser-side instance./// @return the plugin-side instance.virtual pp::Instance* CreateInstance(PP_Instance instance) {return new HelloTutorialInstance(instance);}
};namespace pp {
/// Factory function called by the browser when the module is first loaded.
/// The browser keeps a singleton of this module.  It calls the
/// CreateInstance() method on the object you return to make instances.  There
/// is one instance per <embed> tag on the page.  This is the main binding
/// point for your NaCl module with the browser.
Module* CreateModule() {return new HelloTutorialModule();
}
}  // namespace pp

插入所需头文件路径,库路径以及相关库。在“nacl_sdk\pepper_49…”下。pepper_49中“49”是我安装的版本号。
4. 编译生成dll文件,以下是使用electron测试插件。
5. 测试:
main.js

var app = require('app');
var BrowserWindow = require('browser-window');
var path = require('path')var mainWindow = null;app.commandLine.appendSwitch('register-pepper-plugins', path.join(__dirname, 'libppapi_hello.so;application/x-hello'))app.on('ready', function() {mainWindow = new BrowserWindow({height: 800,width: 1024,'web-preferences' : {'p

nacl.html

<!DOCTYPE html>
<html><!--Copyright (c) 2013 The Chromium Authors. All rights reserved.Use of this source code is governed by a BSD-style license that can befound in the LICENSE file.-->
<head><title>hello_tutorial</title><script type="text/javascript">// The 'message' event handler.  This handler is fired when the NaCl module// posts a message to the browser by calling PPB_Messaging.PostMessage()// (in C) or pp::Instance.PostMessage() (in C++).  This implementation// simply displays the content of the message in an alert panel.function handleMessage(message_event) {alert(message_event.data);}</script>
</head>
<body><h1>NaCl C++ Tutorial: Getting Started</h1><p><div id="listener"><script type="text/javascript">var listener = document.getElementById('listener');listener.addEventListener('message', handleMessage, true);</script><embed id="hello_tutorial"width=0 height=0type="application/x-hello" /></div></p>
</body>
</html>

package.json

{"main": "main.js","name": "Pepper plugin test","description": "testing third party plugin load","version": "0.0.1","license": "MIT"}

使用electron启动相关应用后可以看到,页面启动后弹出提示框。

PPAPI 插件编写相关推荐

  1. Gulp:插件编写入门

    之前挖了个坑,准备写篇gulp插件编写入门的科普文,之后迟迟没有动笔,因为不知道该肿么讲清楚Stream这货,毕竟,gulp插件的实现不像grunt插件的实现那么直观. 好吧,于是决定单刀直入了.文中 ...

  2. VS2010插件编写学习总结

    VS2010 Addins 外接程序(插件)开发 http://www.cnblogs.com/Leo_wl/archive/2013/03/21/2973886.html 简单做了一个添加文件头注视 ...

  3. [Linux实用工具]munin-node插件配置和插件编写

    前面介绍了2篇munin使用的相关文章: [Linux实用工具]Linux监控工具munin的安装和配置 [Linux实用工具]Linux监控工具munin的展示(Nginx) 这次介绍一下munin ...

  4. maven插件编写_编写Maven插件的提示

    maven插件编写 最近,我花了很多时间为Maven编写插件或在其中工作. 它们简单,有趣且有趣. 我以为我会分享一些技巧,使编写它们时的生活更轻松. 提示1:将任务与Mojo分开 最初,您将把moj ...

  5. 【转载】Nessus安全测试插件编写教程

    Nessus安全测试插件编写教程 作者:Renaud Deraison 翻译:nixe0n 1.怎样编写一个高效的Nessus安全测试插件 在Nessus安全测试系统中, 所有的安全测试都是由ness ...

  6. Soul网关源码阅读(十)自定义简单插件编写

    Soul网关源码阅读(十)自定义简单插件编写 简介     综合前面所分析的插件处理流程相关知识,此次我们来编写自定义的插件:统计请求在插件链中的经历时长 编写准备     首先我们先探究一下,一个P ...

  7. jQuery插件编写,

    jQuery插件编写 jQuery插件 最近搞jquery插件的编写这里做下笔记 给jquery扩展的方式很多,看的我眼花缭乱 方式1 $.fun=function(){} 方式2 $.fn.fun= ...

  8. 3ds max sdk导出插件编写的心得

    3ds max sdk导出插件编写的心得 作者:yhchinabest 来自:CG先生-3D图形插件开发网http://www.cgsir.com 写在前面 为什么要写这个心得?去年11月份的时候我写 ...

  9. 3D MAX导出插件编写

    文章版权归博客园 BigCoder所有,转载请于明显位置标明原文作者及出处,以示尊重!! 原文出处:http://www.cnblogs.com/csyisong/archive/2009/09/01 ...

  10. PPAPI插件的全屏切换处理

    有时你会想让PPAPI插件全屏(比如播放视频时),这次来看看怎么做. PPAPI和CEF App两侧都要处理. foruok原创,转载请注明出处.欢迎关注foruok的订阅号"程序视界&qu ...

最新文章

  1. 最新的GAN方法——PGGAN揭秘
  2. 《JavaScript高级程序设计》心得笔记-----第四篇章
  3. docker 中部署一个springBoot项目
  4. 超百家金融机构争相出席,只因飞贷宣布输出全球领先的移动信贷整体技术
  5. ubuntu修改mysql的绑定端口
  6. 织梦 css里的图片标签,织梦{dede:field.body /}中用CSS的expression参数控制图片大小
  7. 【BZOJ2004】[Hnoi2010]Bus 公交线路 状压+矩阵乘法
  8. 冲刺第三天 11.27 TUE
  9. android 图片转字符串,图片转字符文字怎么转?安卓字符图App
  10. python 随机padding_Python backend.spatial_2d_padding方法代码示例
  11. CakePHP查询数据
  12. 遗传算法求解TSP问题(Python)
  13. 人工智能——状态空间表示法
  14. CUDA的下载与安装
  15. 学习与记忆方法-学习之前先学如何学习
  16. 【meArm机械臂】第一篇·结构设计及搭建
  17. linux系统制作qcow2,oz制作qcow2镜像
  18. 基于单片机的超市储物柜设计_基于单片机的自动存储柜的设计
  19. 指令系统的发展经历指令系统的发展经历了从简单到复杂的演变过程
  20. 服务器前端机中转机制,『中高级前端面试』之终极知识点

热门文章

  1. oracle应收模块报表,OracleERPEBS应收模块AR概要培训ppt课件
  2. 黑马程序员pink老师前端入门教程,零基础必看的JavaScript基础语法视频教程(jQuery2)
  3. c语言常量指什么作用,c语言字符常量是什么
  4. [渝粤教育] 重庆工程职业技术学院 数控机床编程与操作 参考 资料
  5. 3 Java学习之 IO
  6. WEB网页监控系统的设计框架思路详解
  7. html5库存管理,库存管理的基本方法
  8. 通过vb代码将多个excel合并成一个
  9. 在电脑上安装python-如何在自己的电脑上安装python的idle版 - 卡饭网
  10. 计算机一级考试wps教程视频教程,全国计算机等级考试一级WPS Office教程(2008年版)...