Chromium Code Reviews| 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 if (doc->processingLoadEvent()) | 601 if (doc->processingLoadEvent()) |
| 602 return true; | 602 return true; |
| 603 if (doc->hasActiveParser()) | 603 if (doc->hasActiveParser()) |
| 604 return true; | 604 return true; |
| 605 } | 605 } |
| 606 return frameLoader()->subframeIsLoading(); | 606 return frameLoader()->subframeIsLoading(); |
| 607 } | 607 } |
| 608 | 608 |
| 609 bool DocumentLoader::maybeCreateArchive() | 609 bool DocumentLoader::maybeCreateArchive() |
| 610 { | 610 { |
| 611 // Only the top-frame can load MHTML. | |
| 612 if (m_frame->tree().parent()) | |
| 613 return false; | |
| 614 | |
| 611 // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. | 615 // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. |
| 612 if (!isArchiveMIMEType(m_response.mimeType())) | 616 if (!isArchiveMIMEType(m_response.mimeType())) |
| 613 return false; | 617 return false; |
| 614 | 618 |
| 615 ASSERT(m_mainResource); | 619 ASSERT(m_mainResource); |
| 616 m_archive = MHTMLArchive::create(m_response.url(), m_mainResource->resourceB uffer()); | 620 m_archive = MHTMLArchive::create(m_response.url(), m_mainResource->resourceB uffer()); |
| 617 // Invalid MHTML. | 621 // Invalid MHTML. |
| 618 if (!m_archive || !m_archive->mainResource()) { | 622 if (!m_archive || !m_archive->mainResource()) { |
| 619 m_archive.clear(); | 623 m_archive.clear(); |
| 620 return false; | 624 return false; |
| 621 } | 625 } |
| 622 | 626 |
| 627 // No JavaScript allowed in MHTML to prevent access to cookies for example. | |
| 628 if (m_frame->settings()) | |
| 629 m_frame->settings()->setScriptEnabled(false); | |
|
abarth-chromium
2014/02/12 22:09:15
Won't this setting persist until after the MHTML h
Jay Civelli
2014/02/12 23:26:40
Ah! Thanks for catching this, I did not realize th
| |
| 630 | |
| 623 addAllArchiveResources(m_archive.get()); | 631 addAllArchiveResources(m_archive.get()); |
| 624 ArchiveResource* mainResource = m_archive->mainResource(); | 632 ArchiveResource* mainResource = m_archive->mainResource(); |
| 625 | 633 |
| 626 // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so | 634 // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so |
| 627 // relative URLs are resolved properly. | 635 // relative URLs are resolved properly. |
| 628 ensureWriter(mainResource->mimeType(), m_archive->mainResource()->url()); | 636 ensureWriter(mainResource->mimeType(), m_archive->mainResource()->url()); |
| 629 | 637 |
| 630 commitData(mainResource->data()->data(), mainResource->data()->size()); | 638 commitData(mainResource->data()->data(), mainResource->data()->size()); |
| 631 return true; | 639 return true; |
| 632 } | 640 } |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 845 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume nt) | 853 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume nt) |
| 846 { | 854 { |
| 847 m_frame->loader().stopAllLoaders(); | 855 m_frame->loader().stopAllLoaders(); |
| 848 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url( ), mimeType(), m_writer ? m_writer->encoding() : emptyAtom, m_writer ? m_writer ->encodingWasChosenByUser() : false, true); | 856 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url( ), mimeType(), m_writer ? m_writer->encoding() : emptyAtom, m_writer ? m_writer ->encodingWasChosenByUser() : false, true); |
| 849 if (!source.isNull()) | 857 if (!source.isNull()) |
| 850 m_writer->appendReplacingData(source); | 858 m_writer->appendReplacingData(source); |
| 851 endWriting(m_writer.get()); | 859 endWriting(m_writer.get()); |
| 852 } | 860 } |
| 853 | 861 |
| 854 } // namespace WebCore | 862 } // namespace WebCore |
| OLD | NEW |