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

Unified Diff: Source/core/dom/ExecutionContext.cpp

Issue 1109633002: Basic experimental suborigin CSP directive and SecurityOrigin mods (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on ToT Created 5 years, 7 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/dom/ExecutionContext.h ('k') | Source/core/frame/csp/CSPDirectiveList.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ExecutionContext.cpp
diff --git a/Source/core/dom/ExecutionContext.cpp b/Source/core/dom/ExecutionContext.cpp
index d08002ec5d244d04c2598381d4997616bbe716a9..401cc8ffa345c5479dbe87e13a04a0da5ce22bdc 100644
--- a/Source/core/dom/ExecutionContext.cpp
+++ b/Source/core/dom/ExecutionContext.cpp
@@ -38,6 +38,7 @@
#include "core/inspector/ScriptCallStack.h"
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerThread.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "wtf/MainThread.h"
namespace blink {
@@ -235,6 +236,16 @@ KURL ExecutionContext::completeURL(const String& url) const
return virtualCompleteURL(url);
}
+bool ExecutionContext::hasSuborigin()
+{
+ return securityContext().securityOrigin()->hasSuborigin();
+}
+
+String ExecutionContext::suboriginName()
+{
+ return securityContext().securityOrigin()->suboriginName();
+}
+
void ExecutionContext::allowWindowInteraction()
{
++m_windowInteractionTokens;
@@ -267,6 +278,20 @@ void ExecutionContext::removeURLFromMemoryCache(const KURL& url)
memoryCache()->removeURLFromCache(url);
}
+// |name| should be non-empty, and this should be enforced by parsing.
+void ExecutionContext::enforceSuborigin(const String& name)
+{
+ if (name.isNull())
+ return;
+ ASSERT(!name.isEmpty());
+ ASSERT(RuntimeEnabledFeatures::suboriginsEnabled());
+ SecurityOrigin* origin = securityContext().securityOrigin();
+ ASSERT(origin);
+ ASSERT(!origin->hasSuborigin() || origin->suboriginName() == name);
+ origin->addSuborigin(name);
+ securityContext().didUpdateSecurityOrigin();
+}
+
DEFINE_TRACE(ExecutionContext)
{
#if ENABLE(OILPAN)
« no previous file with comments | « Source/core/dom/ExecutionContext.h ('k') | Source/core/frame/csp/CSPDirectiveList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698