導航:首頁 > 源碼編譯 > 編譯cef源碼生成的庫是什麼

編譯cef源碼生成的庫是什麼

發布時間:2024-06-29 11:19:56

❶ 如何利用CEF3創建一個簡單的應用程序

開始
首先,根據自身所使用的開發平台,可以去 這里 下載對應的發布版本。針對這個教程,我們需要下載1750或者更新的版本。當前支持的平台有Windows, Linux和Mac OS X。每一個版本都包含了當在特定平台上編譯特定版本CEF3時所需要的所有文件和資源。您可以通過包含在里邊的 REDME.txt 文件或者在Wiki上GeneralUsage 中的 Getting Started,了解每個發布版本的具體內容和細節。
編譯發布版本中的項目
以CEF發布版本為基礎開發的應用程序可以使用標準的平台編譯工具進行編譯執行。包括 Windows 平台下的 Visual Studio, Mac OS X 平台下的 Xcode, 以及 Linux 平台下的 gcc/make。針對平台的不同,項目的編譯過程也有些許的不同和要求。
Windows
Windows 平台下編譯 Cefsimple 步驟:
1. 用對應的 Visual Studio 版本打開項目解決方案。舉個例子,如果你安裝的是 Visual Studio 2010, 那麼,打開的就是 cesimple2010.sln。
2. 如果你下載的是 x64版本,請確保你選擇的是 x64的開發平台。
3. 開始編譯。
4. 如果編譯通過,那麼,在當前解決方案的目錄下,將出現「out/Debug」(或者 「out/Release」)文件夾
5. 執行文件夾下 cefsimple.exe, 確保能正確運行。
載入一個自定義URL
cefsimple項目中默認載入的URL是 google.com,當然,你也可以用自定義的 URL 去替代它,最方便的就是通過命令行搞定。
# Load the local file 「c:\example\example.html」
cefsimple.exe --url=file://c:/example/example.html

除了命令行的方法,也可以通過直接修改在 cefsimple/simple.cpp 文件中的代碼,達到你的目的。
# Load the local file 「c:\example\example.html」

if (url.empty())
url = file://c:/example/example.html;

應用程序組成
所有的 CEF 應用程序都有一下主要組成部分:
1. CEF 的動態鏈接庫 。(在 Windows 平台下就是 libcef.dll)
2. 支持庫。(ICU, FFMPEG等)
3. 資源。(html/js/css, strings等)
4. 客戶端執行文件。(本教程中就是 cefsimple.exe.)
要點(必看)
1. CEF 使用的是多進程。應用程序主進程是瀏覽器進程,而其他子進程是由 renderer, plugins, GPU等創建。
2. 在 Windows 和 Linux 平台下的執行文件可以被主進程和子進程使用。
3. CEF 中所有進程都可以是多線程的。CEF提供了許多功能和介面在不同的線程中傳遞任務。
4. 一些回調方法和函數只能在特定的進程或者線程中使用。在你第一次使用新的回調方法或者函數之前,請確保你已經閱讀了 API 頭文件中源碼,看使用要求。
流程分析
cefsimple 應用程序首先初始化CEF,然後創建了一個簡單的彈出瀏覽器窗口。當關閉了所有的瀏覽器窗口,應用程序就會結束。程序執行流程如下:
1. 系統執行入口點函數(main or wWinMain),並創建瀏覽器進程。
2. 入口點函數:
1. 創建能夠處理進程級別的回調方法的 SimpleApp 實例。
2. 初始化 CEF,進入 CEF 消息循環。
3. 初始化 CEF 之後,調用 SimpleApp::OnContextInitialized() 。這個方法中:
1. 創建單例的 SimpleHandler 。
2. 由 CefBrowserHost::CreateBrowsersync() 方法創建一個瀏覽器窗口。
4. 所有的瀏覽器共享 SimpleHandler 實例, 此實例能定製瀏覽器行為、處理瀏覽器相關回調方法(life span, loading state, title display等)。
5. 當一個瀏覽器窗口關閉的時候,調用 SimpleHandler::OnBeforeClose() 。當所有的瀏覽器窗口全部關閉時,OnBeforeClose() 函數就會執行跳出 CEF 消息循環的行為,退出應用程序。
入口點函數
程序的運行開始於瀏覽器進程中的入口點函數。這個函數會初始化 CEF 以及所有跟操作系統有關的對象。
Windows

#include <windows.h>

#include "cefsimple/simple_app.h"
#include "include/cef_sandbox_win.h"

// Set to 0 to disable sandbox support.
#define CEF_ENABLE_SANDBOX 1

