Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(672)

Unified Diff: Source/core/frame/LocalDOMWindow.cpp

Issue 365873002: Implement a part of ProcessingInstruction by using PrivateScript (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: WIP: async XHR, rewriting layout tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/LocalDOMWindow.h ('k') | Source/core/xml/DocumentXSLT.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/LocalDOMWindow.cpp
diff --git a/Source/core/frame/LocalDOMWindow.cpp b/Source/core/frame/LocalDOMWindow.cpp
index 54eee0b21640a0177e665dc83cbf1aeaf6420452..3511b674527167eec00f7c0a97ca9438487daf40 100644
--- a/Source/core/frame/LocalDOMWindow.cpp
+++ b/Source/core/frame/LocalDOMWindow.cpp
@@ -35,6 +35,7 @@
#include "bindings/core/v8/ScriptController.h"
#include "bindings/core/v8/SerializedScriptValue.h"
#include "bindings/core/v8/V8DOMActivityLogger.h"
+#include "bindings/core/v8/V8Document.h"
#include "core/css/CSSComputedStyleDeclaration.h"
#include "core/css/CSSRuleList.h"
#include "core/css/DOMWindowCSS.h"
@@ -69,6 +70,7 @@
#include "core/frame/Navigator.h"
#include "core/frame/Screen.h"
#include "core/frame/Settings.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/html/HTMLFrameOwnerElement.h"
#include "core/inspector/ConsoleMessage.h"
#include "core/inspector/ConsoleMessageStorage.h"
@@ -1896,6 +1898,34 @@ PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo
return DOMWindowLifecycleNotifier::create(this);
}
+void LocalDOMWindow::replaceDocument(String documentSource, String contentType, String encodingName)
+{
+ ASSERT(m_frame);
+ RefPtrWillBeRawPtr<Document> oldDocument(m_document);
+
+ DocumentInit init(oldDocument->url(), m_frame);
+
+ bool forceXHTML = contentType == "text/plain";
+
+ RefPtrWillBeRawPtr<Document> newDocument = installNewDocument(contentType, init, forceXHTML);
+
+ // Before parsing, we need to save & detach the old document and get the new document
+ // in place. We have to do this only if we're rendering the result document.
+ if (FrameView* view = m_frame->view())
+ view->clear();
+
+ newDocument->updateSecurityOrigin(oldDocument->securityOrigin());
+ newDocument->setCookieURL(oldDocument->cookieURL());
+ newDocument->contentSecurityPolicy()->copyStateFrom(oldDocument->contentSecurityPolicy());
+
+ DocumentEncodingData data;
+ data.setEncoding(WTF::TextEncoding(encodingName));
+ newDocument->setEncodingData(data);
+
+ V8Document::PrivateScript::setTransformSourceDocumentMethod(m_frame, newDocument.get(), oldDocument.get());
+ newDocument->setContent(documentSource);
+}
+
void LocalDOMWindow::trace(Visitor* visitor)
{
visitor->trace(m_document);
« no previous file with comments | « Source/core/frame/LocalDOMWindow.h ('k') | Source/core/xml/DocumentXSLT.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698