void ClientApp::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) { /** N.B. this code is poor and needs tidying up **/ std::string bootData("(function () { "\ " try { "\ " // Widget interface is injected here."\ " %s"\ " } catch (e) { "\ " alert(\"webinos boot code exception: \" + e); "\ " } "\ "}());"); std::string widgetInterface; webinos::WidgetConfig cfg; if (cfg.LoadFromURL(frame->GetURL())) { std::string widgetArgs; AppGetWidgetArgs(cfg.GetSessionId(),widgetArgs); /* We need to expose the w3c widget interface (http://www.w3.org/TR/widgets-apis/) interface Widget { readonly attribute DOMString author; readonly attribute DOMString description; readonly attribute DOMString name; readonly attribute DOMString shortName; readonly attribute DOMString version; readonly attribute DOMString id; readonly attribute DOMString authorEmail; readonly attribute DOMString authorHref; readonly attribute WidgetStorage preferences; <!-- TBD! readonly attribute unsigned long height; readonly attribute unsigned long width; }; */ std::stringstream wifStr(std::stringstream::in | std::stringstream::out); wifStr << "\ // Widget interface\r\n\ window.widget = { \r\n\ author: \"" << cfg.author() << "\",\r\n\ description: \"" << cfg.description() << "\",\r\n\ name: \"" << cfg.name() << "\",\r\n\ shortName: \"" << cfg.shortName() << "\",\r\n\ version: \"" << cfg.version() << "\",\r\n\ id: \"" << cfg.id() << "\",\r\n\ authorEmail: \"" << cfg.authorEmail() << "\",\r\n\ authorHref: \"" << cfg.authorHref() << "\",\r\n\ preferences: {},\r\n\
void ClientApp::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) { /** N.B. this code is poor and needs tidying up **/ CefRefPtr<CefCommandLine> commandLine = AppGetCommandLine(); #if defined(OS_WIN) FilePath workingDir(commandLine->GetProgram().ToWString().c_str()); FilePath bootPath = workingDir.DirName().Append(L"webinosBoot.js"); #else FilePath workingDir(commandLine->GetProgram()); FilePath bootPath = workingDir.DirName().Append("webinosBoot.js"); #endif int64 bootDataSize; if (file_util::GetFileSize(bootPath, &bootDataSize)) { char* bootData = new char[bootDataSize+1]; file_util::ReadFile(bootPath, bootData, bootDataSize); bootData[bootDataSize] = 0; std::string widgetInterface; webinos::WidgetConfig cfg; if (cfg.LoadFromURL(frame->GetURL())) { std::string widgetArgs; AppGetWidgetArgs(cfg.GetSessionId(),widgetArgs); /* We need to expose the w3c widget interface (http://www.w3.org/TR/widgets-apis/) interface Widget { readonly attribute DOMString author; readonly attribute DOMString description; readonly attribute DOMString name; readonly attribute DOMString shortName; readonly attribute DOMString version; readonly attribute DOMString id; readonly attribute DOMString authorEmail; readonly attribute DOMString authorHref; readonly attribute WidgetStorage preferences; <!-- TBD! readonly attribute unsigned long height; readonly attribute unsigned long width; }; */ std::stringstream wifStr(std::stringstream::in | std::stringstream::out); wifStr << "\ // Widget interface\r\n\ window.widget = { \r\n\ author: \"" << cfg.author() << "\",\r\n\ description: \"" << cfg.description() << "\",\r\n\ name: \"" << cfg.name() << "\",\r\n\ shortName: \"" << cfg.shortName() << "\",\r\n\ version: \"" << cfg.version() << "\",\r\n\ id: \"" << cfg.id() << "\",\r\n\ authorEmail: \"" << cfg.authorEmail() << "\",\r\n\ authorHref: \"" << cfg.authorHref() << "\",\r\n\ preferences: {},\r\n\