#if CEF_ENABLE_SANDBOX
// The cef_sandbox.lib static library is currently built with VS2010. It may not
// link successfully with other VS versions.
#pragma comment(lib, "cef_sandbox.lib")
#endif

// Entry point function for all processes.
int APIENTRY wWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow) {
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

void* sandbox_info = NULL;

#if CEF_ENABLE_SANDBOX
// Manage the life span of the sandbox information object. This is necessary
// for sandbox support on Windows. See cef_sandbox_win.h for complete details.
CefScopedSandboxInfo scoped_sandbox;
sandbox_info = scoped_sandbox.sandbox_info();
#endif

// Provide CEF with command-line arguments.
CefMainArgs main_args(hInstance);

// SimpleApp implements application-level callbacks. It will create the first
// browser instance in OnContextInitialized() after CEF has initialized.
CefRefPtr<SimpleApp> app(new SimpleApp);

// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
int exit_code = CefExecuteProcess(main_args, app.get(), sandbox_info);
if (exit_code >= 0) {
// The sub-process has completed so return here.
return exit_code;
}

// Specify CEF global settings here.
CefSettings settings;

#if !CEF_ENABLE_SANDBOX
settings.no_sandbox = true;
#endif

// Initialize CEF.
CefInitialize(main_args, settings, app.get(), sandbox_info);

// Run the CEF message loop. This will block until CefQuitMessageLoop() is
// called.
CefRunMessageLoop();

// Shut down CEF.
CefShutdown();

return 0;
}

SimpleApp
SimpleApp 負責處理進程級別的回調方法。它會曝露出一些在多進程中共享或者被特定進程使用的介面和方法。CefBrowserProcessHandler 介面,在瀏覽器進程中調用。還有一個被分離出 CefBrowserProcessHandler 介面(例子項目沒有展示)只會在渲染進程中被調用。由於 CefBrowserProcessHandler 不光實現了 CefApp, 同時還有 CefBrowserProcessHandler,所以它的返回值必須是[this]。

// simple_app.h
#include "include/cef_app.h"

class SimpleApp : public CefApp,
public CefBrowserProcessHandler {
public:
SimpleApp();

// CefApp methods:
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
OVERRIDE { return this; }

// CefBrowserProcessHandler methods:
virtual void OnContextInitialized() OVERRIDE;

private:
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(SimpleApp);
};

// simple_app.cpp
#include "cefsimple/simple_app.h"

#include <string>

#include "cefsimple/simple_handler.h"
#include "cefsimple/util.h"
#include "include/cef_browser.h"
#include "include/cef_command_line.h"

SimpleApp::SimpleApp() {
}

void SimpleApp::OnContextInitialized() {
REQUIRE_UI_THREAD();

// Information used when creating the native window.
CefWindowInfo window_info;

#if defined(OS_WIN)
// On Windows we need to specify certain flags that will be passed to
// CreateWindowEx().
window_info.SetAsPopup(NULL, "cefsimple");
#endif

// SimpleHandler implements browser-level callbacks.
CefRefPtr<SimpleHandler> handler(new SimpleHandler());

// Specify CEF browser settings here.
CefBrowserSettings browser_settings;

std::string url;

// Check if a "--url=" value was provided via the command-line. If so, use
// that instead of the default URL.
CefRefPtr<CefCommandLine> command_line =
CefCommandLine::GetGlobalCommandLine();
url = command_line->GetSwitchValue("url");
if (url.empty())
url = "http://www.google.com";

// Create the first browser window.
CefBrowserHost::CreateBrowserSync(window_info, handler.get(), url,
browser_settings, NULL);
}

SimpleHandler
SimpleHandler 負責處理瀏覽器級別的回調方法。這些回調方法會在瀏覽器進程中執行。在這個項目中,針對所有的瀏覽器使用相同的 CefClient 實例,但是如果你願意,可以在自己的應用程序中使用不同的 CefClient實例的。

// simple_handler.h
#include "include/cef_client.h"

#include <list>

class SimpleHandler : public CefClient,
public CefDisplayHandler,
public CefLifeSpanHandler,
public CefLoadHandler {
public:
SimpleHandler();
~SimpleHandler();

// Provide access to the single global instance of this object.
static SimpleHandler* GetInstance();

// CefClient methods:
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
return this;
}

// CefDisplayHandler methods:
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) OVERRIDE;

// CefLifeSpanHandler methods:
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;

// CefLoadHandler methods:
virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl) OVERRIDE;

// Request that all existing browser windows close.
void CloseAllBrowsers(bool force_close);

private:
// List of existing browser windows. Only accessed on the CEF UI thread.
typedef std::list<CefRefPtr<CefBrowser> > BrowserList;
BrowserList browser_list_;

// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(SimpleHandler);
};

