diff --git a/src/gui/app.cpp b/src/gui/app.cpp index d92ca701..092f6ca4 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -39,6 +39,10 @@ namespace loot { return this; } + CefRefPtr 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 browser, + CefRefPtr frame, + CefRefPtr context) { + + // Retrieve the context's window object. + CefRefPtr object = context->GetGlobal(); + + // Here the initialisation values should be set. + + // LOOT Version / Settings + //------------------------ + + CefRefPtr 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); + } } \ No newline at end of file diff --git a/src/gui/app.h b/src/gui/app.h index 73329660..f2943274 100644 --- a/src/gui/app.h +++ b/src/gui/app.h @@ -27,18 +27,27 @@ #include +#include + namespace loot { - class LootApp : public CefApp, public CefBrowserProcessHandler { + class LootApp : public CefApp, + public CefBrowserProcessHandler, + public CefRenderProcessHandler { public: LootApp(); // Override CefApp methods. virtual CefRefPtr GetBrowserProcessHandler() OVERRIDE; + virtual CefRefPtr GetRenderProcessHandler() OVERRIDE; // Override CefBrowserProcessHandler methods. virtual void OnContextInitialized() OVERRIDE; private: + virtual void OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) OVERRIDE; + IMPLEMENT_REFCOUNTING(LootApp); };