CEF基于Chromium和Webkit而來,支持PPAPI和NaCI。
CEF3的binary包默認已經支持PPAPI(參考[http://magpcss.org/ceforum/viewtopic.php?f=10&t=10509](http://magpcss.org/ceforum/viewtopic.php?f=10&t=10509)),以cefsimple為例(參考[**CEF Windows開發環境搭建**](http://blog.csdn.net/foruok/article/details/50468642)),可以通過命令行參數來注冊PPAPI plugin,通過–url參數傳遞一個加載對應plugin的html頁面。
下面是我測試可用的一個命令行參數
~~~
--ppapi-out-of-process --register-pepper-plugins="D:\projects\cef_binary_3.2357.1271.g8e0674e_windows32\Release\stub.dll;application/x-ppapi-stub" --url=file:///d:/projects/cef_binary_3.2357.1271.g8e0674e_windows32/Release/stub.html
~~~
stub.html非常簡單,代碼如下:
~~~
<!DOCTYPE html>
<html>
<head>
<title>stub</title>
</head>
<body>
<embed id="plugin" type="application/x-ppapi-stub">
</body>
</html>
~~~
其中stub.dll是我編譯的PPAPI SDK里的示例,做了些許改動。stub.c代碼如下:
~~~
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This is the simplest possible C Pepper plugin that does nothing. If you're
// using C++, you will want to look at stub.cc which uses the more convenient
// C++ wrappers.
#include <stddef.h>
#include <stdint.h>
#include <Windows.h>
#include <tchar.h>
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/ppb.h"
#include "ppapi/c/ppp.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/ppp_instance.h"
PP_Module g_module_id;
PPB_GetInterface g_get_browser_interface = NULL;
PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id,
PPB_GetInterface get_browser_interface) {
// Save the global module information for later.
g_module_id = module_id;
g_get_browser_interface = get_browser_interface;
OutputDebugString(_T("PPP_InitializeModule was called\r\n"));
return PP_OK;
}
PP_EXPORT void PPP_ShutdownModule() {
OutputDebugString(_T("PPP_ShutdownModule was called\r\n"));
}
PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
// You will normally implement a getter for at least PPP_INSTANCE_INTERFACE
// here.
return NULL;
}
~~~
如你所見,我只是使用OutputDebugString函數輸出了調試信息。運行cefsimple,使用DbgView工具可以看到我們輸出的信息。
關于PPAPI插件的細節,后面會有一些文章來講。
相關文章參考:
- [**CEF Windows開發環境搭建**](http://blog.csdn.net/foruok/article/details/50468642)
- 前言
- CEF Windows開發環境搭建
- CEF加載PPAPI插件
- VS2013編譯最簡單的PPAPI插件
- 理解PPAPI的設計
- PPAPI插件與瀏覽器的交互過程
- Windows下從源碼編譯CEF
- 編譯PPAPI的media_stream_video示例
- PPAPI插件的繪圖與輸入事件處理
- 在PPAPI插件中創建本地窗口
- PPAPI插件與瀏覽器的通信
- Windows下從源碼編譯Skia
- 在PPAPI插件中使用Skia繪圖
- 加載DLL中的圖片資源生成Skia中的SkBitmap對象
- PPAPI+Skia實現的涂鴉板
- PPAPI中使用Chromium的3D圖形接口
- PPAPI中使用OpenGL ES繪圖