mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
First implementation of C++ -> JS comms.
LOOT version is set in C++, visible in the About dialog.
This commit is contained in:
@@ -39,6 +39,10 @@ namespace loot {
|
||||
return this;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderProcessHandler> LootApp::GetRenderProcessHandler() {
|
||||
return this;
|
||||
}
|
||||
|
||||
void LootApp::OnContextInitialized() {
|
||||
//Make sure this is running in the UI thread.
|
||||
assert(CefCurrentlyOn(TID_UI));
|
||||
@@ -64,4 +68,24 @@ namespace loot {
|
||||
CefBrowserHost::CreateBrowser(window_info, handler.get(), url, browser_settings, NULL);
|
||||
}
|
||||
|
||||
|
||||
void LootApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) {
|
||||
|
||||
// Retrieve the context's window object.
|
||||
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
||||
|
||||
// Here the initialisation values should be set.
|
||||
|
||||
// LOOT Version / Settings
|
||||
//------------------------
|
||||
|
||||
CefRefPtr<CefV8Value> lootObj = CefV8Value::CreateObject(NULL);
|
||||
|
||||
lootObj->SetValue("version", CefV8Value::CreateString(IntToString(g_version_major) + "." + IntToString(g_version_minor) + "." + IntToString(g_version_patch)), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
// Add the string to the window object as "window.myval". See the "JS Objects" section below.
|
||||
object->SetValue("loot", lootObj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -27,18 +27,27 @@
|
||||
|
||||
#include <include/cef_app.h>
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
namespace loot {
|
||||
|
||||
class LootApp : public CefApp, public CefBrowserProcessHandler {
|
||||
class LootApp : public CefApp,
|
||||
public CefBrowserProcessHandler,
|
||||
public CefRenderProcessHandler {
|
||||
public:
|
||||
LootApp();
|
||||
|
||||
// Override CefApp methods.
|
||||
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE;
|
||||
|
||||
// Override CefBrowserProcessHandler methods.
|
||||
virtual void OnContextInitialized() OVERRIDE;
|
||||
private:
|
||||
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(LootApp);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user