void WebContext::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder) { if (decoder.messageReceiverName() == Messages::WebContext::messageReceiverName()) { didReceiveSyncWebContextMessage(connection, decoder, replyEncoder); return; } if (decoder.messageReceiverName() == WebContextLegacyMessages::messageReceiverName() && decoder.messageName() == WebContextLegacyMessages::postSynchronousMessageMessageName()) { // FIXME: We should probably encode something in the case that the arguments do not decode correctly. WebProcessProxy* process = WebProcessProxy::fromConnection(connection); String messageName; RefPtr<API::Object> messageBody; WebContextUserMessageDecoder messageBodyDecoder(messageBody, *process); if (!decoder.decode(messageName)) return; if (!decoder.decode(messageBodyDecoder)) return; RefPtr<API::Object> returnData; didReceiveSynchronousMessageFromInjectedBundle(messageName, messageBody.get(), returnData); replyEncoder->encode(WebContextUserMessageEncoder(returnData.get(), *process)); return; } ASSERT_NOT_REACHED(); }
void WebProcess::postInjectedBundleMessage(const CoreIPC::DataReference& messageData) { InjectedBundle* injectedBundle = WebProcess::shared().injectedBundle(); if (!injectedBundle) return; OwnPtr<CoreIPC::ArgumentDecoder> decoder = CoreIPC::ArgumentDecoder::create(messageData.data(), messageData.size()); String messageName; if (!decoder->decode(messageName)) return; RefPtr<APIObject> messageBody; InjectedBundleUserMessageDecoder messageBodyDecoder(messageBody); if (!decoder->decode(messageBodyDecoder)) return; injectedBundle->didReceiveMessage(messageName, messageBody.get()); }
void WebContext::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder) { if (decoder.messageReceiverName() == Messages::WebContext::messageReceiverName()) { didReceiveWebContextMessage(connection, decoder); return; } if (decoder.messageReceiverName() == WebContextLegacyMessages::messageReceiverName() && decoder.messageName() == WebContextLegacyMessages::postMessageMessageName()) { String messageName; RefPtr<API::Object> messageBody; WebContextUserMessageDecoder messageBodyDecoder(messageBody, *WebProcessProxy::fromConnection(connection)); if (!decoder.decode(messageName)) return; if (!decoder.decode(messageBodyDecoder)) return; didReceiveMessageFromInjectedBundle(messageName, messageBody.get()); return; } ASSERT_NOT_REACHED(); }
bool WebConnectionToUIProcess::decodeMessageBody(CoreIPC::ArgumentDecoder& decoder, RefPtr<API::Object>& messageBody) { InjectedBundleUserMessageDecoder messageBodyDecoder(messageBody); return decoder.decode(messageBodyDecoder); }