| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 void DocumentLoader::clearMainResourceHandle() | 582 void DocumentLoader::clearMainResourceHandle() |
| 583 { | 583 { |
| 584 if (!m_mainResource) | 584 if (!m_mainResource) |
| 585 return; | 585 return; |
| 586 m_mainResource->removeClient(this); | 586 m_mainResource->removeClient(this); |
| 587 m_mainResource = 0; | 587 m_mainResource = 0; |
| 588 } | 588 } |
| 589 | 589 |
| 590 bool DocumentLoader::maybeCreateArchive() | 590 bool DocumentLoader::maybeCreateArchive() |
| 591 { | 591 { |
| 592 // Only the top-frame can load MHTML. |
| 593 if (m_frame->tree().parent()) |
| 594 return false; |
| 595 |
| 592 // Give the archive machinery a crack at this document. If the MIME type is
not an archive type, it will return 0. | 596 // Give the archive machinery a crack at this document. If the MIME type is
not an archive type, it will return 0. |
| 593 if (!isArchiveMIMEType(m_response.mimeType())) | 597 if (!isArchiveMIMEType(m_response.mimeType())) |
| 594 return false; | 598 return false; |
| 595 | 599 |
| 596 ASSERT(m_mainResource); | 600 ASSERT(m_mainResource); |
| 597 m_archive = MHTMLArchive::create(m_response.url(), m_mainResource->resourceB
uffer()); | 601 m_archive = MHTMLArchive::create(m_response.url(), m_mainResource->resourceB
uffer()); |
| 598 // Invalid MHTML. | 602 // Invalid MHTML. |
| 599 if (!m_archive || !m_archive->mainResource()) { | 603 if (!m_archive || !m_archive->mainResource()) { |
| 600 m_archive.clear(); | 604 m_archive.clear(); |
| 601 return false; | 605 return false; |
| 602 } | 606 } |
| 603 | 607 |
| 604 addAllArchiveResources(m_archive.get()); | 608 addAllArchiveResources(m_archive.get()); |
| 605 ArchiveResource* mainResource = m_archive->mainResource(); | 609 ArchiveResource* mainResource = m_archive->mainResource(); |
| 606 | 610 |
| 607 // The origin is the MHTML file, we need to set the base URL to the document
encoded in the MHTML so | 611 // The origin is the MHTML file, we need to set the base URL to the document
encoded in the MHTML so |
| 608 // relative URLs are resolved properly. | 612 // relative URLs are resolved properly. |
| 609 ensureWriter(mainResource->mimeType(), m_archive->mainResource()->url()); | 613 ensureWriter(mainResource->mimeType(), m_archive->mainResource()->url()); |
| 610 | 614 |
| 615 // The Document has now been created. |
| 616 document()->enforceSandboxFlags(SandboxAll); |
| 617 |
| 611 commitData(mainResource->data()->data(), mainResource->data()->size()); | 618 commitData(mainResource->data()->data(), mainResource->data()->size()); |
| 612 return true; | 619 return true; |
| 613 } | 620 } |
| 614 | 621 |
| 615 void DocumentLoader::addAllArchiveResources(MHTMLArchive* archive) | 622 void DocumentLoader::addAllArchiveResources(MHTMLArchive* archive) |
| 616 { | 623 { |
| 617 ASSERT(archive); | 624 ASSERT(archive); |
| 618 if (!m_archiveResourceCollection) | 625 if (!m_archiveResourceCollection) |
| 619 m_archiveResourceCollection = adoptPtr(new ArchiveResourceCollection); | 626 m_archiveResourceCollection = adoptPtr(new ArchiveResourceCollection); |
| 620 m_archiveResourceCollection->addAllResources(archive); | 627 m_archiveResourceCollection->addAllResources(archive); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume
nt) | 828 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume
nt) |
| 822 { | 829 { |
| 823 m_frame->loader().stopAllLoaders(); | 830 m_frame->loader().stopAllLoaders(); |
| 824 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url(
), mimeType(), m_writer ? m_writer->encoding() : emptyAtom, m_writer ? m_writer
->encodingWasChosenByUser() : false, true); | 831 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url(
), mimeType(), m_writer ? m_writer->encoding() : emptyAtom, m_writer ? m_writer
->encodingWasChosenByUser() : false, true); |
| 825 if (!source.isNull()) | 832 if (!source.isNull()) |
| 826 m_writer->appendReplacingData(source); | 833 m_writer->appendReplacingData(source); |
| 827 endWriting(m_writer.get()); | 834 endWriting(m_writer.get()); |
| 828 } | 835 } |
| 829 | 836 |
| 830 } // namespace WebCore | 837 } // namespace WebCore |
| OLD | NEW |