// simple_handler.cpp
#include "cefsimple/simple_handler.h"

#include <sstream>
#include <string>

#include "cefsimple/util.h"
#include "include/cef_app.h"
#include "include/cef_runnable.h"

namespace {

SimpleHandler* g_instance = NULL;

❷ 如何查看大型工程的源代碼

程序員在工作過程中,會遇到很多需要閱讀源碼的場景,比如技術預研、選擇技術框架、接手以前的項目、review他人的代碼、維護老產品等等。可以說,閱讀源代碼是程序員的基本功,這項基本功是否扎實,會在很大程度上影響一個程序員在技術上的成長速度。2014年寫《Qt on Android核心編程》和《Qt Quick核心編程》時,很多內容都是通過分析Qt源碼搞明白的。這陣子研究CEF和PPAPI,也主要靠研究源代碼來搞明白用法。最近工作上要修改已有項目的一個子系統,也是得硬著頭皮先讀懂代碼。總之在開發工作這十來年中,讀過太多源碼了,從源代碼中學習到太多東西了,如果不閱讀源代碼,真不知道自己能否成長起來。寫代碼是從模仿開始的,提高也是從觀摩別人的優秀設計和代碼開始的。所以閱讀源碼至關重要,接下來咱從下列方面聊聊閱讀源碼的事兒。不同的目的會有不同的心情,會影響到工作的進展,像修復他人的Bug這種事情,類似於沒被掰彎的男猿捏著鼻子給另外一個男人擦屁股,是很惡心的,很容易讓人拒絕的。所以因這種目標而閱讀源碼,往往是欲拒還迎、欲說還休,效率較低。然而修復實際工作中幫別人修復Bug這種情形,十有八九你要遇到,無可逃避。所以,心理調試很重要。為了學習去讀源碼,這是最愉快的最放鬆的。不過提醒一點,設定可檢驗的目標才會有收獲,否則就會像走到大街上看見一美女擦肩而過那樣,驚艷一下下,過後嘛關系嘛收獲也沒了。其他的目的,重構舊代碼、添加新功能,比幫別人擦溝子(陝西話,屁股)略強,因為他帶有創造性,創造性的活動能給人帶來強烈的愉悅,所以雖然這兩種目的也有很多讓人不爽的部分,不過想到我可以讓一棵老樹煥發青春,不爽也就慢慢弱下去了。

❸ 微信是用什麼語言開發的

一般安卓手機的應用軟體目前都是以Java為主的程序語言開發的,包括微信。

許多的Android應用都是Java程序員開發者開發。雖然 Android運用了不同的JVM以及不同的封裝方式,但是代碼還是用Java語言所編寫。相當一部分的手機中都支持JAVA游戲,這就使很多非編程人員都認識了JAVA。

(3)編譯cef源碼生成的庫是什麼擴展閱讀

Java 語言是一門隨時代快速發展的計算機語言程序,其深刻展示了程序編寫的精髓,加上其簡明嚴謹的結構及簡潔的語法編寫為其將來的發展及維護提供了保障。由於提供了網路應用的支持和多媒體的存取,會推動Internet和企業網路的Web的應用 。

另外,為了保持Java的增長和推進Java社區的參與,Sun公司在Java One開發者大會上宣布開放Java核心源代碼,以鼓勵更多的人參與到Java社團活動中。來自Java社團和IBM等全球技術合作夥伴兩方面的支持,

Java技術在創新和社會進步上繼續發揮強有力的重要作用,並且隨著其程序編寫難度的降低使得更多專業人員將精力放置於Java語言的編寫與框架結構的設計中。

閱讀全文

與編譯cef源碼生成的庫是什麼相關的資料

熱點內容
電子發票如何填寫伺服器地址 瀏覽:803
python主線程和子線程區別 瀏覽:529
看動畫片的免費網站 瀏覽:37
五百里是哪部電影的主題曲 瀏覽:594
乘法口訣python程序 瀏覽:608
什麼軟體可以破解電影 瀏覽:843
思科命令清除 瀏覽:785
雙語電影如何切換默認音軌 瀏覽:619
查理人參精電影 瀏覽:425
安卓系統什麼品牌最流暢 瀏覽:734
pdf換成jpg圖片在線 瀏覽:700
交易app什麼時候掛單 瀏覽:479
古裝風月片大全 瀏覽:217
開發app應用要注意什麼 瀏覽:394
一邊懷孕一邊做的電影 瀏覽:491
python中所有的模塊 瀏覽:880
程序員用小新pro16 瀏覽:282
軍校電影有哪些 瀏覽:303
電腦文件夾默認排序怎麼恢復 瀏覽:723
萬德python 瀏覽:329