- Code: Select all
#include "ClientJsExtensionHandler.h"
#include "common/SystemSetting.h"
#include <json/include/value.h>
#include "include/cef_runnable.h"
bool ClientJsExtensionHandler::Execute(const CefString& name,
CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
CefString& exception){
bool handled = false;
if (name == "restart")
{
SystemSetting t_SystemSetting;
t_SystemSetting.restart();
return true;
}
// Send a message to the browser process.
CefRefPtr<CefBrowser> browser =
CefV8Context::GetCurrentContext()->GetBrowser();
ASSERT(browser.get());
CefRefPtr<CefProcessMessage> message =
CefProcessMessage::Create(name);
int index = 0;
// Translate the arguments, if any.
if (arguments.size() > 0)
{
for each (CefRefPtr<CefV8Value> arg in arguments)
{
JsUtil::SetListValue(message->GetArgumentList(), index, arg);
index++;
}
}
browser->SendProcessMessage(PID_BROWSER, message);
handled = true;
if (!handled)
exception = "Invalid method arguments";
return true;
}
- Code: Select all
void SystemSetting::restart()
{
TCHAR appName[MAX_PATH];
TCHAR configPath[MAX_PATH];
CommonUtil::GetExecuteDirectory(configPath);
wcscat(configPath, L"config.ini");
::GetPrivateProfileString(L"config", L"appName", L"CEF", appName, MAX_PATH, configPath);
HWND hWndPrev = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
while (::IsWindow(hWndPrev))
{
MessageBox(NULL,L"11111::IsWindow(hWndPrev)",L"::IsWindow(hWndPrev)",0);
}
}
it point out “Cannot create windows on non-UI thread!”,and I find it in Chromium31 it is can , it have idea ?