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

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

Issue 134863007: CSP: Replace 'static_cast' with 'toDocument'. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 10 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/ContentSecurityPolicy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/ContentSecurityPolicy.cpp
diff --git a/Source/core/frame/ContentSecurityPolicy.cpp b/Source/core/frame/ContentSecurityPolicy.cpp
index 3057041a962646db9ca31b078183f23b25420e81..b3e3a1b0a210ec1bc934ed13e8e01d8dd0a0e857 100644
--- a/Source/core/frame/ContentSecurityPolicy.cpp
+++ b/Source/core/frame/ContentSecurityPolicy.cpp
@@ -1692,9 +1692,8 @@ void ContentSecurityPolicy::didReceiveHeader(const String& header, HeaderType ty
void ContentSecurityPolicy::addPolicyFromHeaderValue(const String& header, HeaderType type, HeaderSource source)
{
- Document* document = 0;
- if (m_client->isDocument()) {
- document = static_cast<Document*>(m_client);
+ Document* document = this->document();
+ if (document) {
UseCounter::count(*document, getUseCounterType(type));
// CSP 1.1 defines report-only in a <meta> element as invalid. Measure for now, disable in experimental mode.
@@ -1859,10 +1858,8 @@ bool ContentSecurityPolicy::allowScriptEval(ScriptState* state, ContentSecurityP
bool ContentSecurityPolicy::allowStyleEval(ScriptState* state, ContentSecurityPolicy::ReportingStatus reportingStatus) const
{
if (!experimentalFeaturesEnabled()) {
- if (m_client->isDocument()) {
- Document* document = static_cast<Document*>(m_client);
+ if (Document* document = this->document())
UseCounter::count(*document, UseCounter::UnsafeEvalBlocksCSSOM);
- }
return true;
}
return isAllowedByAllWithState<&CSPDirectiveList::allowStyleEval>(m_policies, state, reportingStatus);
@@ -2079,8 +2076,8 @@ KURL ContentSecurityPolicy::completeURL(const String& url) const
void ContentSecurityPolicy::enforceSandboxFlags(SandboxFlags mask) const
{
- if (m_client->isDocument())
- static_cast<Document*>(m_client)->enforceSandboxFlags(mask);
+ if (Document* document = this->document())
+ document->enforceSandboxFlags(mask);
}
static String stripURLForUseInReport(Document* document, const KURL& url)
@@ -2128,7 +2125,7 @@ void ContentSecurityPolicy::reportViolation(const String& directiveText, const S
if (!m_client->isDocument())
return;
- Document* document = static_cast<Document*>(m_client);
+ Document* document = this->document();
Frame* frame = document->frame();
if (!frame)
return;
« no previous file with comments | « Source/core/frame/ContentSecurityPolicy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698