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/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/inspector/ConsoleMessage.h" | 10 #include "core/inspector/ConsoleMessage.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 if (directives->isReportOnly() && directives->reportURIs().isEmpty()) | 40 if (directives->isReportOnly() && directives->reportURIs().isEmpty()) |
41 policy->reportMissingReportURI(String(begin, end - begin)); | 41 policy->reportMissingReportURI(String(begin, end - begin)); |
42 | 42 |
43 return directives.release(); | 43 return directives.release(); |
44 } | 44 } |
45 | 45 |
46 void CSPDirectiveList::reportViolation(const String& directiveText, const String
& effectiveDirective, const String& consoleMessage, const KURL& blockedURL) cons
t | 46 void CSPDirectiveList::reportViolation(const String& directiveText, const String
& effectiveDirective, const String& consoleMessage, const KURL& blockedURL) cons
t |
47 { | 47 { |
48 String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleM
essage; | 48 String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleM
essage; |
49 m_policy->executionContext()->addConsoleMessage(ConsoleMessage::create(Secur
ityMessageSource, ErrorMessageLevel, message)); | 49 m_policy->logToConsole(ConsoleMessage::create(SecurityMessageSource, ErrorMe
ssageLevel, message)); |
50 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); | 50 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); |
51 } | 51 } |
52 | 52 |
53 void CSPDirectiveList::reportViolationWithLocation(const String& directiveText,
const String& effectiveDirective, const String& consoleMessage, const KURL& bloc
kedURL, const String& contextURL, const WTF::OrdinalNumber& contextLine) const | 53 void CSPDirectiveList::reportViolationWithLocation(const String& directiveText,
const String& effectiveDirective, const String& consoleMessage, const KURL& bloc
kedURL, const String& contextURL, const WTF::OrdinalNumber& contextLine) const |
54 { | 54 { |
55 String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleM
essage; | 55 String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleM
essage; |
56 m_policy->executionContext()->addConsoleMessage(ConsoleMessage::create(Secur
ityMessageSource, ErrorMessageLevel, message, contextURL, contextLine.oneBasedIn
t())); | 56 m_policy->logToConsole(ConsoleMessage::create(SecurityMessageSource, ErrorMe
ssageLevel, message, contextURL, contextLine.oneBasedInt())); |
57 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); | 57 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); |
58 } | 58 } |
59 | 59 |
60 void CSPDirectiveList::reportViolationWithState(const String& directiveText, con
st String& effectiveDirective, const String& message, const KURL& blockedURL, Sc
riptState* scriptState) const | 60 void CSPDirectiveList::reportViolationWithState(const String& directiveText, con
st String& effectiveDirective, const String& message, const KURL& blockedURL, Sc
riptState* scriptState) const |
61 { | 61 { |
62 String reportMessage = m_reportOnly ? "[Report Only] " + message : message; | 62 String reportMessage = m_reportOnly ? "[Report Only] " + message : message; |
63 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(S
ecurityMessageSource, ErrorMessageLevel, reportMessage); | 63 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(S
ecurityMessageSource, ErrorMessageLevel, reportMessage); |
64 consoleMessage->setScriptState(scriptState); | 64 consoleMessage->setScriptState(scriptState); |
65 m_policy->executionContext()->addConsoleMessage(consoleMessage.release()); | 65 m_policy->logToConsole(consoleMessage.release()); |
66 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); | 66 m_policy->reportViolation(directiveText, effectiveDirective, message, blocke
dURL, m_reportURIs, m_header); |
67 } | 67 } |
68 | 68 |
69 bool CSPDirectiveList::checkEval(SourceListDirective* directive) const | 69 bool CSPDirectiveList::checkEval(SourceListDirective* directive) const |
70 { | 70 { |
71 return !directive || directive->allowEval(); | 71 return !directive || directive->allowEval(); |
72 } | 72 } |
73 | 73 |
74 bool CSPDirectiveList::checkInline(SourceListDirective* directive) const | 74 bool CSPDirectiveList::checkInline(SourceListDirective* directive) const |
75 { | 75 { |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 parseReferrer(name, value); | 674 parseReferrer(name, value); |
675 else | 675 else |
676 m_policy->reportUnsupportedDirective(name); | 676 m_policy->reportUnsupportedDirective(name); |
677 } else { | 677 } else { |
678 m_policy->reportUnsupportedDirective(name); | 678 m_policy->reportUnsupportedDirective(name); |
679 } | 679 } |
680 } | 680 } |
681 | 681 |
682 | 682 |
683 } // namespace blink | 683 } // namespace blink |
OLD | NEW |