| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010. Adam Barth. All rights reserved. | 2 * Copyright (C) 2010. Adam Barth. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 DocumentWriter::DocumentWriter(Frame* frame) | 57 DocumentWriter::DocumentWriter(Frame* frame) |
| 58 : m_frame(frame) | 58 : m_frame(frame) |
| 59 , m_hasReceivedSomeData(false) | 59 , m_hasReceivedSomeData(false) |
| 60 , m_encodingWasChosenByUser(false) | 60 , m_encodingWasChosenByUser(false) |
| 61 { | 61 { |
| 62 } | 62 } |
| 63 | 63 |
| 64 // This is only called by ScriptController::executeIfJavaScriptURL | 64 // This is only called by ScriptController::executeIfJavaScriptURL |
| 65 // and always contains the result of evaluating a javascript: url. | 65 // and always contains the result of evaluating a javascript: url. |
| 66 // This is the <iframe src="javascript:'html'"> case. | 66 // This is the <iframe src="javascript:'html'"> case. |
| 67 void DocumentWriter::replaceDocument(const String& source) | 67 void DocumentWriter::replaceDocument(const String& source, Document* ownerDocume
nt) |
| 68 { | 68 { |
| 69 m_frame->loader()->stopAllLoaders(); | 69 m_frame->loader()->stopAllLoaders(); |
| 70 begin(m_frame->document()->url(), true, InheritSecurityOrigin); | 70 begin(m_frame->document()->url(), true, ownerDocument); |
| 71 | 71 |
| 72 if (!source.isNull()) { | 72 if (!source.isNull()) { |
| 73 if (!m_hasReceivedSomeData) { | 73 if (!m_hasReceivedSomeData) { |
| 74 m_hasReceivedSomeData = true; | 74 m_hasReceivedSomeData = true; |
| 75 m_frame->document()->setCompatibilityMode(Document::NoQuirksMode); | 75 m_frame->document()->setCompatibilityMode(Document::NoQuirksMode); |
| 76 } | 76 } |
| 77 | 77 |
| 78 // FIXME: This should call DocumentParser::appendBytes instead of append | 78 // FIXME: This should call DocumentParser::appendBytes instead of append |
| 79 // to support RawDataDocumentParsers. | 79 // to support RawDataDocumentParsers. |
| 80 if (DocumentParser* parser = m_frame->document()->parser()) | 80 if (DocumentParser* parser = m_frame->document()->parser()) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 99 | 99 |
| 100 PassRefPtr<Document> DocumentWriter::createDocument(const KURL& url) | 100 PassRefPtr<Document> DocumentWriter::createDocument(const KURL& url) |
| 101 { | 101 { |
| 102 if (!m_frame->loader()->stateMachine()->isDisplayingInitialEmptyDocument() &
& m_frame->loader()->client()->shouldUsePluginDocument(m_mimeType)) | 102 if (!m_frame->loader()->stateMachine()->isDisplayingInitialEmptyDocument() &
& m_frame->loader()->client()->shouldUsePluginDocument(m_mimeType)) |
| 103 return PluginDocument::create(m_frame, url); | 103 return PluginDocument::create(m_frame, url); |
| 104 if (!m_frame->loader()->client()->hasHTMLView()) | 104 if (!m_frame->loader()->client()->hasHTMLView()) |
| 105 return PlaceholderDocument::create(m_frame, url); | 105 return PlaceholderDocument::create(m_frame, url); |
| 106 return DOMImplementation::createDocument(m_mimeType, m_frame, url, m_frame->
inViewSourceMode()); | 106 return DOMImplementation::createDocument(m_mimeType, m_frame, url, m_frame->
inViewSourceMode()); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void DocumentWriter::begin(const KURL& urlReference, bool dispatch, SecurityOrig
inSource originSource) | 109 void DocumentWriter::begin(const KURL& urlReference, bool dispatch, Document* ow
nerDocument) |
| 110 { | 110 { |
| 111 RefPtr<Document> oldDocument = m_frame->document(); | |
| 112 | |
| 113 // We grab a local copy of the URL because it's easy for callers to supply | 111 // We grab a local copy of the URL because it's easy for callers to supply |
| 114 // a URL that will be deallocated during the execution of this function. | 112 // a URL that will be deallocated during the execution of this function. |
| 115 // For example, see <https://bugs.webkit.org/show_bug.cgi?id=66360>. | 113 // For example, see <https://bugs.webkit.org/show_bug.cgi?id=66360>. |
| 116 KURL url = urlReference; | 114 KURL url = urlReference; |
| 117 | 115 |
| 118 // Create a new document before clearing the frame, because it may need to | 116 // Create a new document before clearing the frame, because it may need to |
| 119 // inherit an aliased security context. | 117 // inherit an aliased security context. |
| 120 RefPtr<Document> document = createDocument(url); | 118 RefPtr<Document> document = createDocument(url); |
| 121 | 119 |
| 122 // If the new document is for a Plugin but we're supposed to be sandboxed fr
om Plugins, | 120 // If the new document is for a Plugin but we're supposed to be sandboxed fr
om Plugins, |
| 123 // then replace the document with one whose parser will ignore the incoming
data (bug 39323) | 121 // then replace the document with one whose parser will ignore the incoming
data (bug 39323) |
| 124 if (document->isPluginDocument() && m_frame->loader()->isSandboxed(SandboxPl
ugins)) | 122 if (document->isPluginDocument() && m_frame->loader()->isSandboxed(SandboxPl
ugins)) |
| 125 document = SinkDocument::create(m_frame, url); | 123 document = SinkDocument::create(m_frame, url); |
| 126 | 124 |
| 127 // FIXME: Do we need to consult the content security policy here about block
ed plug-ins? | 125 // FIXME: Do we need to consult the content security policy here about block
ed plug-ins? |
| 128 | 126 |
| 129 bool resetScripting = !(m_frame->loader()->stateMachine()->isDisplayingIniti
alEmptyDocument() && m_frame->document()->securityOrigin()->isSecureTransitionTo
(url)); | 127 bool resetScripting = !(m_frame->loader()->stateMachine()->isDisplayingIniti
alEmptyDocument() && m_frame->document()->securityOrigin()->isSecureTransitionTo
(url)); |
| 130 m_frame->loader()->clear(resetScripting, resetScripting); | 128 m_frame->loader()->clear(resetScripting, resetScripting); |
| 131 clear(); | 129 clear(); |
| 132 if (resetScripting) | 130 if (resetScripting) |
| 133 m_frame->script()->updatePlatformScriptObjects(); | 131 m_frame->script()->updatePlatformScriptObjects(); |
| 134 | 132 |
| 135 m_frame->loader()->setOutgoingReferrer(url); | 133 m_frame->loader()->setOutgoingReferrer(url); |
| 136 m_frame->setDocument(document); | 134 m_frame->setDocument(document); |
| 137 | 135 |
| 138 if (m_decoder) | 136 if (m_decoder) |
| 139 document->setDecoder(m_decoder.get()); | 137 document->setDecoder(m_decoder.get()); |
| 140 if (originSource == InheritSecurityOrigin) { | 138 if (ownerDocument) { |
| 141 document->setCookieURL(oldDocument->cookieURL()); | 139 document->setCookieURL(ownerDocument->cookieURL()); |
| 142 document->setSecurityOrigin(oldDocument->securityOrigin()); | 140 document->setSecurityOrigin(ownerDocument->securityOrigin()); |
| 143 } | 141 } |
| 144 | 142 |
| 145 m_frame->domWindow()->setURL(document->url()); | 143 m_frame->domWindow()->setURL(document->url()); |
| 146 m_frame->domWindow()->setSecurityOrigin(document->securityOrigin()); | 144 m_frame->domWindow()->setSecurityOrigin(document->securityOrigin()); |
| 147 | 145 |
| 148 m_frame->loader()->didBeginDocument(dispatch); | 146 m_frame->loader()->didBeginDocument(dispatch); |
| 149 | 147 |
| 150 document->implicitOpen(); | 148 document->implicitOpen(); |
| 151 | 149 |
| 152 // We grab a reference to the parser so that we'll always send data to the | 150 // We grab a reference to the parser so that we'll always send data to the |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 return m_frame->document()->url().isEmpty() ? m_encoding : encoding(); | 261 return m_frame->document()->url().isEmpty() ? m_encoding : encoding(); |
| 264 } | 262 } |
| 265 | 263 |
| 266 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() | 264 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() |
| 267 { | 265 { |
| 268 ASSERT(!m_parser->isStopped()); | 266 ASSERT(!m_parser->isStopped()); |
| 269 m_parser->setDocumentWasLoadedAsPartOfNavigation(); | 267 m_parser->setDocumentWasLoadedAsPartOfNavigation(); |
| 270 } | 268 } |
| 271 | 269 |
| 272 } // namespace WebCore | 270 } // namespace WebCore |
| OLD | NEW |