void WebView::evaluateJS(const std::string& javascript, const Awesomium::JSArguments& args) { #ifdef HAVE_AWESOMIUM std::string resultScript; char paramName[15]; unsigned int i, count; for(i = 0, count = 0; i < javascript.length(); i++) { if(javascript[i] == '?') { count++; if(count <= args.size()) { sprintf(paramName, "__p00%d", count - 1); setProperty(paramName, args[count-1]); resultScript += "Client."; resultScript += paramName; } else { resultScript += "undefined"; } } else { resultScript.push_back(javascript[i]); } } webView->executeJavascript(resultScript); #endif }
void Awesomium::WebView::handleFutureJSValueCallback(const Awesomium::JSArguments& args) { if(args.size() != 2) return; int requestID = args[0].toInteger(); std::map<int, JSValueFutureImpl*>::iterator i; jsValueFutureMapLock->Lock(); i = jsValueFutureMap.find(requestID); if(i == jsValueFutureMap.end()) return; JSValueFutureImpl* futureImpl = (*i).second; if(!futureImpl->value) { futureImpl->value = new Awesomium::JSValue(); *futureImpl->value = args[1]; } jsValueFutureMapLock->Unlock(); if(!futureImpl->resolveFutureEvent.IsSignaled()) futureImpl->resolveFutureEvent.Signal(); }
void CheckKeyboardFocusCallback::handleCallback(const CppArgumentList& args, CppVariant* result) { Awesomium::JSArguments jsArgs; initFromCppArgumentList(args, jsArgs); if(jsArgs.size()) view->handleCheckKeyboardFocus(jsArgs[0].toBoolean()); result->SetNull(); }