bool DocumentLoader::maybeCreateArchive() { // Only the top-frame can load MHTML. if (m_frame->tree().parent()) return false; // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. if (!isArchiveMIMEType(m_response.mimeType())) return false; ASSERT(m_mainResource); m_archive = MHTMLArchive::create(m_response.url(), m_mainResource->resourceBuffer()); // Invalid MHTML. if (!m_archive || !m_archive->mainResource()) { m_archive.clear(); return false; } addAllArchiveResources(m_archive.get()); ArchiveResource* mainResource = m_archive->mainResource(); // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so // relative URLs are resolved properly. ensureWriter(mainResource->mimeType(), m_archive->mainResource()->url()); // The Document has now been created. document()->enforceSandboxFlags(SandboxAll); commitData(mainResource->data()->data(), mainResource->data()->size()); return true; }
void DocumentLoader::commitData(const char* bytes, size_t length) { DCHECK_LT(m_state, MainResourceDone); ensureWriter(m_response.mimeType()); // This can happen if document.close() is called by an event handler while // there's still pending incoming data. if (m_frame && !m_frame->document()->parsing()) return; if (length) m_dataReceived = true; m_writer->addData(bytes, length); }
bool DocumentLoader::maybeCreateArchive() { // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. if (!isArchiveMIMEType(m_response.mimeType())) return false; ASSERT(m_mainResource); ArchiveResource* mainResource = m_fetcher->createArchive(m_mainResource.get()); if (!mainResource) return false; // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so // relative URLs are resolved properly. ensureWriter(mainResource->mimeType(), mainResource->url()); // The Document has now been created. m_frame->document()->enforceSandboxFlags(SandboxAll); commitData(mainResource->data()->data(), mainResource->data()->size()); return true; }
void DocumentLoader::commitData(const char* bytes, size_t length) { ensureWriter(m_response.mimeType()); ASSERT(m_frame->document()->parsing()); m_writer->addData(bytes, length); }