예제 #1
0
bool Application::Execute(
    const CefString& name,
    CefRefPtr<CefV8Value> object,
    const CefV8ValueList& arguments,
    CefRefPtr<CefV8Value>& retval,
    CefString& exception
) {
    if (name == "exit") {
        printf("Exiting with value %d!\n", arguments[0]->GetIntValue());
        this->firstBrowser = NULL;
        // see http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=891 for the 'right' way to do this
        CefRefPtr<CefProcessMessage> message = CefProcessMessage::Create("quit");
        message->GetArgumentList()->SetInt(0, arguments[0]->GetIntValue());
        message->GetArgumentList()->SetString(1, this->outBuffer);
        if(CefV8Context::GetEnteredContext()->GetBrowser()->SendProcessMessage(PID_BROWSER, message)) {
            printf("Got true from quit send process\n");
        } else { 
            printf("Got false from quit send process message\n");
        }
        return true;

    } else if (name == "open") {

    } else if (name == "openWindow") {
        CefPostTask(
            TID_UI,
            NewCefRunnableFunction(&noOpenWindow)
            );
        return true;

    } else if (name == "nop") {
        return true;

    } else if (name == "log") {
        /*if (object->IsSame(this->leprechaunObj)) {
            // Figure out if we need this some day...
            return false;
        }*/
        std::wstringstream ss;
        for (size_t i = 0; i < arguments.size(); ++i) {
            ss << arguments[i]->GetStringValue().ToWString();
        }
        printf("Got log: %S\n", ss.str().c_str());
        return true;
    } else if (name == "echo") {
        std::wstringstream ss;
        for (size_t i = 0; i < arguments.size(); ++i) {
            ss << arguments[i]->GetStringValue().ToWString();
        }
	this->outBuffer += ss.str().c_str();
	this->outBuffer += L"\n";
        return true;
    } else if (name == "onerror") {
        return true;
    }

    return false;
}
예제 #2
0
bool ClientHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception)
{
    if (name == "ChangeTextInJS") {
        if (arguments.size() == 1 && arguments[0]->IsString()) {
            CefString text = arguments[0]->GetStringValue();

            CefRefPtr<CefFrame> frame = this->GetBrowser()->GetMainFrame();

            std::string jscall = "ChangeText('";
            jscall += text;
            jscall += "');";

            frame->ExecuteJavaScript(jscall, frame->GetURL(), 0);

            /*
            * If you want your method to return a value, just use retval, like this:
            * retval = CefV8Value::CreateString("Hello World!");
            * you can use any CefV8Value, what means you can return arrays, objects or whatever you can create with CefV8Value::Create* methods
            */

            return true;
        }
    }

    return false;
}
예제 #3
0
// Transfer a V8 vector to a list
void SetList(const CefV8ValueList& source, CefRefPtr<CefListValue> target)
{
    int arg_length = source.size();
    if (arg_length == 0)
        return;
    target->SetSize(arg_length);
    for (int i = 0; i < arg_length; ++i)
        SetListValue(target, i, source[i]);
}
CefRefPtr<CefListValue> FUnrealCEFSubProcessRemoteScripting::V8ArrayToCef(const CefV8ValueList& Values)
{
	CefRefPtr<CefListValue> Result = CefListValue::Create();
	for (size_t I = 0; I < Values.size(); ++I)
	{
		V8ToCef(Result, nullptr, I, Values[I]);
	}
	return Result;
}
예제 #5
0
bool CSJsSocket::Execute(const CefString& name,  CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,  CefRefPtr<CefV8Value>& retval, CefString& exception)
{
    if (name == "connect")
    {
        if (arguments.size() == 2)
        {
            bool result = Connect(arguments[0]->GetStringValue(), arguments[1]->GetIntValue());
            retval = CefV8Value::CreateBool(result);
            return true;
        }        
    }
    else if (name == "send")
    {
        if (arguments.size() == 1)
        {
            std::string data = arguments[0]->GetStringValue().ToString();
            int size = Write(data.c_str(), data.size());
            retval = CefV8Value::CreateInt(size);
            return true;
        }
    }
    else if (name == "close")
    {
        Close();
    }
    else if (name == "onopen")
    {
        if (arguments.size() == 1)
        {
            mOpenCallback = arguments[0];
            mOpenContext = CefV8Context::GetCurrentContext();
        }
    }
    else if (name == "onmessage")
    {
        if (arguments.size() == 1)
        {
            mReadCallback = arguments[0];
            mReadContext = CefV8Context::GetCurrentContext();
        }
    }
    else if (name == "onclose")
    {
        if (arguments.size() == 1)
        {
            mCloseCallback = arguments[0];
            mCloseContext = CefV8Context::GetCurrentContext();
        }        
    }
    else if (name == "onerror")
    {
        if (arguments.size() == 1)
        {
            mErrorCallback = arguments[0];
            mErrorContext = CefV8Context::GetCurrentContext();
        }        
    }
    
    return false;
}
예제 #6
0
 // Execute with the specified argument list and return value.  Return true if
 // the method was handled.
 virtual bool Execute(const CefString& name,
                      CefRefPtr<CefV8Value> object,
                      const CefV8ValueList& arguments,
                      CefRefPtr<CefV8Value>& retval,
                      CefString& exception)
 {
   if(name == "Dummy")
   {
     // Used for performance testing.
     return true;
   }
   else if(name == "SetTestParam")
   {
     // Handle the SetTestParam native function by saving the string argument
     // into the local member.
     if(arguments.size() != 1 || !arguments[0]->IsString())
       return false;
     
     test_param_ = arguments[0]->GetStringValue();
     return true;
   }
   else if(name == "GetTestParam")
   {
     // Handle the GetTestParam native function by returning the local member
     // value.
     retval = CefV8Value::CreateString(test_param_);
     return true;
   }
   else if(name == "GetTestObject")
   {
     // Handle the GetTestObject native function by creating and returning a
     // new V8 object.
     retval = CefV8Value::CreateObject(NULL, NULL);
     // Add a string parameter to the new V8 object.
     retval->SetValue("param", CefV8Value::CreateString(
         "Retrieving a parameter on a native object succeeded."),
         V8_PROPERTY_ATTRIBUTE_NONE);
     // Add a function to the new V8 object.
     retval->SetValue("GetMessage",
         CefV8Value::CreateFunction("GetMessage", this),
         V8_PROPERTY_ATTRIBUTE_NONE);
     return true;
   }
   else if(name == "GetMessage")
   {
     // Handle the GetMessage object function by returning a string.
     retval = CefV8Value::CreateString(
         "Calling a function on a native object succeeded.");
     return true;
   }
   return false;
 }
