bool FUnrealCEFSubProcessRemoteScripting::HandleSetValueMessage(CefRefPtr<CefBrowser> Browser, CefRefPtr<CefListValue> MessageArguments)
{
	CefRefPtr<CefFrame> MainFrame = Browser->GetMainFrame();
	CefRefPtr<CefV8Context> Context = MainFrame->GetV8Context();
	ScopedV8Context ContextScope(Context);
	CefRefPtr<CefV8Value> RootObject = Context->GetGlobal()->GetValue("ue");
	if (!RootObject.get())
	{
		// The root object should always be created on context creation.
		return false;
	}

	for (size_t I = 0; I < MessageArguments->GetSize(); I++)
	{
		if (MessageArguments->GetType(I) != VTYPE_DICTIONARY)
		{
			return false;
		}
		CefRefPtr<CefDictionaryValue> Argument = MessageArguments->GetDictionary(I);

		if (Argument->GetType("name") != VTYPE_STRING
			|| Argument->GetType("value") != VTYPE_DICTIONARY
			|| Argument->GetType("permanent") != VTYPE_BOOL)
		{
			// Wrong message argument types or count
			return false;
		}

		CefString Name = Argument->GetString("name");
		CefRefPtr<CefDictionaryValue> CefValue = Argument->GetDictionary("value");
		bool bPermanent = Argument->GetBool("permanent");

		if (bPermanent)
		{
			int32 BrowserID = Browser->GetIdentifier();
			CefRefPtr<CefDictionaryValue> Bindings;
			if (PermanentBindings.Contains(BrowserID))
			{
				Bindings = PermanentBindings[BrowserID];
			}
			else
			{
				Bindings = CefDictionaryValue::Create();
				PermanentBindings.Add(BrowserID, Bindings);
			}

			Bindings->SetDictionary(Name, CefValue);
		}
		CefRefPtr<CefV8Value> Value = CefToV8(CefValue);
		RootObject->SetValue(Name, Value, V8_PROPERTY_ATTRIBUTE_NONE);

	}
	return true;
}
예제 #2
0
파일: XCefInfo.cpp 프로젝트: Zion-007/XCef
static void _list_to_dict(
	CefRefPtr<CefListValue> &		src,
	CefRefPtr<CefDictionaryValue> & dest,
	CefDictionaryValue::KeyList &	keys
	)
{
	if (!src.get())
		return;
	if (!dest.get())
		dest = CefDictionaryValue::Create();

	bool has_keys = keys.size() == dest->GetSize();
	for (int i = 0, nsize = static_cast<int>(src->GetSize()); i < nsize; ++i)
	{
		std::string key = has_keys ? keys[i] : std::to_string(i);
		switch (src->GetType(i))
		{
		case VTYPE_NULL:
			dest->SetNull(key);
			break;
		case VTYPE_BOOL:
			dest->SetBool(key, src->GetBool(i));
			break;
		case VTYPE_INT:
			dest->SetInt(key, src->GetInt(i));
			break;
		case VTYPE_DOUBLE:
			dest->SetDouble(key, src->GetDouble(i));
			break;
		case VTYPE_STRING:
			dest->SetString(key, src->GetString(i));
			break;
		case VTYPE_BINARY:
			dest->SetBinary(key, src->GetBinary(i));
			break;
		case VTYPE_DICTIONARY:
			dest->SetDictionary(key, src->GetDictionary(i));
			break;
		case VTYPE_LIST:
			dest->SetList(key, src->GetList(i));
			break;
		default:
			assert(0);
			break;
		}
	}
}
예제 #3
0
파일: XCefInfo.cpp 프로젝트: Zion-007/XCef
// ¶ªÆúkey
static void _dict_to_list(CefRefPtr<CefDictionaryValue> & src, CefRefPtr<CefListValue> & dest)
{
	if (!src.get())
		return;
	if (!dest.get())
		dest = CefListValue::Create();

	CefDictionaryValue::KeyList keys;
	src->GetKeys(keys);

	int idx = 0;
	for (CefString & i : keys)
	{
		switch (src->GetType(i))
		{
		case VTYPE_NULL:
			dest->SetNull(idx);
			break;
		case VTYPE_BOOL:
			dest->SetBool(idx, src->GetBool(i));
			break;
		case VTYPE_INT:
			dest->SetInt(idx, src->GetInt(i));
			break;
		case VTYPE_DOUBLE:
			dest->SetDouble(idx, src->GetDouble(i));
			break;
		case VTYPE_STRING:
			dest->SetString(idx, src->GetString(i));
			break;
		case VTYPE_BINARY:
			dest->SetBinary(idx, src->GetBinary(i));
			break;
		case VTYPE_DICTIONARY:
			dest->SetDictionary(idx, src->GetDictionary(i));
			break;
		case VTYPE_LIST:
			dest->SetList(idx, src->GetList(i));
			break;
		default:
			assert(0);
			break;
		}
		++idx;
	}
}
CefRefPtr<CefV8Value> FUnrealCEFSubProcessRemoteScripting::CefToV8(CefRefPtr<CefDictionaryValue> Dictionary)
{
	// Custom types are encoded inside dictionary values with a $type and a $value property
	if ( Dictionary->GetType("$type") == VTYPE_STRING)
	{
		FString Type = Dictionary->GetString("$type").ToWString().c_str();
		if ( Type == "struct" &&  Dictionary->GetType("$value") == VTYPE_DICTIONARY)
		{
			return CefToPlainV8Object(Dictionary->GetDictionary("$value"));
		}
		if ( Type == "uobject" && Dictionary->GetType("$id") == VTYPE_STRING && Dictionary->GetType("$methods") == VTYPE_LIST)
		{
			FGuid Guid;
			if (FGuid::Parse(Dictionary->GetString("$id").ToWString().c_str(), Guid))
			{
				CefRefPtr<CefListValue> Methods = Dictionary->GetList("$methods");
				return CreateUObjectProxy(Guid, Methods);
			}
		}
	}
	return CefToPlainV8Object(Dictionary);

}
void FUnrealCEFSubProcessRemoteScripting::OnContextCreated(CefRefPtr<CefBrowser> Browser, CefRefPtr<CefFrame> Frame, CefRefPtr<CefV8Context> Context)
{
	ScopedV8Context ContextScope(Context);
	CefRefPtr<CefV8Value> Global = Context->GetGlobal();
	if ( !Global->HasValue("ue") )
	{
		Global->SetValue("ue", CefV8Value::CreateObject(nullptr), V8_PROPERTY_ATTRIBUTE_DONTDELETE);
	}
	CefRefPtr<CefV8Value> RootObject = Context->GetGlobal()->GetValue("ue");

	int32 BrowserID = Browser->GetIdentifier();

	if (PermanentBindings.Contains(BrowserID))
	{
		CefRefPtr<CefDictionaryValue> Bindings = PermanentBindings[BrowserID];
		CefDictionaryValue::KeyList Keys;
		Bindings->GetKeys(Keys);
		for (CefString Key : Keys)
		{
			CefRefPtr<CefV8Value> Value = CefToV8(Bindings->GetDictionary(Key));
			RootObject->SetValue(Key, Value, V8_PROPERTY_ATTRIBUTE_NONE);
		}
	}
}
예제 #6
0
// 根据命令行执行创建浏览器的参数的解析
JWebTopConfigs * JWebTopConfigs::loadAsJSON(wstring jsonString){
	if (jsonString.length() == 0)return loadConfigs(JWebTopConfigs::getAppDefFile(NULL));
	CefRefPtr<CefValue> v = CefParseJSON(CefString(jsonString), JSON_PARSER_RFC);  // 进行解析
	if (v == NULL)return loadConfigs(JWebTopConfigs::getAppDefFile(NULL));
	CefRefPtr<CefDictionaryValue> value = v->GetDictionary();// 按JSON字典来获取
	CefRefPtr<CefValue> tmp= value->GetValue("appDefFile");
	JWebTopConfigs * configs = loadConfigs(JWebTopConfigs::getAppDefFile((tmp != NULL ? LPCTSTR(tmp->GetString().ToWString().c_str()) : NULL)));
	tmp = value->GetValue("parentWinS");
	if (tmp != NULL)configs->parentWin = jw::str::parseLong64(tmp->GetString().ToWString());
	// url,appendJs,name,icon,dwStyle,dwExStyle
	tmp = value->GetValue("url");
	if (tmp != NULL)configs->url = tmp->GetString();
	tmp = value->GetValue("appendJs");
	if (tmp != NULL)configs->appendJs = tmp->GetString();
	tmp = value->GetValue("name");
	if (tmp != NULL)configs->name = tmp->GetString();
	tmp = value->GetValue("icon");
	if (tmp != NULL)configs->icon = tmp->GetString();
	tmp = value->GetValue("dwStyleS");
	if (tmp != NULL)configs->dwStyle = jw::str::parseLong64(tmp->GetString().ToWString());
	tmp = value->GetValue("dwExStyleS");
	if (tmp != NULL)configs->dwExStyle = jw::str::parseLong64(tmp->GetString().ToWString());
	// x,y,w,h,max
	tmp = value->GetValue("x");
	if (tmp != NULL)configs->x = tmp->GetInt();
	tmp = value->GetValue("y");
	if (tmp != NULL)configs->y = tmp->GetInt();
	tmp = value->GetValue("h");
	if (tmp != NULL)configs->h = tmp->GetInt();
	tmp = value->GetValue("w");
	if (tmp != NULL)configs->w = tmp->GetInt();
	tmp = value->GetValue("max");
	if (tmp != NULL)configs->max = tmp->GetInt();
	// enableDebug,enableResize,disableRefresh,enableDrag
	tmp = value->GetValue("enableDebug");
	if (tmp != NULL)configs->enableDebug = (tmp->GetInt()!=0);
	tmp = value->GetValue("enableResize");
	if (tmp != NULL)configs->enableResize = (tmp->GetInt() != 0);
	tmp = value->GetValue("disableRefresh");
	if (tmp != NULL)configs->disableRefresh = (tmp->GetInt() != 0);
	tmp = value->GetValue("enableDrag");
	if (tmp != NULL)configs->enableDrag = (tmp->GetInt() != 0);

	// [CEF]小节:cef配置参数(cef相关参数只在应用启动时起作用),配置在[CEF]小节下
	tmp = value->GetValue("single_process");
	if (tmp != NULL)configs->single_process = tmp->GetInt();
	tmp = value->GetValue("user_data_path");
	if (tmp != NULL)configs->user_data_path = tmp->GetString();
	tmp = value->GetValue("cache_path");
	if (tmp != NULL)configs->cache_path = tmp->GetString();
	tmp = value->GetValue("persist_session_cookies");
	if (tmp != NULL)configs->persist_session_cookies = tmp->GetInt();
	tmp = value->GetValue("user_agent");
	if (tmp != NULL)configs->user_agent = tmp->GetString();
	tmp = value->GetValue("locale");
	if (tmp != NULL)configs->locale = tmp->GetString();
	tmp = value->GetValue("log_severity");
	if (tmp != NULL)configs->log_severity = tmp->GetInt();
	tmp = value->GetValue("log_file");
	if (tmp != NULL)configs->log_file = tmp->GetString();
	tmp = value->GetValue("resources_dir_path");
	if (tmp != NULL)configs->resources_dir_path = tmp->GetString();

	tmp = value->GetValue("locales_dir_path");
	if (tmp != NULL)configs->locales_dir_path = tmp->GetString();
	tmp = value->GetValue("ignore_certificate_errors");
	if (tmp != NULL)configs->ignore_certificate_errors = tmp->GetInt();
	tmp = value->GetValue("remote_debugging_port");
	if (tmp != NULL)configs->remote_debugging_port = tmp->GetInt();
	

	tmp = value->GetValue("proxyServer");
	if (tmp != NULL)configs->proxyServer = tmp->GetString();
	tmp = value->GetValue("proxyAuthUser");
	if (tmp != NULL)configs->proxyAuthUser = tmp->GetString();
	tmp = value->GetValue("proxyAuthPwd");
	if (tmp != NULL)configs->proxyAuthPwd = tmp->GetString();
	tmp = value->GetValue("no_sandbox");
	if (tmp != NULL)configs->no_sandbox = tmp->GetInt();

	return configs;
}
예제 #7
0
CefRefPtr<CefV8Value> CefDictionaryValueToV8Value(
        CefRefPtr<CefDictionaryValue> dictValue,
        int nestingLevel) {
    if (!dictValue->IsValid()) {
        DebugLog("CefDictionaryValueToV8Value() FAILED: " \
                "CefDictionaryValue is invalid");
        return CefV8Value::CreateNull();
    }
    if (nestingLevel > 8) {
        DebugLog("CefDictionaryValueToV8Value(): WARNING: " \
            "max nesting level (8) exceeded");
        return CefV8Value::CreateNull();
    }
    std::vector<CefString> keys;
    if (!dictValue->GetKeys(keys)) {
        DebugLog("CefDictionaryValueToV8Value() FAILED: " \
            "dictValue->GetKeys() failed");
        return CefV8Value::CreateNull();
    }
    CefRefPtr<CefV8Value> ret = CefV8Value::CreateObject(NULL);
    CefRefPtr<CefBinaryValue> binaryValue;
    PythonCallback pyCallback;
    CefRefPtr<CefV8Handler> v8FunctionHandler;
    for (std::vector<CefString>::iterator it = keys.begin(); \
            it != keys.end(); ++it) {
        CefString key = *it;
        cef_value_type_t valueType = dictValue->GetType(key);
        bool success;
        std::string callbackName = "python_callback_";
        if (valueType == VTYPE_NULL) {
            success = ret->SetValue(key,
                    CefV8Value::CreateNull(),
                    V8_PROPERTY_ATTRIBUTE_NONE);
        } else if (valueType == VTYPE_BOOL) {
            success = ret->SetValue(key,
                    CefV8Value::CreateBool(dictValue->GetBool(key)),
                    V8_PROPERTY_ATTRIBUTE_NONE);
        } else if (valueType == VTYPE_INT) {
            success = ret->SetValue(key,
                    CefV8Value::CreateInt(dictValue->GetInt(key)),
                    V8_PROPERTY_ATTRIBUTE_NONE);
        } else if (valueType == VTYPE_DOUBLE) {
            success = ret->SetValue(key,
                    CefV8Value::CreateDouble(dictValue->GetDouble(key)),
                    V8_PROPERTY_ATTRIBUTE_NONE);
        } else if (valueType == VTYPE_STRING) {
            success = ret->SetValue(key,
                    CefV8Value::CreateString(dictValue->GetString(key)),
                    V8_PROPERTY_ATTRIBUTE_NONE);
        } else if (valueType == VTYPE_BINARY) {
            binaryValue = dictValue->GetBinary(key);
            if (binaryValue->GetSize() == sizeof(pyCallback)) {
                binaryValue->GetData(&pyCallback, sizeof(pyCallback), 0);
                v8FunctionHandler = new V8FunctionHandler(
                        NULL, pyCallback.callbackId);
                // You must provide a function name to
                // CefV8Value::CreateFunction(), otherwise it fails.
                callbackName.append(AnyToString(pyCallback.callbackId));
                success = ret->SetValue(key,
                                CefV8Value::CreateFunction(
                                        callbackName, v8FunctionHandler),
                                V8_PROPERTY_ATTRIBUTE_NONE);
            } else {
                DebugLog("CefListValueToV8Value(): WARNING: " \
                        "unknown binary value, setting value to null");
                success = ret->SetValue(key,
                        CefV8Value::CreateNull(),
                        V8_PROPERTY_ATTRIBUTE_NONE);
            }
        } else if (valueType == VTYPE_DICTIONARY) {
            success = ret->SetValue(key,
                    CefDictionaryValueToV8Value(
                            dictValue->GetDictionary(key),
                            nestingLevel + 1),
                    V8_PROPERTY_ATTRIBUTE_NONE);
        } else if (valueType == VTYPE_LIST) {
            success = ret->SetValue(key,
                    CefListValueToV8Value(
                            dictValue->GetList(key),
                            nestingLevel + 1),
                    V8_PROPERTY_ATTRIBUTE_NONE);
        } else {
            DebugLog("CefDictionaryValueToV8Value(): WARNING: " \
                    "unknown type, setting value to null");
            success = ret->SetValue(key,
                    CefV8Value::CreateNull(),
                    V8_PROPERTY_ATTRIBUTE_NONE);
        }
        if (!success) {
            DebugLog("CefDictionaryValueToV8Value(): WARNING: " \
                    "ret->SetValue() failed");
        }
    }
    return ret;
}
예제 #8
0
CefRefPtr<CefV8Value> CefListValueToV8Value(
        CefRefPtr<CefListValue> listValue,
        int nestingLevel) {
    if (!listValue->IsValid()) {
        DebugLog("CefListValueToV8Value() FAILED: " \
                "CefDictionaryValue is invalid");
        return CefV8Value::CreateNull();
    }
    if (nestingLevel > 8) {
        DebugLog("CefListValueToV8Value(): WARNING: " \
            "max nesting level (8) exceeded");
        return CefV8Value::CreateNull();
    }
    int listSize = (int)listValue->GetSize();
    CefRefPtr<CefV8Value> ret = CefV8Value::CreateArray(listSize);
    CefRefPtr<CefBinaryValue> binaryValue;
    PythonCallback pyCallback;
    CefRefPtr<CefV8Handler> v8FunctionHandler;
    for (int key = 0; key < listSize; ++key) {
        cef_value_type_t valueType = listValue->GetType(key);
        bool success;
        std::string callbackName = "python_callback_";
        if (valueType == VTYPE_NULL) {
            success = ret->SetValue(key,
                    CefV8Value::CreateNull());
        } else if (valueType == VTYPE_BOOL) {
            success = ret->SetValue(key,
                    CefV8Value::CreateBool(listValue->GetBool(key)));
        } else if (valueType == VTYPE_INT) {
            success = ret->SetValue(key,
                    CefV8Value::CreateInt(listValue->GetInt(key)));
        } else if (valueType == VTYPE_DOUBLE) {
            success = ret->SetValue(key,
                    CefV8Value::CreateDouble(listValue->GetDouble(key)));
        } else if (valueType == VTYPE_STRING) {
            success = ret->SetValue(key,
                    CefV8Value::CreateString(listValue->GetString(key)));
        } else if (valueType == VTYPE_BINARY) {
            binaryValue = listValue->GetBinary(key);
            if (binaryValue->GetSize() == sizeof(pyCallback)) {
                binaryValue->GetData(&pyCallback, sizeof(pyCallback), 0);
                v8FunctionHandler = new V8FunctionHandler(
                        NULL, pyCallback.callbackId);
                // You must provide a function name to
                // CefV8Value::CreateFunction(), otherwise it fails.
                callbackName.append(AnyToString(pyCallback.callbackId));
                success = ret->SetValue(key,
                                CefV8Value::CreateFunction(
                                        callbackName, v8FunctionHandler));
            } else {
                DebugLog("CefListValueToV8Value(): WARNING: " \
                        "unknown binary value, setting value to null");
                success = ret->SetValue(key, CefV8Value::CreateNull());
            }
        } else if (valueType == VTYPE_DICTIONARY) {
            success = ret->SetValue(key,
                    CefDictionaryValueToV8Value(
                            listValue->GetDictionary(key),
                            nestingLevel + 1));
        } else if (valueType == VTYPE_LIST) {
            success = ret->SetValue(key,
                    CefListValueToV8Value(
                            listValue->GetList(key),
                            nestingLevel + 1));
        } else {
            DebugLog("CefListValueToV8Value(): WARNING: " \
                    "unknown type, setting value to null");
            success = ret->SetValue(key,
                    CefV8Value::CreateNull());
        }
        if (!success) {
            DebugLog("CefListValueToV8Value(): WARNING: " \
                    "ret->SetValue() failed");
        }
    }
    return ret;
}
예제 #9
0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
boost::python::dict CefDictionaryValueToPy( CefRefPtr<CefDictionaryValue> d )
{
	boost::python::dict result;

	CefDictionaryValue::KeyList keys;
	d->GetKeys( keys );

	for( size_t i = 0; i < keys.size(); i++ )
	{
		std::string k = keys[i].ToString();

		switch( d->GetType( keys[i] ) )
		{
			case VTYPE_INT:
			{
				result[k.c_str()] = d->GetInt( keys[i] );
				break;
			}
			case VTYPE_DOUBLE:
			{
				result[k.c_str()] = d->GetDouble( keys[i] );
				break;
			}
			case VTYPE_BOOL:
			{
				result[k.c_str()] = d->GetBool( keys[i] );
				break;
			}
			case VTYPE_STRING:
			{
				result[k.c_str()] = d->GetString( keys[i] ).ToString().c_str();
				break;
			}
			case VTYPE_BINARY:
			{
				WarsCefData_t warsCefData;
				CefRefPtr<CefBinaryValue> binaryData = d->GetBinary( keys[i] );
				binaryData->GetData( &warsCefData, sizeof( warsCefData ), 0 );
				if( warsCefData.type == WARSCEF_TYPE_JSOBJECT )
				{
					WarsCefJSObject_t warsCefJSObject;
					binaryData->GetData( &warsCefJSObject, sizeof( warsCefJSObject ), 0 );

					CefRefPtr<JSObject> jsResultObject = new JSObject( "", warsCefJSObject.uuid );
					result[k.c_str()] = boost::python::object( PyJSObject( jsResultObject ) );
				}
				else
				{
					result[k.c_str()] = boost::python::object();
				}
				break;
			}
			case VTYPE_DICTIONARY:
			{
				result[k.c_str()] = CefDictionaryValueToPy( d->GetDictionary( keys[i] ) );
				break;
			}
			case VTYPE_LIST:
			{
				result[k.c_str()] = CefValueListToPy( d->GetList( keys[i] ) );
				break;
			}
			default:
			{
				result[k.c_str()] = d->GetString( keys[i] ).ToString().c_str();
				break;
			}
		}
	}

	return result;
}
예제 #10
0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
boost::python::list CefValueListToPy( CefRefPtr<CefListValue> l )
{
	boost::python::list result;
	for( size_t i = 0; i < l->GetSize(); i++ )
	{
		switch( l->GetType( i ) )
		{
			case VTYPE_INT:
			{
				result.append( l->GetInt( i ) );
				break;
			}
			case VTYPE_DOUBLE:
			{
				result.append( l->GetDouble( i ) );
				break;
			}
			case VTYPE_BOOL:
			{
				result.append( l->GetBool( i ) );
				break;
			}
			case VTYPE_STRING:
			{
				result.append( l->GetString( i ).ToString().c_str() );
				break;
			}
			case VTYPE_BINARY:
			{
				WarsCefData_t warsCefData;
				l->GetBinary( i )->GetData( &warsCefData, sizeof( warsCefData ), 0 );
				if( warsCefData.type == WARSCEF_TYPE_JSOBJECT )
				{
					WarsCefJSObject_t warsCefJSObject;
					l->GetBinary( i )->GetData( &warsCefJSObject, sizeof( warsCefJSObject ), 0 );

					CefRefPtr<JSObject> jsResultObject = new JSObject( "", warsCefJSObject.uuid );
					result.append( boost::python::object( PyJSObject( jsResultObject ) ) );
				}
				else
				{
					result.append( boost::python::object() );
				}
				break;
			}
			case VTYPE_DICTIONARY:
			{
				result.append( CefDictionaryValueToPy( l->GetDictionary( i ) ) );
				break;
			}
			case VTYPE_LIST:
			{
				result.append( CefValueListToPy( l->GetList( i ) ) );
				break;
			}
			default:
			{
				result.append( l->GetString( i ).ToString().c_str() );
				break;
			}
		}
	}
	return result;
}
예제 #11
0
bool excuteJSON(const CefString& request){
	CefRefPtr<CefValue> v = CefParseJSON(request, JSON_PARSER_RFC);          // 进行解析
	if (v == NULL){
		//callback->Failure(1, CefString(L"错误的JSON格式"));
		return false;
	}
#ifdef JWebTopLog 
	wstringstream log;
	log << L"JWebTopCommons#Handler#OnQuery jsons=" << request.ToWString() << L"\r\n";
	writeLog(log.str());
#endif
	CefRefPtr<CefDictionaryValue> value = v->GetDictionary();// 按JSON字典来获取
	wstring methodName = value->GetString("m").ToWString();  // 取出某字符串 
	 if (methodName == L"loadUrl"){
		CefRefPtr<CefValue> handler = value->GetValue("handler");
		if (handler == NULL)return false;
		CefRefPtr<CefValue> url = value->GetValue("url");
		if (url == NULL)return false;
		jb::loadUrl((HWND)handler->GetInt(), url->GetString().ToWString());
	}
	else if (methodName == L"reload"){
		CefRefPtr<CefValue> handler = value->GetValue("handler");
		if (handler == NULL)return false;
		jb::reload((HWND)handler->GetInt());
	}
	//// (true|false,[handler]);// 允许进行拖动
	//extensionCode << "JWebTop.=function(enable,handler){JWebTop.cefQuery({m:'enableDrag',enable:enable,handler:(handler?handler:JWebTop.handler)})};" << endl;
	//// ([handler]);// 开始进行拖动
	//extensionCode << "JWebTop.=function(handler){JWebTop.cefQuery({m:'startDrag',handler:(handler?handler:JWebTop.handler)})};" << endl;
	//// ([handler]);// 停止拖动
	//extensionCode << "JWebTop.=function(handler){JWebTop.cefQuery({m:'stopDrag',handler:(handler?handler:JWebTop.handler)})};" << endl;
	else if (methodName == L"enableDrag"){
		CefRefPtr<CefValue> handler = value->GetValue("handler");
		if (handler == NULL)return false;
		CefRefPtr<CefValue> enable = value->GetValue("enable");
		if (enable == NULL)return false;
		jb::enableDrag((HWND)handler->GetInt(), enable->GetBool());
	}
	else if (methodName == L"startDrag"){
		CefRefPtr<CefValue> handler = value->GetValue("handler");
		if (handler == NULL)return false;
		jb::startDrag((HWND)handler->GetInt());
	}
	else if (methodName == L"stopDrag"){
		CefRefPtr<CefValue> handler = value->GetValue("handler");
		if (handler == NULL)return false;
		jb::stopDrag((HWND)handler->GetInt());
	}
	else if (methodName == L"reloadIgnoreCache"){
		CefRefPtr<CefValue> handler = value->GetValue("handler");
		if (handler == NULL)return false;
		jb::stopDrag((HWND)handler->GetInt());
	}
	else if (methodName == L"runApp"){
		CefRefPtr<CefValue> handler = value->GetValue("handler");
		if (handler == NULL)return false;
		CefRefPtr<CefValue> app = value->GetValue("app");
		CefRefPtr<CefValue> parentWin = value->GetValue("parentWin");
		jb::runApp((HWND)handler->GetInt(), app->GetString().ToWString(), parentWin == NULL ? 0 : parentWin->GetInt()
			,NULL,NULL,NULL,-1,-1,-1,-1);
	}
	else if (methodName == L"runAppMore"){
		CefRefPtr<CefValue> handler = value->GetValue("handler");
		if (handler == NULL)return false;
		CefRefPtr<CefValue> app = value->GetValue("app");
		CefRefPtr<CefValue> parentWin = value->GetValue("parentWin");
		CefRefPtr<CefValue> url = value->GetValue("url");
		CefRefPtr<CefValue> title = value->GetValue("title");
		CefRefPtr<CefValue> icon = value->GetValue("icon");
		CefRefPtr<CefValue> x = value->GetValue("x");
		CefRefPtr<CefValue> y = value->GetValue("y");
		CefRefPtr<CefValue> w = value->GetValue("w");
		CefRefPtr<CefValue> h = value->GetValue("h");
		jb::runApp((HWND)handler->GetInt(), app->GetString().ToWString(), parentWin == NULL ? 0 : parentWin->GetInt()
			, (url == NULL ? NULL : LPTSTR(url->GetString().ToWString().c_str()))
			, (title == NULL ? NULL : LPTSTR(title->GetString().ToWString().c_str()))
			, (icon == NULL ? NULL : LPTSTR(icon->GetString().ToWString().c_str()))
			, (x == NULL ? -1 : x->GetInt())
			, (y == NULL ? -1 : y->GetInt())
			, (w == NULL ? -1 : w->GetInt())
			, (h == NULL ? -1 : h->GetInt()));
	}
	else if(methodName == L"close"){
		CefRefPtr<CefValue> handler = value->GetValue("handler");
		if (handler == NULL)return false;
		jb::close((HWND)handler->GetInt());
	}
	else if (methodName == L"showDev"){
		CefRefPtr<CefValue> handler = value->GetValue("handler");
		if (handler == NULL)return false;
		jb::showDev((HWND)handler->GetInt());
	}
	else{
		return false;
	}
	return true;
}
bool FUnrealCEFSubProcessRemoteScripting::HandleDeleteValueMessage(CefRefPtr<CefBrowser> Browser, CefRefPtr<CefListValue> MessageArguments)
{
	CefRefPtr<CefFrame> MainFrame = Browser->GetMainFrame();
	CefRefPtr<CefV8Context> Context = MainFrame->GetV8Context();
	ScopedV8Context ContextScope(Context);
	CefRefPtr<CefV8Value> RootObject = Context->GetGlobal()->GetValue("ue");
	if (!RootObject.get())
	{
		// The root object should always be created on context creation.
		return false;
	}

	for (size_t I = 0; I < MessageArguments->GetSize(); I++)
	{
		if (MessageArguments->GetType(I) != VTYPE_DICTIONARY)
		{
			return false;
		}
		CefRefPtr<CefDictionaryValue> Argument = MessageArguments->GetDictionary(I);

		if (Argument->GetType("name") != VTYPE_STRING
			|| Argument->GetType("id") != VTYPE_STRING
			|| Argument->GetType("permanent") != VTYPE_BOOL)
		{
			// Wrong message argument types or count
			return false;
		}

		CefString Name = Argument->GetString("name");
		CefString Id = Argument->GetString("id");
		bool bPermanent = Argument->GetBool("permanent");

		FGuid Guid;
		if (!FGuid::Parse(Id.ToWString().c_str(), Guid))
		{
			return false;
		}

		if (bPermanent)
		{
			int32 BrowserID = Browser->GetIdentifier();
			CefRefPtr<CefDictionaryValue> Bindings;
			if (PermanentBindings.Contains(BrowserID))
			{
				Bindings = PermanentBindings[BrowserID];
				if (!Bindings->HasKey(Name))
				{
					return false;
				}
				if (Guid.IsValid())
				{
					CefRefPtr<CefDictionaryValue> CefValue = Bindings->GetDictionary(Name);
					if (CefValue.get() && CefValue->GetString("$id") != Id)
					{
						return false;
					}
				}
				Bindings->Remove(Name);
			}
		}

		if (!RootObject->HasValue(Name))
		{
			return false;
		}
		if (Guid.IsValid())
		{
			CefRefPtr<CefV8Value> Value = RootObject->GetValue(Name);
			if (!Value->HasValue("$id") || !Value->GetValue("$id")->IsString() || Value->GetValue("$id")->GetStringValue() != Id)
			{
				return false;
			}
		}
		RootObject->DeleteValue(Name);
	}
	return true;

}