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

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

Issue 703193004: XSLT-in-PrivateScript (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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
Index: Source/core/frame/LocalDOMWindow.cpp
diff --git a/Source/core/frame/LocalDOMWindow.cpp b/Source/core/frame/LocalDOMWindow.cpp
index 7ee9063c803257a93a00d294f0d933139efea4ec..ab8978ea135f1afe80b43837dffee13403995674 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"
@@ -70,6 +71,7 @@
#include "core/frame/Screen.h"
#include "core/frame/ScrollOptions.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"
@@ -1923,6 +1925,34 @@ PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo
return DOMWindowLifecycleNotifier::create(this);
}
+void LocalDOMWindow::replaceDocument(String documentSource, String contentType, String encodingName)
+{
+ ASSERT(frame());
+ RefPtrWillBeRawPtr<Document> oldDocument(m_document);
+
+ DocumentInit init(oldDocument->url(), 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 = 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(frame(), newDocument.get(), oldDocument.get());
+ newDocument->setContent(documentSource);
+}
+
void LocalDOMWindow::trace(Visitor* visitor)
{
#if ENABLE(OILPAN)

Powered by Google App Engine
This is Rietveld 408576698