Exemple #1
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());
}
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;

    return true;
}
Exemple #3
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());
}
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;
}
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;
}
Exemple #6
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());
}
Exemple #7
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());
}
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);
}
Exemple #10
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;
}