예제 #7
0
bool Application::Execute( const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception )
{
    if(name == "exec" && arguments.size() == 4)
    {
        std::string service = arguments[0]->GetStringValue().ToString();
        std::string action  = arguments[1]->GetStringValue().ToString();
        std::string callbackId = arguments[2]->GetStringValue().ToString();
        std::string rawArgs = arguments[3]->GetStringValue().ToString();
        _pluginManager->exec(service, action, callbackId, rawArgs);
        return true;
    }
    return false;
}
예제 #8
0
void ClientApp::V8ValueListToCefListValue(const CefV8ValueList& src, CefRefPtr<CefListValue> & dst) 
{
    for (unsigned i = 0; i < src.size(); i++) 
    {
		if (!src[i]->IsValid())							{ dst->SetString(dst->GetSize(),"Invalid V8Value");			continue;}
		if (src[i]->IsUndefined() || src[i]->IsNull())	{ dst->SetNull(dst->GetSize()); 							continue;}
		if (src[i]->IsBool()) 							{ dst->SetBool(dst->GetSize(),	src[i]->GetBoolValue());	continue;}
		if (src[i]->IsInt()) 							{ dst->SetInt(dst->GetSize(),	src[i]->GetIntValue());		continue;}
		if (src[i]->IsDouble()) 						{ dst->SetDouble(dst->GetSize(),src[i]->GetDoubleValue());	continue;}
		if (src[i]->IsString()) 						{ dst->SetString(dst->GetSize(),src[i]->GetStringValue());	continue;}
		
		dst->SetString(dst->GetSize(), "Unimplemented V8Value conversion");
    }
}
예제 #9
0
파일: cefmouse.cpp 프로젝트: Croydon/code
bool InexorCefMouseManager::Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception)
{
    CEF_REQUIRE_RENDERER_THREAD();
    if (name == "show") {
        Show();
        return true;
    } else if (name == "hide") {
        Hide();
        return true;
    } else if (name == "setTexture") {
        if (arguments.size() == 2 && arguments[0]->IsString() && arguments[1]->IsInt()) {
            SetTexture(arguments[0]->GetStringValue().ToString(), arguments[1]->GetIntValue());
            return true;
        }
    }
    return false;
}
예제 #10
0
  // Execute with the specified argument list and return value.  Return true if
  // the method was handled.
  virtual bool Execute(const CefString& name,
                       CefRefPtr<CefV8Value> object,
                       const CefV8ValueList& arguments,
                       CefRefPtr<CefV8Value>& retval,
                       CefString& exception)
  {
    if(name == "modifyRotation") {
      // This function requires one argument.
      if(arguments.size() != 1)
        return false;

      float increment = 0.;
      if(arguments[0]->IsInt()) {
        // The argument is an integer value.
        increment = static_cast<float>(arguments[0]->GetIntValue());
      } else if(arguments[0]->IsDouble()) {
        // The argument is an double value.
        increment = static_cast<float>(arguments[0]->GetDoubleValue());
      }

      if(increment != 0.) {
        // Modify the rotation accordingly.
        ModifyRotation(increment);
        return true;
      }
    } else if(name == "resetRotation") {
      // Reset the rotation value.
      ResetRotation();
      return true;
    } else if(name == "viewSource") {
      // View the page source.
      AppGetBrowser()->GetMainFrame()->ViewSource();
      return true;
    }

    return false;
  }
