Пример #1
0
void CheckKeyboardFocusCallback::handleCallback(const CppArgumentList& args, CppVariant* result)
{
	Awesomium::JSArguments jsArgs;
	initFromCppArgumentList(args, jsArgs);

	if(jsArgs.size())
		view->handleCheckKeyboardFocus(jsArgs[0].toBoolean());

	result->SetNull();
}
Пример #2
0
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();
}
Пример #3
0
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
}
Пример #4
0
void initFromCppArgumentList(const CppArgumentList& args, Awesomium::JSArguments& result)
{
	for(CppArgumentList::const_iterator i = args.begin(); i != args.end(); i++)
	{
		if(i->isInt32())
			result.push_back(i->ToInt32());
		else if(i->isDouble())
			result.push_back(i->ToDouble());
		else if(i->isBool())
			result.push_back(i->ToBoolean());
		else if(i->isString())
			result.push_back(i->ToString());
		else
			result.push_back(Awesomium::JSValue());
	}
}