void WebSoupRequestManager::didHandleURIRequest(const CoreIPC::DataReference& requestData, uint64_t contentLength, const String& mimeType, uint64_t requestID)
{
    WebSoupRequestAsyncData* data = m_requestMap.get(requestID);
    ASSERT(data);
    GRefPtr<GSimpleAsyncResult> result = data->releaseResult();
    ASSERT(result.get());

    GRefPtr<WebKitSoupRequestGeneric> request = adoptGRef(WEBKIT_SOUP_REQUEST_GENERIC(g_async_result_get_source_object(G_ASYNC_RESULT(result.get()))));
    webkitSoupRequestGenericSetContentLength(request.get(), contentLength ? contentLength : -1);
    webkitSoupRequestGenericSetContentType(request.get(), !mimeType.isEmpty() ? mimeType.utf8().data() : 0);

    GInputStream* dataStream;
    if (!requestData.size()) {
        // Empty reply, just create and empty GMemoryInputStream.
        dataStream = g_memory_input_stream_new();
        m_requestMap.remove(requestID);
    } else if (requestData.size() == contentLength) {
        // We don't expect more data, so we can just create a GMemoryInputStream with all the data.
        dataStream = g_memory_input_stream_new_from_data(g_memdup(requestData.data(), requestData.size()), contentLength, g_free);
        m_requestMap.remove(requestID);
    } else {
        // We expect more data chunks from the UI process.
        dataStream = webkitSoupRequestInputStreamNew(contentLength);
        data->stream = dataStream;
        webkitSoupRequestInputStreamAddData(WEBKIT_SOUP_REQUEST_INPUT_STREAM(dataStream), requestData.data(), requestData.size());
    }
    g_simple_async_result_set_op_res_gpointer(result.get(), dataStream, g_object_unref);
    g_simple_async_result_complete(result.get());
}
void PluginControllerProxy::manualStreamDidReceiveData(const CoreIPC::DataReference& data)
{
    if (m_pluginCanceledManualStreamLoad)
        return;

    m_plugin->manualStreamDidReceiveData(reinterpret_cast<const char*>(data.data()), data.size());
}
Пример #3
0
static PassRefPtr<WebData> createWebData(const CoreIPC::DataReference& data)
{
    if (data.isEmpty())
        return 0;

    return WebData::create(data.data(), data.size());
}
Пример #4
0
bool NetworkResourceLoadParameters::decode(CoreIPC::ArgumentDecoder* decoder, NetworkResourceLoadParameters& result)
{
    if (!decoder->decode(result.m_request))
        return false;

    bool hasHTTPBody;
    if (!decoder->decode(hasHTTPBody))
        return false;

    if (hasHTTPBody) {
        CoreIPC::DataReference formData;
        if (!decoder->decode(formData))
            return false;
        DecoderAdapter httpBodyDecoderAdapter(formData.data(), formData.size());
        result.m_request.setHTTPBody(FormData::decode(httpBodyDecoderAdapter));
    }

    if (!decoder->decodeEnum(result.m_priority))
        return false;
    if (!decoder->decodeEnum(result.m_contentSniffingPolicy))
        return false;
    if (!decoder->decodeEnum(result.m_allowStoredCredentials))
        return false;
    if (!decoder->decode(result.m_inPrivateBrowsingMode))
        return false;

    return true;
}
Пример #5
0
void WebIconDatabase::setIconDataForIconURL(const CoreIPC::DataReference& iconData, const String& iconURL)
{
    LOG(IconDatabase, "WK2 UIProcess setting icon data (%i bytes) for page URL %s", (int)iconData.size(), iconURL.ascii().data());
    if (!m_iconDatabaseImpl)
        return;

    RefPtr<SharedBuffer> buffer = SharedBuffer::create(iconData.data(), iconData.size());
    m_iconDatabaseImpl->setIconDataForIconURL(buffer.release(), iconURL);
}
Пример #6
0
bool decode(ArgumentDecoder* decoder, RetainPtr<CFDataRef>& result)
{
    CoreIPC::DataReference dataReference;
    if (!decoder->decode(dataReference))
        return false;

    result.adoptCF(CFDataCreate(0, dataReference.data(), dataReference.size()));
    return true;
}
bool NetworkResourceLoadParameters::decode(CoreIPC::ArgumentDecoder& decoder, NetworkResourceLoadParameters& result)
{
    if (!decoder.decode(result.m_identifier))
        return false;

    if (!decoder.decode(result.m_webPageID))
        return false;

    if (!decoder.decode(result.m_webFrameID))
        return false;

    if (!decoder.decode(result.m_request))
        return false;

    bool hasHTTPBody;
    if (!decoder.decode(hasHTTPBody))
        return false;

    if (hasHTTPBody) {
        CoreIPC::DataReference formData;
        if (!decoder.decode(formData))
            return false;
        DecoderAdapter httpBodyDecoderAdapter(formData.data(), formData.size());
        result.m_request.setHTTPBody(FormData::decode(httpBodyDecoderAdapter));

        if (!decoder.decode(result.m_requestBodySandboxExtensions))
            return false;
    }

    if (result.m_request.url().isLocalFile()) {
        if (!decoder.decode(result.m_resourceSandboxExtension))
            return false;
    }

    if (!decoder.decodeEnum(result.m_priority))
        return false;
    if (!decoder.decodeEnum(result.m_contentSniffingPolicy))
        return false;
    if (!decoder.decodeEnum(result.m_allowStoredCredentials))
        return false;
    if (!decoder.decode(result.m_inPrivateBrowsingMode))
        return false;
    if (!decoder.decode(result.m_shouldClearReferrerOnHTTPSToHTTPRedirect))
        return false;

    return true;
}
Пример #8
0
void WebProcessProxy::addBackForwardItem(uint64_t itemID, const String& originalURL, const String& url, const String& title, const CoreIPC::DataReference& backForwardData)
{
    MESSAGE_CHECK_URL(originalURL);
    MESSAGE_CHECK_URL(url);

    WebBackForwardListItemMap::AddResult result = m_backForwardListItemMap.add(itemID, 0);
    if (result.isNewEntry) {
        result.iterator->value = WebBackForwardListItem::create(originalURL, url, title, backForwardData.data(), backForwardData.size(), itemID);
        return;
    }

    // Update existing item.
    result.iterator->value->setOriginalURL(originalURL);
    result.iterator->value->setURL(url);
    result.iterator->value->setTitle(title);
    result.iterator->value->setBackForwardData(backForwardData.data(), backForwardData.size());
}
Пример #9
0
void WebProcess::postInjectedBundleMessage(const CoreIPC::DataReference& messageData)
{
    InjectedBundle* injectedBundle = WebProcess::shared().injectedBundle();
    if (!injectedBundle)
        return;

    CoreIPC::ArgumentDecoder decoder(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());
}
Пример #10
0
bool decode(ArgumentDecoder* decoder, RetainPtr<CFStringRef>& result)
{
    CFStringEncoding encoding;
    if (!decoder->decodeEnum(encoding))
        return false;

    if (!CFStringIsEncodingAvailable(encoding))
        return false;
    
    CoreIPC::DataReference dataReference;
    if (!decoder->decode(dataReference))
        return false;

    CFStringRef string = CFStringCreateWithBytes(0, dataReference.data(), dataReference.size(), encoding, false);
    if (!string)
        return false;

    result.adoptCF(string);
    return true;
}
Пример #11
0
bool decode(ArgumentDecoder* decoder, RetainPtr<CFNumberRef>& result)
{
    CFNumberType numberType;
    if (!decoder->decodeEnum(numberType))
        return false;

    CoreIPC::DataReference dataReference;
    if (!decoder->decode(dataReference))
        return false;

    size_t neededBufferSize = sizeForNumberType(numberType);
    if (!neededBufferSize || dataReference.size() != neededBufferSize)
        return false;

    ASSERT(dataReference.data());
    CFNumberRef number = CFNumberCreate(0, numberType, dataReference.data());
    result.adoptCF(number);

    return true;
}
Пример #12
0
void WebResourceLoader::didReceiveData(const CoreIPC::DataReference& data, int64_t encodedDataLength, bool allAtOnce)
{
    LOG(Network, "(WebProcess) WebResourceLoader::didReceiveData of size %i for '%s'", (int)data.size(), m_coreLoader->url().string().utf8().data());
    m_coreLoader->didReceiveData(reinterpret_cast<const char*>(data.data()), data.size(), encodedDataLength, allAtOnce);
}
void PluginControllerProxy::streamDidReceiveData(uint64_t streamID, const CoreIPC::DataReference& data)
{
    m_plugin->streamDidReceiveData(streamID, reinterpret_cast<const char*>(data.data()), data.size());
}
Пример #14
0
void WebSoupRequestManager::didReceiveURIRequestData(const CoreIPC::DataReference& requestData, uint64_t requestID)
{
    WebSoupRequestAsyncData* data = m_requestMap.get(requestID);
    // The data might have been removed from the request map if a previous chunk failed
    // and a new message was sent by the UI process before being notified about the failure.
    if (!data)
        return;
    ASSERT(data->stream.get());

    if (data->requestFailed()) {
        // ResourceRequest failed or it was cancelled. It doesn't matter here the error or if it was cancelled,
        // because that's already handled by the resource handle client, we just want to notify the UI process
        // to stop reading data from the user input stream. If UI process already sent all the data we simply
        // finish silently.
        if (!webkitSoupRequestInputStreamFinished(WEBKIT_SOUP_REQUEST_INPUT_STREAM(data->stream.get())))
            m_process->connection()->send(Messages::WebSoupRequestManagerProxy::DidFailToLoadURIRequest(requestID), 0);
        m_requestMap.remove(requestID);

        return;
    }

    webkitSoupRequestInputStreamAddData(WEBKIT_SOUP_REQUEST_INPUT_STREAM(data->stream.get()), requestData.data(), requestData.size());
    if (webkitSoupRequestInputStreamFinished(WEBKIT_SOUP_REQUEST_INPUT_STREAM(data->stream.get())))
        m_requestMap.remove(requestID);
}
Пример #15
0
void WebConnection::handleMessage(const CoreIPC::DataReference& messageData)
{
    OwnPtr<CoreIPC::ArgumentDecoder> decoder = CoreIPC::ArgumentDecoder::create(messageData.data(), messageData.size());

    String messageName;
    if (!decoder->decode(messageName))
        return;

    RefPtr<APIObject> messageBody;
    if (!decodeMessageBody(*decoder, messageBody))
        return;

    m_client.didReceiveMessage(this, messageName, messageBody.get());
}
Пример #16
0
bool BlobRegistrationData::decode(CoreIPC::ArgumentDecoder& decoder, BlobRegistrationData& result)
{
    ASSERT(!result.m_data);
    result.m_data = BlobData::create();

    String contentType;
    if (!decoder.decode(contentType))
        return false;
    result.m_data->setContentType(contentType);

    String contentDisposition;
    if (!decoder.decode(contentDisposition))
        return false;
    result.m_data->setContentDisposition(contentDisposition);

    uint64_t itemCount;
    if (!decoder.decode(itemCount))
        return false;

    for (uint64_t i = 0; i < itemCount; ++i) {
        uint32_t type;
        if (!decoder.decode(type))
            return false;
        switch (type) {
        case BlobDataItem::Data: {
            CoreIPC::DataReference data;
            if (!decoder.decode(data))
                return false;
            RefPtr<RawData> rawData = RawData::create();
            rawData->mutableData()->append(data.data(), data.size());
            result.m_data->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile);
            break;
        }
        case BlobDataItem::File: {
            int64_t offset;
            if (!decoder.decode(offset))
                return false;
            int64_t length;
            if (!decoder.decode(length))
                return false;
            double expectedModificationTime;
            if (!decoder.decode(expectedModificationTime))
                return false;
            String path;
            if (!decoder.decode(path))
                return false;
            result.m_data->appendFile(path, offset, length, expectedModificationTime);
            break;
        }
        case BlobDataItem::Blob: {
            int64_t offset;
            if (!decoder.decode(offset))
                return false;
            int64_t length;
            if (!decoder.decode(length))
                return false;
            String url;
            if (!decoder.decode(url))
                return false;
            result.m_data->appendBlob(URL(URL(), url), offset, length);
            break;
        }
        default:
            return false;
        }
    }

    if (!decoder.decode(result.m_sandboxExtensions))
        return false;

    return true;
}