First implementation of C++ -> JS comms.

LOOT version is set in C++, visible in the About dialog.
This commit is contained in:
WrinklyNinja
2014-07-12 16:33:43 +01:00
parent 2552e6c6ba
commit c6beb23b89
2 changed files with 34 additions and 1 deletions
+24
View File
@@ -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
View File
@@ -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);
};