| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/frame/csp/CSPDirectiveList.h" | 6 #include "core/frame/csp/CSPDirectiveList.h" |
| 7 | 7 |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "platform/ParsingUtilities.h" | 9 #include "platform/ParsingUtilities.h" |
| 10 #include "platform/weborigin/KURL.h" | 10 #include "platform/weborigin/KURL.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 if (directives->isReportOnly() && directives->reportURIs().isEmpty()) | 38 if (directives->isReportOnly() && directives->reportURIs().isEmpty()) |
| 39 policy->reportMissingReportURI(String(begin, end - begin)); | 39 policy->reportMissingReportURI(String(begin, end - begin)); |
| 40 | 40 |
| 41 return directives.release(); | 41 return directives.release(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void CSPDirectiveList::reportViolation(const String& directiveText, const String
& effectiveDirective, const String& consoleMessage, const KURL& blockedURL) cons
t | 44 void CSPDirectiveList::reportViolation(const String& directiveText, const String
& effectiveDirective, const String& consoleMessage, const KURL& blockedURL) cons
t |
| 45 { | 45 { |
| 46 String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleM
essage; | 46 String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleM
essage; |
| 47 m_policy->client()->addConsoleMessage(SecurityMessageSource, ErrorMessageLev
el, message); | 47 m_policy->executionContext()->addConsoleMessage(SecurityMessageSource, Error
MessageLevel, message); |
| 48 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); | 48 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void CSPDirectiveList::reportViolationWithLocation(const String& directiveText,
const String& effectiveDirective, const String& consoleMessage, const KURL& bloc
kedURL, const String& contextURL, const WTF::OrdinalNumber& contextLine) const | 51 void CSPDirectiveList::reportViolationWithLocation(const String& directiveText,
const String& effectiveDirective, const String& consoleMessage, const KURL& bloc
kedURL, const String& contextURL, const WTF::OrdinalNumber& contextLine) const |
| 52 { | 52 { |
| 53 String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleM
essage; | 53 String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleM
essage; |
| 54 m_policy->client()->addConsoleMessage(SecurityMessageSource, ErrorMessageLev
el, message, contextURL, contextLine.oneBasedInt()); | 54 m_policy->executionContext()->addConsoleMessage(SecurityMessageSource, Error
MessageLevel, message, contextURL, contextLine.oneBasedInt()); |
| 55 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); | 55 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void CSPDirectiveList::reportViolationWithState(const String& directiveText, con
st String& effectiveDirective, const String& consoleMessage, const KURL& blocked
URL, ScriptState* scriptState) const | 58 void CSPDirectiveList::reportViolationWithState(const String& directiveText, con
st String& effectiveDirective, const String& consoleMessage, const KURL& blocked
URL, ScriptState* scriptState) const |
| 59 { | 59 { |
| 60 String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleM
essage; | 60 String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleM
essage; |
| 61 m_policy->client()->addConsoleMessage(SecurityMessageSource, ErrorMessageLev
el, message, scriptState); | 61 m_policy->executionContext()->addConsoleMessage(SecurityMessageSource, Error
MessageLevel, message, scriptState); |
| 62 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); | 62 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool CSPDirectiveList::checkEval(SourceListDirective* directive) const | 65 bool CSPDirectiveList::checkEval(SourceListDirective* directive) const |
| 66 { | 66 { |
| 67 return !directive || directive->allowEval(); | 67 return !directive || directive->allowEval(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool CSPDirectiveList::checkInline(SourceListDirective* directive) const | 70 bool CSPDirectiveList::checkInline(SourceListDirective* directive) const |
| 71 { | 71 { |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 parseReferrer(name, value); | 670 parseReferrer(name, value); |
| 671 else | 671 else |
| 672 m_policy->reportUnsupportedDirective(name); | 672 m_policy->reportUnsupportedDirective(name); |
| 673 } else { | 673 } else { |
| 674 m_policy->reportUnsupportedDirective(name); | 674 m_policy->reportUnsupportedDirective(name); |
| 675 } | 675 } |
| 676 } | 676 } |
| 677 | 677 |
| 678 | 678 |
| 679 } // namespace WebCore | 679 } // namespace WebCore |
| 680 | |
| OLD | NEW |