bool ClientHandler::OnProcessMessageReceived(
    CefRefPtr<CefBrowser> browser,
    CefProcessId source_process,
    CefRefPtr<CefProcessMessage> message) {
  bool handled = false;
  
  // Check for callbacks first
  if (message->GetName() == "executeCommandCallback") {
    int32 commandId = message->GetArgumentList()->GetInt(0);
    bool result = message->GetArgumentList()->GetBool(1);
    
    CefRefPtr<CommandCallback> callback = command_callback_map_[commandId];
    callback->CommandComplete(result);
    command_callback_map_.erase(commandId);
    
    handled = true;
  }
  
  // Execute delegate callbacks.
  ProcessMessageDelegateSet::iterator it = process_message_delegates_.begin();
  for (; it != process_message_delegates_.end() && !handled; ++it) {
    handled = (*it)->OnProcessMessageReceived(this, browser, source_process,
                                              message);
  }
    
  return handled;
}
Пример #2
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;
}
Пример #3
0
bool V8FunctionHandler::Execute(const CefString& functionName,
                        CefRefPtr<CefV8Value> thisObject,
                        const CefV8ValueList& v8Arguments,
                        CefRefPtr<CefV8Value>& returnValue,
                        CefString& exception) {
    if (!CefV8Context::InContext()) {
        // CefV8Context::GetCurrentContext may not be called when
        // not in a V8 context.
        DebugLog("Renderer: V8FunctionHandler::Execute() FAILED:"\
                " not inside a V8 context");
        return false;
    }
    CefRefPtr<CefV8Context> context =  CefV8Context::GetCurrentContext();
    CefRefPtr<CefBrowser> browser = context.get()->GetBrowser();
    CefRefPtr<CefFrame> frame = context.get()->GetFrame();
    if (pythonCallbackId_) {
        DebugLog("Renderer: V8FunctionHandler::Execute(): python callback");
        CefRefPtr<CefListValue> functionArguments = V8ValueListToCefListValue(
                v8Arguments);
        CefRefPtr<CefProcessMessage> processMessage = \
                CefProcessMessage::Create("ExecutePythonCallback");
        CefRefPtr<CefListValue> messageArguments = \
                processMessage->GetArgumentList();
        messageArguments->SetInt(0, pythonCallbackId_);
        messageArguments->SetList(1, functionArguments);
        browser->SendProcessMessage(PID_BROWSER, processMessage);
        returnValue = CefV8Value::CreateNull();
        return true;
    } else {
        DebugLog("Renderer: V8FunctionHandler::Execute(): js binding");
        if (!(cefPythonApp_.get() \
                && cefPythonApp_->BindedFunctionExists( \
                        browser, functionName))) {
            exception = std::string("[CEF Python] " \
                    "V8FunctionHandler::Execute() FAILED: " \
                    "function does not exist: ").append(functionName) \
                    .append("()");
            // Must return true for the exception to be thrown.
            return true;
        }
        CefRefPtr<CefListValue> functionArguments = V8ValueListToCefListValue(
                v8Arguments);
        // TODO: losing int64 precision here.
        int frameId = (int)frame->GetIdentifier();
        CefRefPtr<CefProcessMessage> processMessage = \
                CefProcessMessage::Create("V8FunctionHandler::Execute");
        CefRefPtr<CefListValue> messageArguments = \
                processMessage->GetArgumentList();
        messageArguments->SetInt(0, frameId);
        messageArguments->SetString(1, functionName);
        messageArguments->SetList(2, functionArguments);
        browser->SendProcessMessage(PID_BROWSER, processMessage);
        returnValue = CefV8Value::CreateNull();
        return true;
    }
}
Пример #4
0
bool ClientHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
                                             CefProcessId source_process,
                                             CefRefPtr<CefProcessMessage> message) {
    // Check the message name.
    const std::string& message_name = message->GetName();

    if (message_name == "MethodCall") {
        const auto arguments = message->GetArgumentList();

        const auto methodName = arguments.get()->GetString(0).ToString();
        const auto json = arguments.get()->GetString(1).ToString();
        const auto callId = arguments.get()->GetInt(2);

        std::cout << "MethodCall id " << callId << " " << methodName << " " << json << std::endl;
        // Handle the message here...

        QJsonParseError parseError;
        QJsonDocument jsonDoc = QJsonDocument::fromJson(QByteArray::fromStdString(json), &parseError);
        if (parseError.error != QJsonParseError::NoError) {
            qDebug() << "JSON Error:" << parseError.errorString();
            return false;
        }
        const auto argsArray = jsonDoc.array();

        const auto bridge = static_cast<Shell*>(qApp)->bridge;

        std::vector<std::string> attempts;

        #include "cg/ClientSlot.cppf"

        if (!attempts.empty()) {
            const char* const delim = "\n";

            std::ostringstream imploded;
            std::copy(attempts.begin(), attempts.end(),
                      std::ostream_iterator<std::string>(imploded, delim));
            CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("CallFailed");
            CefRefPtr<CefListValue> args = msg->GetArgumentList();

            args->SetInt(0, callId);

            // To keep the string version of the JSON value escaped
            // here to use the functionality provided by QDebug
            QString tmpStr;
            QDebug(&tmpStr) << QString::fromStdString(imploded.str()); // Have to cast to QString first, otherwise mojibake
            args->SetString(1, tmpStr.toStdString());

            browser->SendProcessMessage(PID_RENDERER, msg);
            return true;
        }

        return false;
    }
    return false;
}
bool ClientHandler::SendJSCommand(CefRefPtr<CefBrowser> browser, const CefString& commandName, CefRefPtr<CommandCallback> callback)
{
  CefRefPtr<CefProcessMessage> message = CefProcessMessage::Create("executeCommand");
  message->GetArgumentList()->SetString(0, commandName);

  if (callback) {
    callbackId++;
    command_callback_map_[callbackId] = callback;
    message->GetArgumentList()->SetInt(1, callbackId);
  }

  return browser->SendProcessMessage(PID_RENDERER, message);
}
Пример #6
0
bool FWebJSScripting::OnProcessMessageReceived(CefRefPtr<CefBrowser> Browser, CefProcessId SourceProcess, CefRefPtr<CefProcessMessage> Message)
{
	bool Result = false;
	FString MessageName = Message->GetName().ToWString().c_str();
	if (MessageName == TEXT("UE::ExecuteUObjectMethod"))
	{
		Result = HandleExecuteUObjectMethodMessage(Message->GetArgumentList());
	}
	else if (MessageName == TEXT("UE::ReleaseUObject"))
	{
		Result = HandleReleaseUObjectMessage(Message->GetArgumentList());
	}
	return Result;
}
Пример #7
0
// ------------------------------------ //
// ThriveJSMessageHandler
bool
    ThriveJSMessageHandler::OnProcessMessageReceived(
        CefRefPtr<CefBrowser> browser,
        CefProcessId source_process,
        CefRefPtr<CefProcessMessage> message)
{
    const auto args = message->GetArgumentList();
    const auto& customType = args->GetString(0);

    if(customType == "startNewGame") {

        LOG_INFO("Got start game message from GUI process");
        ThriveGame::Get()->startNewGame();
        return true;

    } else if(customType == "editorButtonClicked") {

        ThriveGame::Get()->editorButtonClicked();
        return true;

    } else if(customType == "finishEditingClicked") {

        ThriveGame::Get()->finishEditingClicked();
        return true;
    }

    // Not ours
    return false;
}
Пример #8
0
bool WindowClient::OnProcessMessageReceived(
    CefRefPtr<CefBrowser> browser,
    CefProcessId source_process,
    CefRefPtr<CefProcessMessage> message
) {
    if (message->GetName() == "quit") {
        s_result = message->GetArgumentList()->GetInt(0);
        printf("Quitting with value %d\n", s_result);
        printf("Log:\n%S", message->GetArgumentList()->GetString(1).ToWString().c_str());

        CloseAllBrowsers();
    } else {
        printf("Unknown message %s\n", message->GetName().ToString().c_str());
    }
    return false;
}
bool ClientHandler::OnProcessMessageReceived(
    CefRefPtr<CefBrowser> browser,
    CefProcessId source_process,
    CefRefPtr<CefProcessMessage> message) {
  // Check for messages from the client renderer.
  std::string message_name = message->GetName();
  if (message_name == client_renderer::kFocusedNodeChangedMessage) {
    // A message is sent from ClientRenderDelegate to tell us whether the
    // currently focused DOM node is editable. Use of |m_bFocusOnEditableField|
    // is redundant with CefKeyEvent.focus_on_editable_field in OnPreKeyEvent
    // but is useful for demonstration purposes.
    m_bFocusOnEditableField = message->GetArgumentList()->GetBool(0);
    return true;
  }

  bool handled = false;

  // Execute delegate callbacks.
  ProcessMessageDelegateSet::iterator it = process_message_delegates_.begin();
  for (; it != process_message_delegates_.end() && !handled; ++it) {
    handled = (*it)->OnProcessMessageReceived(this, browser, source_process,
                                              message);
  }

  return handled;
}
void CloseLiveBrowser(CefRefPtr<CefBrowser> browser, CefRefPtr<CefProcessMessage> response)
{
    const char *killall = "killall -9 %s";
    gchar *cmdline;
    gint exitstatus;
    GError *gerror = NULL;
    int error = NO_ERROR;
    CefRefPtr<CefListValue> responseArgs = response->GetArgumentList();

    // check for supported browsers (in PATH directories)
    for (size_t i = 0; i < sizeof(browsers) / sizeof(browsers[0]); i++) {
        cmdline = g_strdup_printf(killall, browsers[i].c_str());

        // FIXME (jasonsanjose): use async
        if (!g_spawn_command_line_sync(cmdline, NULL, NULL, &exitstatus, &gerror)) {
            error = ConvertGnomeErrorCode(gerror);
            g_error_free(gerror);
        }

        g_free(cmdline);

        // browser is found in os; stop iterating
        if (exitstatus == 0) {
            error = NO_ERROR;
            break;
        }
    }

    responseArgs->SetInt(1, error);
    browser->SendProcessMessage(PID_RENDERER, response);
}
Пример #11
0
void FWebJSScripting::BindUObject(const FString& Name, UObject* Object, bool bIsPermanent)
{
	CefRefPtr<CefDictionaryValue> Converted = ConvertObject(Object);
	if (bIsPermanent)
	{
		// Each object can only have one permanent binding
		if (BoundObjects[Object].bIsPermanent)
		{
			return;
		}
		// Existing permanent objects must be removed first
		if (PermanentUObjectsByName.Contains(Name))
		{
			return;
		}
		BoundObjects[Object]={true, -1};
		PermanentUObjectsByName.Add(Name, Object);
	}

	CefRefPtr<CefProcessMessage> SetValueMessage = CefProcessMessage::Create(TEXT("UE::SetValue"));
	CefRefPtr<CefListValue>MessageArguments = SetValueMessage->GetArgumentList();
	CefRefPtr<CefDictionaryValue> Value = CefDictionaryValue::Create();
	Value->SetString("name", *Name);
	Value->SetDictionary("value", Converted);
	Value->SetBool("permanent", bIsPermanent);

	MessageArguments->SetDictionary(0, Value);
	SendProcessMessage(SetValueMessage);
}
Пример #12
0
void BrowserWindow::SetCefBrowser(CefRefPtr<CefBrowser> cefBrowser) {
    // Called from ClientHandler::OnAfterCreated().
    _ASSERT(!cefBrowser_);
    if (cefBrowser_) {
        LOG_ERROR << "BrowserWindow::SetCefBrowser() called, "
                  << "but it is already set";
        return;
    }
    cefBrowser_ = cefBrowser;
    fullscreen_.reset(new Fullscreen(cefBrowser));
    json_value* appSettings = GetApplicationSettings();
    if (!IsPopup()) {
        bool start_fullscreen = (*appSettings)["main_window"]["start_fullscreen"];
        if (start_fullscreen) {
            fullscreen_->ToggleFullscreen();
            CefRefPtr<CefProcessMessage> message = \
                    CefProcessMessage::Create("SetIsFullscreen");
            message->GetArgumentList()->SetBool(0, fullscreen_->IsFullscreen());
            cefBrowser->SendProcessMessage(PID_RENDERER, message);
        }
    }

    // OnSize was called from WM_SIZE, but cefBrowser_ was not yet
    // set, so the window wasn't yet positioned correctly.
    this->OnSize();
}
// Destructor will notify the client that the uobject is no longer being referenced on the JS side
FUnrealCEFSubProcessRemoteObject::~FUnrealCEFSubProcessRemoteObject()
{
	CefRefPtr<CefProcessMessage> Message = CefProcessMessage::Create("UE::ReleaseUObject");
	CefRefPtr<CefListValue> MessageArguments = Message->GetArgumentList();
	MessageArguments->SetString(0, CefString(*ObjectId.ToString(EGuidFormats::Digits)));
	Browser->SendProcessMessage(PID_BROWSER, Message);
}
Пример #14
0
void FWebJSScripting::UnbindUObject(const FString& Name, UObject* Object, bool bIsPermanent)
{
	if (bIsPermanent)
	{
		// If overriding an existing permanent object, make it non-permanent
		if (PermanentUObjectsByName.Contains(Name) && (Object == nullptr || PermanentUObjectsByName[Name] == Object))
		{
			Object = PermanentUObjectsByName.FindAndRemoveChecked(Name);
			BoundObjects.Remove(Object);
			return;
		}
		else
		{
			return;
		}
	}

	CefRefPtr<CefProcessMessage> DeleteValueMessage = CefProcessMessage::Create(TEXT("UE::DeleteValue"));
	CefRefPtr<CefListValue>MessageArguments = DeleteValueMessage->GetArgumentList();
	CefRefPtr<CefDictionaryValue> Info = CefDictionaryValue::Create();
	Info->SetString("name", *Name);
	Info->SetString("id", *PtrToGuid(Object).ToString(EGuidFormats::Digits));
	Info->SetBool("permanent", bIsPermanent);

	MessageArguments->SetDictionary(0, Info);
	SendProcessMessage(DeleteValueMessage);
}
bool RenderProcessHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
                                                    CefProcessId source_process,
                                                    CefRefPtr<CefProcessMessage> message) {
    const auto& messageName = message->GetName();
    if (messageName == "SignalEmit") {
        CefRefPtr<CefFrame> frame = browser->GetMainFrame();

        // [signalName: str, resultArray: jsonStr]
        const auto arguments = message->GetArgumentList();
        std::string exec = "onSignalEmit(\"" +
                           arguments->GetString(0).ToString() + "\", " +
                           arguments->GetString(1).ToString() + ");";
        LOG(INFO) << "EXEC " << exec;
        frame->ExecuteJavaScript(exec, frame->GetURL(), 0);
        return true;
    }

    if (messageName == "CallReturn") {
        CefRefPtr<CefFrame> frame = browser->GetMainFrame();

        // [callId: int, resultArray: jsonStr]
        const auto arguments = message->GetArgumentList();
        std::ostringstream exec;
        exec << "onCallReturn(" <<
        arguments->GetInt(0) << ", " <<
        arguments->GetString(1).ToString() << ");";
        LOG(INFO) << "EXEC " << exec.str();
        frame->ExecuteJavaScript(exec.str(), frame->GetURL(), 0);
        return true;
    }

    if (messageName == "CallFailed") {
        CefRefPtr<CefFrame> frame = browser->GetMainFrame();

        // [callId: int, resultArray: jsonStr]
        const auto arguments = message->GetArgumentList();
        std::ostringstream exec;
        exec << "onCallFailed(" <<
        arguments->GetInt(0) << ", " <<
        arguments->GetString(1).ToString() << ");";
        LOG(INFO) << "EXEC " << exec.str();
        frame->ExecuteJavaScript(exec.str(), frame->GetURL(), 0);
        return true;
    }

    return false;
}
void IPC_Container::ReadContainerObjectsAndWriteToIPCMsg(
    CefRefPtr<CefV8Context> context,
    std::string container_array_variable,
    std::vector<int> amounts,
    int64 frameID,
    CefRefPtr<CefProcessMessage> msg
    )
{
    CefRefPtr<CefListValue> args = msg->GetArgumentList();
    int index = 0;

    // Write frameID at position #0
    args->SetDouble(index++, (double) frameID);

    // Write different amount of different node types at position #1
    args->SetInt(index++, amounts.size());

    // Write amount of each node type at first positions
    for (int i = 0; i < (int)amounts.size(); i++)
    {
        args->SetInt(index++, amounts[i]);
    }

    if (context->Enter())
    {
        int all_objects_done = 0;

        for (int i = 0; i < (int)amounts.size(); i++)
        {
            // Read each container object
            for (int j = 0; j < amounts[i]; j++)
            {
                // Read every attribute and get their value
                for (int k = 0; k < (int)_scheme.size(); k++)
                {
                    // DLOG(INFO) << "Reading object #" << j << ", Attribute #" << k  << "), writing to IPC args index #" << index;

                    // Get each attribute as V8Value
                    CefRefPtr<CefV8Value> attribute = GetAttributesV8Value( // TODO: There HAS TO BE a bug concerning the object's position in the array
                                                        context,
                                                        container_array_variable,
                                                        j+all_objects_done,
                                                        _scheme[k]
                                                        );

                    // Write each attribute to IPC message
                    SetIPCArgumentsValue(
                        args,
                        index,
                        attribute,
                        _scheme[k]
                        );
                }
            }
            all_objects_done += amounts[i];
        }
        context->Exit();
    }
}
Пример #17
0
bool ClientApp::OnProcessMessageReceived(
    CefRefPtr<CefBrowser> browser,
    CefProcessId source_process,
    CefRefPtr<CefProcessMessage> message) {
  ASSERT(source_process == PID_BROWSER);

  bool handled = false;

  RenderDelegateSet::iterator it = render_delegates_.begin();
  for (; it != render_delegates_.end() && !handled; ++it) {
    handled = (*it)->OnProcessMessageReceived(this, browser, source_process,
                                              message);
  }

  if (handled)
    return true;

  // Execute the registered JavaScript callback if any.
  if (!callback_map_.empty()) {
    CefString message_name = message->GetName();
    CallbackMap::const_iterator it = callback_map_.find(
        std::make_pair(message_name.ToString(),
                       browser->GetIdentifier()));
    if (it != callback_map_.end()) {
      // Keep a local reference to the objects. The callback may remove itself
      // from the callback map.
      CefRefPtr<CefV8Context> context = it->second.first;
      CefRefPtr<CefV8Value> callback = it->second.second;

      // Enter the context.
      context->Enter();

      CefV8ValueList arguments;

      // First argument is the message name.
      arguments.push_back(CefV8Value::CreateString(message_name));

      // Second argument is the list of message arguments.
      CefRefPtr<CefListValue> list = message->GetArgumentList();
      CefRefPtr<CefV8Value> args =
          CefV8Value::CreateArray(static_cast<int>(list->GetSize()));
      SetList(list, args);
      arguments.push_back(args);

      // Execute the callback.
      CefRefPtr<CefV8Value> retval = callback->ExecuteFunction(NULL, arguments);
      if (retval.get()) {
        if (retval->IsBool())
          handled = retval->GetBoolValue();
      }

      // Exit the context.
      context->Exit();
    }
  }

  return handled;
}
Пример #18
0
bool BrowserClient::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message)
{
	
	FString name = FString(UTF8_TO_TCHAR(message->GetArgumentList()->GetString(0).c_str()));
	FString data;
	FString type = FString(UTF8_TO_TCHAR(message->GetArgumentList()->GetString(2).c_str()));
	FString data_type = FString(UTF8_TO_TCHAR(message->GetArgumentList()->GetString(3).c_str()));

	if (type == "js_event")
	{

		// Check the datatype

		if (data_type == "bool")
			data = message->GetArgumentList()->GetBool(1) ? TEXT("true") : TEXT("false");
		else if (data_type == "int")
			data = FString::FromInt(message->GetArgumentList()->GetInt(1));
		else if (data_type == "string")
			data = FString(UTF8_TO_TCHAR(message->GetArgumentList()->GetString(1).c_str()));
		else if (data_type == "double")
			data = FString::SanitizeFloat(message->GetArgumentList()->GetDouble(1));

		event_emitter->Broadcast(name, data);
	}

	return true;

}
Пример #19
0
void WebView::ExecuteJSHook(const char* InHookName, ICefRuntimeVariantList* InArguments)
{
	CefRefPtr<CefProcessMessage> Message = CefProcessMessage::Create(InHookName);
	if (InArguments)
	{
		SetCefListFromVariantList(Message->GetArgumentList(), InArguments);
	}
	Client->GetBrowser()->SendProcessMessage(PID_RENDERER, Message);
}
Пример #20
0
void FWebJSScripting::InvokeJSFunction(FGuid FunctionId, const CefRefPtr<CefListValue>& FunctionArguments, bool bIsError)
{
	CefRefPtr<CefProcessMessage> Message = CefProcessMessage::Create(TEXT("UE::ExecuteJSFunction"));
	CefRefPtr<CefListValue> MessageArguments = Message->GetArgumentList();
	MessageArguments->SetString(0, *FunctionId.ToString(EGuidFormats::Digits));
	MessageArguments->SetList(1, FunctionArguments);
	MessageArguments->SetBool(2, bIsError);
	SendProcessMessage(Message);
}
Пример #21
0
void RenderProcessApp::SendCall(const CefString& json)
{
	CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create(invoke_host_call);
	CefRefPtr<CefListValue> args = msg->GetArgumentList();

	args->SetString(0, json);
	
	m_pBrowser->SendProcessMessage(PID_BROWSER, msg);
}
Пример #22
0
bool ClientApp::Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception)
{
	CefRefPtr<CefProcessMessage> message = CefProcessMessage::Create(name);
	CefRefPtr<CefListValue> par = message->GetArgumentList();
	V8ValueListToCefListValue(arguments, par);
	CefRefPtr<CefBrowser> browser = CefV8Context::GetCurrentContext()->GetBrowser();
	if (browser) browser->SendProcessMessage(PID_BROWSER, message);	
	return true;
}
Пример #23
0
void Application::OnFocusedNodeChanged(
	CefRefPtr<CefBrowser> InBrowser,
	CefRefPtr<CefFrame> InFrame,
	CefRefPtr<CefDOMNode> InNode)
{
	bool IsEditableNode = InNode.get() && InNode->IsEditable();

	CefRefPtr<CefProcessMessage> Message = CefProcessMessage::Create(RADUIIPCMSG_FOCUSNODECHANGED);
	Message->GetArgumentList()->SetBool(0, IsEditableNode);
	InBrowser->SendProcessMessage(PID_BROWSER, Message);
}
bool FUnrealCEFSubProcessRemoteScripting::OnProcessMessageReceived(CefRefPtr<CefBrowser> Browser,
    CefProcessId SourceProcess,
    CefRefPtr<CefProcessMessage> Message)
{
	bool Result = false;
	FString MessageName = Message->GetName().ToWString().c_str();
	if (MessageName == TEXT("UE::ExecuteJSFunction"))
	{
		Result = HandleExecuteJSFunctionMessage(Message->GetArgumentList());
	}
	else if (MessageName == TEXT("UE::SetValue"))
	{
		Result = HandleSetValueMessage(Browser, Message->GetArgumentList());
	}
	else if (MessageName == TEXT("UE::DeleteValue"))
	{
		Result = HandleDeleteValueMessage(Browser, Message->GetArgumentList());
	}

	return Result;
}
Пример #25
0
void CWebAppRenderer::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node)
{
    bool is_editable = (node.get() && node->IsEditable());
    if (is_editable != m_lastNodeIsEditable)
    {
      // Notify the browser of the change in focused element type.
      m_lastNodeIsEditable = is_editable;
      CefRefPtr<CefProcessMessage> message = CefProcessMessage::Create(RendererMessage::FocusedNodeChanged);
      message->GetArgumentList()->SetBool(0, is_editable);
      browser->SendProcessMessage(PID_BROWSER, message);
    }

}
Пример #26
0
bool BrowserClient::OnProcessMessageReceived(
	CefRefPtr<CefBrowser> browser,
	CefProcessId source_process,
	CefRefPtr<CefProcessMessage> message)
{
	const std::string& message_name = message->GetName();
	if (message_name == "getCurrentScene") {

		int callbackID = message->GetArgumentList()->GetInt(0);

		const char* jsonString = browserOBSBridge->GetCurrentSceneJSONData();

		CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("executeCallback");
		CefRefPtr<CefListValue> args = msg->GetArgumentList();
		args->SetInt(0, callbackID);
		args->SetString(1, jsonString);

		browser->SendProcessMessage(PID_RENDERER, msg);

		return true;
	}
	return false;
}
void MoveFileOrDirectoryToTrash(ExtensionString filename, CefRefPtr<CefBrowser> browser, CefRefPtr<CefProcessMessage> response)
{
    int error = NO_ERROR;
    GFile *file = g_file_new_for_path(filename.c_str());
    GError *gerror = NULL;
    if (!g_file_trash(file, NULL, &gerror)) {
        error = ConvertGnomeErrorCode(gerror);
        g_error_free(gerror);
    }
    g_object_unref(file);
    
    response->GetArgumentList()->SetInt(1, error);
    browser->SendProcessMessage(PID_RENDERER, response);
}
Пример #28
0
bool QCefView::sendEVentNotifyMessage(int frameId, const QString& name, const QCefEvent& event)
{
	CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create(
		TRIGGEREVENT_NOTIFY_MESSAGE);
	CefRefPtr<CefListValue> arguments = msg->GetArgumentList();

	int idx = 0;
	arguments->SetInt(idx++, frameId);

	CefString eventName = name.toStdString();
	arguments->SetString(idx++, eventName);

	CefRefPtr<CefDictionaryValue> dict = CefDictionaryValue::Create();

	CefString cefStr;
	cefStr.FromWString(event.objectName().toStdWString());
	dict->SetString("name", cefStr);

	QList<QByteArray> keys = event.dynamicPropertyNames();
	for (QByteArray key : keys)
	{
		QVariant value = event.property(key.data());
		if (value.type() == QMetaType::Bool)
		{
			dict->SetBool(key.data(), value.toBool());
		}
		else if (value.type() == QMetaType::Int || value.type() == QMetaType::UInt)
		{
			dict->SetInt(key.data(), value.toInt());
		}
		else if (value.type() == QMetaType::Double)
		{
			dict->SetDouble(key.data(), value.toDouble());
		}
		else if (value.type() == QMetaType::QString)
		{
			cefStr.FromWString(value.toString().toStdWString());
			dict->SetString(key.data(), cefStr);
		}
		else
		{
			__noop(_T("QCefView"), _T("Unknow Type!"));
		}
	}

	arguments->SetDictionary(idx++, dict);

	return cefWindow_->cefViewHandler()->TriggerEvent(msg);
}
Пример #29
0
void FWebJSScripting::InvokeJSFunction(FGuid FunctionId, int32 ArgCount, FWebJSParam Arguments[], bool bIsError)
{
	CefRefPtr<CefListValue> FunctionArguments = CefListValue::Create();
	for ( int32 i=0; i<ArgCount; i++)
	{
		SetConverted(FunctionArguments, i, Arguments[i]);
	}

	CefRefPtr<CefProcessMessage> Message = CefProcessMessage::Create(TEXT("UE::ExecuteJSFunction"));
	CefRefPtr<CefListValue> MessageArguments = Message->GetArgumentList();
	MessageArguments->SetString(0, *FunctionId.ToString(EGuidFormats::Digits));
	MessageArguments->SetList(1, FunctionArguments);
	MessageArguments->SetBool(2, bIsError);
	SendProcessMessage(Message);
}
void ClientRenderDelegate::OnFocusedNodeChanged(
  CefRefPtr<ApkAnalyzerApp> app,
  CefRefPtr<CefBrowser> browser,
  CefRefPtr<CefFrame> frame,
  CefRefPtr<CefDOMNode> node) {
  bool is_editable = (node.get() && node->IsEditable());
  if (is_editable != last_node_is_editable_) {
    // Notify the browser of the change in focused element type.
    last_node_is_editable_ = is_editable;
    CefRefPtr<CefProcessMessage> message =
      CefProcessMessage::Create(kFocusedNodeChangedMessage);
    message->GetArgumentList()->SetBool(0, is_editable);
    browser->SendProcessMessage(PID_BROWSER, message);
  }
}