bool CefJSHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception)
{
	// 当Web中调用了"NimCefWebFunction"函数后,会触发到这里,然后把参数保存,转发到Broswer进程
	// Broswer进程的BrowserHandler类在OnProcessMessageReceived接口中处理kJsCallbackMessage消息,就可以收到这个消息

	if (arguments.size() < 2)
	{
		exception = "Invalid arguments.";
		return false;
	}

	CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
	CefRefPtr<CefFrame> frame = context->GetFrame();
	CefRefPtr<CefBrowser> browser = context->GetBrowser();

	int64_t browser_id = browser->GetIdentifier();
	int64_t frame_id = frame->GetIdentifier();

	if (name == "call")
	{
		// 允许没有参数列表的调用,第二个参数为回调
		// 如果传递了参数列表,那么回调是第三个参数
		CefString function_name = arguments[0]->GetStringValue();
		CefString params = "{}";
		CefRefPtr<CefV8Value> callback;
		if (arguments[0]->IsString() && arguments[1]->IsFunction())
		{
			callback = arguments[1];
		}
		else if (arguments[0]->IsString() && arguments[1]->IsString() && arguments[2]->IsFunction())
		{
			params = arguments[1]->GetStringValue();
			callback = arguments[2];
		}
		else
		{
			exception = "Invalid arguments.";
			return false;
		}

		// 执行 C++ 方法
		if (!js_bridge_->CallCppFunction(function_name, params, callback))
		{
			exception = nbase::StringPrintf("Failed to call function %s.", function_name).c_str();
			return false;
		}

		return true;
	}
	else if (name == "register")
	{
		if (arguments[0]->IsString() && arguments[1]->IsFunction())
		{
			std::string function_name = arguments[0]->GetStringValue();
			CefRefPtr<CefV8Value> callback = arguments[1];
			if (!js_bridge_->RegisterJSFunc(function_name, callback))
			{
				exception = "Failed to register function.";
				return false;
			}
			return true;
		}
		else
		{
			exception = "Invalid arguments.";
			return false;
		}
	}

	return false;
}
예제 #12
0
bool CSJsUi::Execute(const CefString& name,  CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,  CefRefPtr<CefV8Value>& retval, CefString& exception)
{
    if (name == "startMove")
    {
        mWindow->StartMove();
		retval = CefV8Value::CreateNull();
		return true;
    }
    else if (name == "stopMove")
    {
        mWindow->StopMove();
		retval = CefV8Value::CreateNull();
		return true;        
    }
    else if (name == "startResize")
    {
        mWindow->StartResize();
		retval = CefV8Value::CreateNull();
		return true;            
    }
    else if (name == "stopResize")
    {
        mWindow->StopResize();
		retval = CefV8Value::CreateNull();
		return true;            
    }
    else if (name == "show")
    {
		if (arguments.size() == 1)
		{
			CefRefPtr<CefV8Value> showWindow = arguments[0];
			bool show = showWindow->GetBoolValue();
            mWindow->Show(show);
		}
		retval = CefV8Value::CreateNull();
		return true;            
    }
    else if (name == "close")
    {
        mWindow->Close();
		retval = CefV8Value::CreateNull();
		return true;            
    }
    else if (name == "setSize")
    {
        if (arguments.size() == 2)
        {
            int width = arguments[0]->GetIntValue();
            int height = arguments[1]->GetIntValue();
            mWindow->SetSize(width, height);
            retval = CefV8Value::CreateNull();
            return true;            
        }
    }
    else if (name == "move")
    {
        if (arguments.size() == 2)
        {
            int x = arguments[0]->GetIntValue();
            int y = arguments[1]->GetIntValue();
            mWindow->SetPos(x, y);
            retval = CefV8Value::CreateNull();
            return true;            
        }
    }
    else if (name == "screenSize")
    {
        int width, height;
        mWindow->GetScreenSize(width, height);
        CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(NULL, NULL);
        obj->SetValue("width", CefV8Value::CreateInt(width), V8_PROPERTY_ATTRIBUTE_READONLY);
        obj->SetValue("height", CefV8Value::CreateInt(height), V8_PROPERTY_ATTRIBUTE_READONLY);
        retval = obj;
        return true;        
    }
    else if (name == "createWindow")
    {
        if (arguments.size() == 1)
        {
            std::string url = arguments[0]->GetStringValue().ToString();
            CSLogDebug("createWindow(%s)", url.c_str());
            CSWindow *window = new CSWindow(url.c_str());
            window->Show(false);
            retval = CefV8Value::CreateNull();
            return true;            
        }
    }
    else if (name == "menu")
    {
        if (arguments.size() == 1)
        {
            retval = CSJsMenu::CreateMenu(arguments[0]->GetStringValue());
            return true;
        }
    }
    else if (name == "mainMenu")
    {
        retval = CSJsMenu::GetMainMenu();
        return true;
    }
    
    return false;
}
예제 #13
0
//--------------------------------------------------------------
bool ofxCEFV8ExtensionHandler::Execute(const CefString &name,
                                       CefRefPtr<CefV8Value> object,
                                       const CefV8ValueList &arguments,
                                       CefRefPtr<CefV8Value> &retval,
                                       CefString &exception)
{
    if (name == "sendMessageToOF") {
        if (arguments.size() == 2 && arguments[0]->IsString()) {
            CefString type;
            
            if (arguments[1]->IsString()) {
                type = "string";
            }
            else if (arguments[1]->IsDouble()) {
                type = "double";
            }
            else if (arguments[1]->IsInt()) {
                type = "int";
            }
            else if (arguments[1]->IsBool()) {
                type = "bool";
            }
            else {
                std::cout << "ofxCEFV8ExtensionHandler received a message of unknown type." << std::endl;
                return false;
            }
            
            // Create the message object.
            CefRefPtr<CefProcessMessage> message = CefProcessMessage::Create(type);
            
            // Retrieve the argument list object.
            CefRefPtr<CefListValue> args = message->GetArgumentList();
            
            // Message mane
            args->SetString(0, arguments[0]->GetStringValue());
            
            // Message value
            if (type == "string") {
                args->SetString(1, arguments[1]->GetStringValue());
            }
            else if (type == "double") {
                args->SetDouble(1, arguments[1]->GetDoubleValue());
            }
            else if (type == "int") {
                args->SetInt(1, arguments[1]->GetIntValue());
            }
            else if (type == "bool") {
                args->SetBool(1, arguments[1]->GetBoolValue());
            }
            
            // Send message
            CefRefPtr<CefBrowser> browser = CefV8Context::GetCurrentContext()->GetBrowser();
            browser->SendProcessMessage(PID_BROWSER, message);
            return true;
            
        }
    }
    else if (name == "sendMessageWithTypeToOF") {
        if (arguments.size() == 3 && arguments[0]->IsString() && arguments[1]->IsString()) {
            // Populate the argument values.
            CefString type = arguments[0]->GetStringValue();
            
            // Create the message object.
            CefRefPtr<CefProcessMessage> message = CefProcessMessage::Create(type);
            
            // Retrieve the argument list object.
            CefRefPtr<CefListValue> args = message->GetArgumentList();
            
            // Message mane
            args->SetString(0, arguments[1]->GetStringValue());
            
            // Message value
            if (type == "string") {
                args->SetString(1, arguments[2]->GetStringValue());
            }
            else if (type == "double") {
                args->SetDouble(1, arguments[2]->GetDoubleValue());
            }
            else if (type == "int") {
                args->SetInt(1, arguments[2]->GetIntValue());
            }
            else if (type == "bool") {
                args->SetBool(1, arguments[2]->GetBoolValue());
            }
            else {
                std::cout << "ofxCEFV8ExtensionHandler received a message of unknown type." << std::endl;
                return false;
            }
            
            // Send message
            CefRefPtr<CefBrowser> browser = CefV8Context::GetCurrentContext()->GetBrowser();
            browser->SendProcessMessage(PID_BROWSER, message);
            return true;

         }
    }

    return false;
}
bool ClientHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception)
{
	if (name == "db_exec") {
		if (arguments.size() == 1 && arguments[0]->IsString()) {			
			CefString stmt = arguments[0]->GetStringValue();			
			sqlite3 *db; char *err;
			if (sqlite3_open("myDB.db", &db)) {
				retval = CefV8Value::CreateString("ERROR: FAILED to open SQLite db!");
			} else {						
				if (sqlite3_exec(db, std::string(stmt).c_str(), NULL, NULL, &err)) {				
					retval = CefV8Value::CreateString(std::string("ERROR: ") + sqlite3_errmsg(db));		
				} else {
					retval = CefV8Value::CreateString(std::string("SUCCESS: [db_exec] ") + std::string(stmt));
				}						
			}
			sqlite3_close(db);
		} else {
			retval = CefV8Value::CreateString("ERROR: Empty/invalid query string.");
		}
		return true;
	}

	if (name == "db_select") {
		if (arguments.size() == 1 && arguments[0]->IsString()) {			
			CefString stmt = arguments[0]->GetStringValue();
			sqlite3 *db; char *err;
			if (sqlite3_open("myDB.db", &db)) {
				retval = CefV8Value::CreateString("ERROR: FAILED to open SQLite db!");
			} else {				
				char **results = NULL;
				int rows, columns;				
				if (sqlite3_get_table(db, std::string(stmt).c_str(), &results, &rows, &columns, &err)) {				
					retval = CefV8Value::CreateString(sqlite3_errmsg(db));		
				} else {
					std::string jsonStr = "[";
					for (int rowCtr = 1; rowCtr <= rows; ++rowCtr)
					{
						jsonStr += "{";
						for (int colCtr = 0; colCtr < columns; ++colCtr)
						{							
							int cellPosition = (rowCtr * columns) + colCtr;
							int cellPositionHeader = (0 * columns) + colCtr;
							jsonStr += std::string("\"") + results[cellPositionHeader] + std::string("\": \"") + results[cellPosition] + std::string("\"");							
							jsonStr += (colCtr!=columns-1) ? "," : "";
						}
						jsonStr += (rowCtr<rows) ? "}," : "}";
					}
					jsonStr += "]";
					sqlite3_free_table(results);					
					retval = CefV8Value::CreateString(jsonStr);								
				}						
			}
			sqlite3_close(db);
		} else {
			retval = CefV8Value::CreateString("ERROR: Empty/invalid query string.");
		}
		return true;
	}	
    
    return false;
}
예제 #15
0
	virtual bool Execute(const CefString& InName,
		CefRefPtr<CefV8Value> InObject,
		const CefV8ValueList& InArguments,
		CefRefPtr<CefV8Value>& OutRetval,
		CefString& OutException)
	{
		bool Handled = false;
		bool ValidAPI = true;

		if (InName == "TriggerEvent")
		{
			// dispatch hook to the browser process for execution on the game thread
			if ((InArguments.size() == 1) && InArguments[0]->IsArray())
			{
				CefRefPtr<CefV8Value> ArgumentArray = InArguments[0];
				if (ArgumentArray->GetArrayLength() > 0)
				{
					CefRefPtr<CefBrowser> Browser = CefV8Context::GetCurrentContext()->GetBrowser();
					ASSERT(Browser.get());

					CefString HookName = ArgumentArray->GetValue(0)->GetStringValue();
					if (!HookName.empty())
					{
						CefRefPtr<CefProcessMessage> Message = CefProcessMessage::Create(HookName);

						// translate remaining args.
						if ((ArgumentArray->GetArrayLength() > 1) && ArgumentArray->GetValue(1)->IsArray())
						{
							CefRefPtr<CefV8Value> InParameters = ArgumentArray->GetValue(1);
							const int NumParameters = InParameters->GetArrayLength();

							CefRefPtr<CefListValue> OutParameters = Message->GetArgumentList();
							OutParameters->SetSize(NumParameters);

							for (int i = 0; i < (int)NumParameters; ++i)
							{
								V8ValueToListItem_RenderThread(InParameters->GetValue(i), OutParameters, i);
							}
						}

						Browser->SendProcessMessage(PID_BROWSER, Message);
						Handled = true;
					}
				}
			}
		}
		else if (InName == "SetHook")
		{
			if ((InArguments.size() == 2) && (InArguments[0]->IsString()) && (InArguments[1]->IsFunction()))
			{
				CefString HookName = InArguments[0]->GetStringValue().ToString();
				CefRefPtr<CefV8Context> Context = CefV8Context::GetCurrentContext();
				App->SetJSHook(HookName, Context->GetBrowser()->GetIdentifier(), Context, InArguments[1]);
				Handled = true;
			}
		}
		else if (InName == "RemoveHook")
		{
			if ((InArguments.size() == 1) && InArguments[0]->IsString())
			{
				CefRefPtr<CefV8Context> Context = CefV8Context::GetCurrentContext();
				App->RemoveJSHook(InArguments[0]->GetStringValue(), Context->GetBrowser()->GetIdentifier());
				Handled = true;
			}
		}
		else
		{
			ValidAPI = false;
			OutException = std::string("Unrecognized JSHook API Call: '") + InName.ToString() + std::string("'");
		}

		if (!Handled && ValidAPI)
		{
			OutException = std::string("Invalid Arguments Passed To '") + InName.ToString() + std::string("'");
		}

		return Handled;
	}
예제 #16
0
bool CMyV8Handler::Execute( const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception )
{
	if (name==_T("configInfo"))
	{
		retval= CefV8Value::CreateString(CefString(configInfo()));
		return true;
	}
	if (name==_T("clearPassword"))
	{
		GetUserDb()->DeleteUserInfo();
		return true;
	}
	if (name==_T("changeHost"))
	{
		if (arguments.size()>0&&arguments[0]->IsString())
		{
			CString strContent;
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			if(strContent.GetLength()>2)
				strContent=strContent.Mid(1,strContent.GetLength()-2);
			CString strTemp;
			if (COssApi::m_strHost!=_T(""))
				strTemp.Format(_T("\"%s\""),COssApi::m_strHost.c_str());
			else
				strTemp.Format(_T("\"%s\""),GetStaroneControl()->ChangeHost(wstring(strContent)).c_str());
			retval= CefV8Value::CreateString(CefString(strTemp));
		}
		return true;
	}
	if (name==_T("loadFinish"))
	{
		GetStaroneControl()->m_bLoadFinish=TRUE;
		return true;
	}
	if (name==_T("showAuthorizationDlg"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
		}
		CefRefPtr<CefV8Value> func=NULL;
		if (arguments.size()>1)
			func=arguments[1];
		Handler_Msg *hmsg=new Handler_Msg;
		hmsg->strJson=strContent;
		hmsg->v8Ctx=CefV8Context::GetCurrentContext();
		hmsg->vObject=object;
		hmsg->vFunc=func;
		CWebBaseDlg::m_HanderMsg.push_back(hmsg);
		CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
		CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgshowAuthorizationDlg"));
		CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
		msglist->SetInt(0,(int)hmsg);
		browser->SendProcessMessage(PID_RENDERER,msg);
		return true;
	}
	if (name==_T("showWnd"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgMain"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("closeWnd"))
	{
		CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
		CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgcloseWnd"));
		browser->SendProcessMessage(PID_RENDERER,msg);
		return true;
	}
	if (name==_T("setClipboardData"))
	{
		if (arguments.size()>0&&arguments[0]->IsString())
		{
			CString strContent;
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			if(strContent.GetLength()>2)
				strContent=strContent.Mid(1,strContent.GetLength()-2);
			if(OpenClipboard(NULL)) 
			{   
				HGLOBAL clipbuffer; 
				char   *buffer; 
				EmptyClipboard(); 
				clipbuffer=GlobalAlloc(GMEM_DDESHARE,strContent.GetLength()*2+2); 
				buffer=(char *)GlobalLock(clipbuffer);
				memset(buffer,0,strContent.GetLength()*2+2);
				memcpy(buffer,strContent.GetBuffer(0),strContent.GetLength()*2);
				GlobalUnlock(clipbuffer); 
				SetClipboardData(CF_UNICODETEXT,clipbuffer); 
				CloseClipboard();
			}
		}
		return true;
	}
	if (name==_T("showLaunchpad"))
	{
		GetStaroenHummerDlg()->ShowLauchpad();
		return true;
	}
	if (name==_T("getAccessID"))
	{
		CString strTemp;
		strTemp.Format(_T("\"%s\""),GetStaroneControl()->m_UserInfo.strAccessID);
		retval= CefV8Value::CreateString(CefString(strTemp));
		return true;
	}
	if (name==_T("getSignature"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CString strTemp;
			strTemp.Format(_T("\"%s\""),GetSignature(strContent));
			retval= CefV8Value::CreateString(CefString(strTemp));
		}
		return true;
	}
	if (name==_T("getRamSignature"))
	{
		CString strCmd;
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strCmd.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
		}
		if(arguments.size()>1&&arguments[1]->IsString())
		{
			strContent.Format(_T("%s"),arguments[1]->GetStringValue().c_str());
		}
		CString strTemp;
		strTemp.Format(_T("\"%s\""),getRamSignature(strCmd,strContent));
		retval= CefV8Value::CreateString(CefString(strTemp));
		return true;
	}
	if (name==_T("addFile"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgaddFile"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("saveFile"))
	{
		if (arguments.size()>=1&&arguments[0]->IsString())
		{
			CString strContent;
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgsaveFile"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("saveFileDlg"))
	{
		if (arguments.size()==1)
		{
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>0)
				func=arguments[0];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=_T("");
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgsaveFileDlg"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("selectFileDlg"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgselectFileDlg"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("getUpload"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
		}
		retval = CefV8Value::CreateString(CefString(getUpload(strContent)));
		return true;
	}
	if (name==_T("getDownload"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
		}
		retval = CefV8Value::CreateString(CefString(getDownload(strContent)));
		return true;
	}
	if (name==_T("startUpload"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			CHandlerTask *pTask=new CHandlerTask;
			pTask->Init(CefV8Context::GetCurrentContext(),object,func,strContent,_T("startUpload"));
			GetStaroneControl()->m_ThreadPool.AddTask(pTask);
		}
		return true;
	}
	if (name==_T("startDownload"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			CHandlerTask *pTask=new CHandlerTask;
			pTask->Init(CefV8Context::GetCurrentContext(),object,func,strContent,_T("startDownload"));
			GetStaroneControl()->m_ThreadPool.AddTask(pTask);
		}
		return true;
	}
	if (name==_T("stopUpload"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			CHandlerTask *pTask=new CHandlerTask;
			pTask->Init(CefV8Context::GetCurrentContext(),object,func,strContent,_T("stopUpload"));
			GetStaroneControl()->m_ThreadPool.AddTask(pTask);
		}
		return true;
	}
	if (name==_T("stopDownload"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			CHandlerTask *pTask=new CHandlerTask;
			pTask->Init(CefV8Context::GetCurrentContext(),object,func,strContent,_T("stopDownload"));
			GetStaroneControl()->m_ThreadPool.AddTask(pTask);
		}
		return true;
	}
	if (name==_T("deleteUpload"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			CHandlerTask *pTask=new CHandlerTask;
			pTask->Init(CefV8Context::GetCurrentContext(),object,func,strContent,_T("deleteUpload"));
			GetStaroneControl()->m_ThreadPool.AddTask(pTask);
		}
		return true;
	}
	if (name==_T("deleteDownload"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			CHandlerTask *pTask=new CHandlerTask;
			pTask->Init(CefV8Context::GetCurrentContext(),object,func,strContent,_T("deleteDownload"));
			GetStaroneControl()->m_ThreadPool.AddTask(pTask);
		}
		return true;
	}
	if (name==_T("setMetaObject"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			CHandlerTask *pTask=new CHandlerTask;
			pTask->Init(CefV8Context::GetCurrentContext(),object,func,strContent,_T("setMetaObject"));
			GetStaroneControl()->m_ThreadPool.AddTask(pTask);
		}
		return true;
	}
	if (name==_T("getClipboardData"))
	{
		retval = CefV8Value::CreateString(CefString(getClipboardData()));
		return true;
	}
	if (name==_T("getDragFiles"))
	{
		CString strContent=_T("{\"list\":[");
		for (int i=0;i<GetStaroneControl()->m_strDragList.size();i++)
		{
			if (i!=0)
				strContent+=_T(",");
			CString str;
			str.Format(_T("{\"path\":\"%s\"}"),slnhelper::ReplaceToJson(GetStaroneControl()->m_strDragList[i]));
			strContent+=str;
		}
		strContent+=_T("]}");
		retval = CefV8Value::CreateString(CefString(strContent));
		return true;
	}
	if (name==_T("deleteObject"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgdeleteObject"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("copyObject"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgcopyObject"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("changeUpload"))
	{
		CString strContent;
		CefRefPtr<CefV8Value> func=NULL;
		if(arguments.size()>0&&arguments[0]->IsString())
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
		if (arguments.size()>1)
			func=arguments[1];
		GetCallbackUploadThread()->SetCallbackStatus(CefV8Context::GetCurrentContext(),object,func,strContent);
		return true;
	}
	if (name==_T("changeDownload"))
	{
		CString strContent;
		CefRefPtr<CefV8Value> func=NULL;
		if(arguments.size()>0&&arguments[0]->IsString())
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
		if (arguments.size()>1)
			func=arguments[1];
		GetCallbackDownloadThread()->SetCallbackStatus(CefV8Context::GetCurrentContext(),object,func,strContent);
		return true;
	}
	if (name==_T("getErrorLog"))
	{
		retval = CefV8Value::CreateString(CefString(getErrorLog()));
		return true;
	}
	if (name==_T("loginByKey"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgloginByKey"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("loginByFile"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgloginByFile"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("setPassword"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgsetPassword"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("loginPassword"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgloginPassword"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("setServerLocation"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgsetServerLocation"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("saveAuthorization"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgsaveAuthorization"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("getDeviceEncoding"))
	{
		CString strDevice=CRsa::GetDevice();
		wstring hash=L"";
		if (strDevice!=_T(""))
			hash=slnhelper::getstringhash(wstring(strDevice));
		CString strRet;
		strRet.Format(_T("\"%s\""),hash.c_str());
		retval = CefV8Value::CreateString(CefString(strRet));
		return true;
	}
	if (name==_T("getUIPath"))
	{
		CString strRet=_T("");
		if (GetUserDb()->GetUIPath()!=_T(""))
			strRet.Format(_T("\"%s\""),slnhelper::ReplaceToJson(GetUserDb()->GetUIPath()));
		else
			strRet.Format(_T("\"%s\""),slnhelper::ReplaceToJson(GetStaroneControl()->m_strUIPath));
		retval= CefV8Value::CreateString(CefString(strRet));
		return true;
	}
	if (name==_T("openLogFolder"))
	{
		ShellExecute(NULL,_T("open"),GetStaroneControl()->m_strUserConfig+_T("\\log"),NULL,NULL, SW_SHOW);
		return true;
	}
	if (name==_T("deleteBucket"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			CefRefPtr<CefV8Value> func=NULL;
			if (arguments.size()>1)
				func=arguments[1];
			Handler_Msg *hmsg=new Handler_Msg;
			hmsg->strJson=strContent;
			hmsg->v8Ctx=CefV8Context::GetCurrentContext();
			hmsg->vObject=object;
			hmsg->vFunc=func;
			CWebBaseDlg::m_HanderMsg.push_back(hmsg);
			CefRefPtr<CefBrowser> browser=CefV8Context::GetCurrentContext()->GetBrowser();
			CefRefPtr<CefProcessMessage> msg=CefProcessMessage::Create(_T("msgdeleteBucket"));
			CefRefPtr<CefListValue>msglist=msg->GetArgumentList();
			msglist->SetInt(0,(int)hmsg);
			browser->SendProcessMessage(PID_RENDERER,msg);
		}
		return true;
	}
	if (name==_T("setTransInfo"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			setTransInfo(strContent);
		}
		return true;
	}
	if (name==_T("getTransInfo"))
	{
		retval = CefV8Value::CreateString(CefString(getTransInfo()));
		return true;
	}
	if (name==_T("getCurrentLocation"))
	{
		CString strTemp=_T("");
		if (GetStaroneControl()->m_UserInfo.strArea!=_T(""))
		{
			strTemp.Format(_T("\"%s\""),GetStaroneControl()->m_UserInfo.strArea);
		}
		retval = CefV8Value::CreateString(CefString(strTemp));
		return true;
	}
	if (name==_T("getCurrentHost"))
	{
		CString strTemp=_T("");
		if (GetStaroneControl()->m_UserInfo.strHost!=_T(""))
		{
			strTemp.Format(_T("\"%s\""),GetStaroneControl()->m_UserInfo.strHost);
		}
		retval = CefV8Value::CreateString(CefString(strTemp));
		return true;
	}
	if (name==_T("stopLoadDownload"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			stopLoadDownload(strContent);
		}
		return true;
	}
	if (name==_T("openUrl")) 
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			openUrl(strContent);
		}
		return true;
	}
	if (name==_T("setCallFunctionInfo"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			setCallFunctionInfo(strContent);
		}
		return true;
	}
	if (name==_T("getCallFunctionInfo"))
	{
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
			retval = CefV8Value::CreateString(CefString(getCallFunctionInfo(strContent)));
		}
		return true;
	}
	if (name==_T("gGetLanguage"))
	{
		retval = CefV8Value::CreateString(CefString(gGetLanguage()));
		return true;
	}
	if (name==_T("gChangeLanguage"))
	{
		CString strContent=_T("");
		if(arguments.size()>0&&arguments[0]->IsString())
			strContent.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
		gChangeLanguage(strContent);
		return true;
	}
	if (name==_T("gAccountAction"))
	{
		CString strCmd;
		CString strContent;
		if(arguments.size()>0&&arguments[0]->IsString())
		{
			strCmd.Format(_T("%s"),arguments[0]->GetStringValue().c_str());
		}
		if(arguments.size()>1&&arguments[1]->IsString())
		{
			strContent.Format(_T("%s"),arguments[1]->GetStringValue().c_str());
		}
		retval = CefV8Value::CreateString(CefString(gAccountAction(strCmd,strContent)));
		return true;
	}
	return false;
}
예제 #17
0
bool BluScriptHandler::Execute(const CefString& name,
	CefRefPtr<CefV8Value> object,
	const CefV8ValueList& arguments,
	CefRefPtr<CefV8Value>& retval,
	CefString& exception)
{

	// CEF_REQUIRE_RENDERER_THREAD();

	// Our event function
	if (name == "blu_event") {

		if (arguments.size() < 2)
		{
			exception = "Invalid number of arguments! (two required)";
			return true;
		}

		if (!arguments[0]->IsString())
		{
			exception = "Parameter 1 must be a string!";
			return true;
		}

		// Get the first argument as a string, used for the event name
		CefString event_name = arguments[0]->GetStringValue();

		CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("blu_event");

		// Event ID
		msg->GetArgumentList()->SetString(0, event_name);

		// Now we need to see what type of data they passed
		if (arguments[1]->IsBool())
		{
			msg->GetArgumentList()->SetBool(1, arguments[1]->GetBoolValue());
			msg->GetArgumentList()->SetString(3, "bool");
		}
		else if (arguments[1]->IsString())
		{
			msg->GetArgumentList()->SetString(1, arguments[1]->GetStringValue());
			msg->GetArgumentList()->SetString(3, "string");
		}
		else if (arguments[1]->IsDouble())
		{
			msg->GetArgumentList()->SetDouble(1, arguments[1]->GetDoubleValue());
			msg->GetArgumentList()->SetString(3, "double");
		}
		else if (arguments[1]->IsInt())
		{
			msg->GetArgumentList()->SetInt(1, arguments[1]->GetIntValue());
			msg->GetArgumentList()->SetString(3, "int");
		}
		else
		{
			exception = "Parameter 2 - unsupported type! (int, double, string and bool only)";
			return true;
		}


		// Set the type of the event for UE4 to parse
		msg->GetArgumentList()->SetString(2, "js_event");

		if (browser == nullptr)
		{
			exception = "Browser pointer at NULL";
			return true;
		}

		// Send the message to the browser process
		browser->SendProcessMessage(PID_BROWSER, msg);

		// return a true value in js context
		retval = CefV8Value::CreateBool(true);

		// We're done
		return true;
	}

	// Function does not exist.
	return false;
}