OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y |
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N | 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N |
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 */ | 23 */ |
24 | 24 |
25 #ifndef SecurityPolicyViolationEvent_h | 25 #ifndef SecurityPolicyViolationEvent_h |
26 #define SecurityPolicyViolationEvent_h | 26 #define SecurityPolicyViolationEvent_h |
27 | 27 |
28 #include "core/events/Event.h" | 28 #include "core/events/Event.h" |
29 #include "core/events/SecurityPolicyViolationEventInit.h" | 29 #include "core/events/SecurityPolicyViolationEventInit.h" |
30 #include "platform/network/ContentSecurityPolicyParsers.h" | |
Sergey Shekyan
2016/09/16 05:38:02
I am not sure if I should do this or edit DEPS, pl
Mike West
2016/09/16 07:30:35
This is fine; //Source/core can depend on //Source
| |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 class SecurityPolicyViolationEvent final : public Event { | 34 class SecurityPolicyViolationEvent final : public Event { |
34 DEFINE_WRAPPERTYPEINFO(); | 35 DEFINE_WRAPPERTYPEINFO(); |
35 public: | 36 public: |
36 static SecurityPolicyViolationEvent* create(const AtomicString& type, const SecurityPolicyViolationEventInit& initializer) | 37 static SecurityPolicyViolationEvent* create(const AtomicString& type, const SecurityPolicyViolationEventInit& initializer) |
37 { | 38 { |
38 return new SecurityPolicyViolationEvent(type, initializer); | 39 return new SecurityPolicyViolationEvent(type, initializer); |
39 } | 40 } |
40 | 41 |
41 const String& documentURI() const { return m_documentURI; } | 42 const String& documentURI() const { return m_documentURI; } |
42 const String& referrer() const { return m_referrer; } | 43 const String& referrer() const { return m_referrer; } |
43 const String& blockedURI() const { return m_blockedURI; } | 44 const String& blockedURI() const { return m_blockedURI; } |
44 const String& violatedDirective() const { return m_violatedDirective; } | 45 const String& violatedDirective() const { return m_violatedDirective; } |
45 const String& effectiveDirective() const { return m_effectiveDirective; } | 46 const String& effectiveDirective() const { return m_effectiveDirective; } |
46 const String& originalPolicy() const { return m_originalPolicy; } | 47 const String& originalPolicy() const { return m_originalPolicy; } |
48 const AtomicString& disposition() const | |
49 { | |
50 if (m_disposition == ContentSecurityPolicyHeaderTypeEnforce) | |
51 return EventTypeNames::enforce; | |
52 return EventTypeNames::report; | |
Mike West
2016/09/16 07:30:35
As noted above, the `EventTypeNames` bit is simply
| |
53 } | |
47 const String& sourceFile() const { return m_sourceFile; } | 54 const String& sourceFile() const { return m_sourceFile; } |
48 int lineNumber() const { return m_lineNumber; } | 55 int lineNumber() const { return m_lineNumber; } |
49 int columnNumber() const { return m_columnNumber; } | 56 int columnNumber() const { return m_columnNumber; } |
50 uint16_t statusCode() const { return m_statusCode; } | 57 uint16_t statusCode() const { return m_statusCode; } |
51 | 58 |
52 const AtomicString& interfaceName() const override { return EventNames::Secu rityPolicyViolationEvent; } | 59 const AtomicString& interfaceName() const override { return EventNames::Secu rityPolicyViolationEvent; } |
53 | 60 |
54 DEFINE_INLINE_VIRTUAL_TRACE() { Event::trace(visitor); } | 61 DEFINE_INLINE_VIRTUAL_TRACE() { Event::trace(visitor); } |
55 | 62 |
56 private: | 63 private: |
57 SecurityPolicyViolationEvent(const AtomicString& type, const SecurityPolicyV iolationEventInit& initializer) | 64 SecurityPolicyViolationEvent(const AtomicString& type, const SecurityPolicyV iolationEventInit& initializer) |
58 : Event(type, initializer) | 65 : Event(type, initializer) |
66 , m_disposition(ContentSecurityPolicyHeaderTypeEnforce) | |
59 , m_lineNumber(0) | 67 , m_lineNumber(0) |
60 , m_columnNumber(0) | 68 , m_columnNumber(0) |
61 , m_statusCode(0) | 69 , m_statusCode(0) |
62 { | 70 { |
63 if (initializer.hasDocumentURI()) | 71 if (initializer.hasDocumentURI()) |
64 m_documentURI = initializer.documentURI(); | 72 m_documentURI = initializer.documentURI(); |
65 if (initializer.hasReferrer()) | 73 if (initializer.hasReferrer()) |
66 m_referrer = initializer.referrer(); | 74 m_referrer = initializer.referrer(); |
67 if (initializer.hasBlockedURI()) | 75 if (initializer.hasBlockedURI()) |
68 m_blockedURI = initializer.blockedURI(); | 76 m_blockedURI = initializer.blockedURI(); |
69 if (initializer.hasViolatedDirective()) | 77 if (initializer.hasViolatedDirective()) |
70 m_violatedDirective = initializer.violatedDirective(); | 78 m_violatedDirective = initializer.violatedDirective(); |
71 if (initializer.hasEffectiveDirective()) | 79 if (initializer.hasEffectiveDirective()) |
72 m_effectiveDirective = initializer.effectiveDirective(); | 80 m_effectiveDirective = initializer.effectiveDirective(); |
73 if (initializer.hasOriginalPolicy()) | 81 if (initializer.hasOriginalPolicy()) |
74 m_originalPolicy = initializer.originalPolicy(); | 82 m_originalPolicy = initializer.originalPolicy(); |
83 if (initializer.hasDisposition()) { | |
84 if (initializer.disposition() == "report") | |
Mike West
2016/09/16 07:30:35
1. We should move this out of the `.h` file. Doesn
| |
85 m_disposition = ContentSecurityPolicyHeaderTypeReport; | |
86 } | |
75 if (initializer.hasSourceFile()) | 87 if (initializer.hasSourceFile()) |
76 m_sourceFile = initializer.sourceFile(); | 88 m_sourceFile = initializer.sourceFile(); |
77 if (initializer.hasLineNumber()) | 89 if (initializer.hasLineNumber()) |
78 m_lineNumber = initializer.lineNumber(); | 90 m_lineNumber = initializer.lineNumber(); |
79 if (initializer.hasColumnNumber()) | 91 if (initializer.hasColumnNumber()) |
80 m_columnNumber = initializer.columnNumber(); | 92 m_columnNumber = initializer.columnNumber(); |
81 if (initializer.hasStatusCode()) | 93 if (initializer.hasStatusCode()) |
82 m_statusCode = initializer.statusCode(); | 94 m_statusCode = initializer.statusCode(); |
83 } | 95 } |
84 | 96 |
85 String m_documentURI; | 97 String m_documentURI; |
86 String m_referrer; | 98 String m_referrer; |
87 String m_blockedURI; | 99 String m_blockedURI; |
88 String m_violatedDirective; | 100 String m_violatedDirective; |
89 String m_effectiveDirective; | 101 String m_effectiveDirective; |
90 String m_originalPolicy; | 102 String m_originalPolicy; |
103 ContentSecurityPolicyHeaderType m_disposition; | |
91 String m_sourceFile; | 104 String m_sourceFile; |
92 int m_lineNumber; | 105 int m_lineNumber; |
93 int m_columnNumber; | 106 int m_columnNumber; |
94 int m_statusCode; | 107 int m_statusCode; |
95 }; | 108 }; |
96 | 109 |
97 } // namespace blink | 110 } // namespace blink |
98 | 111 |
99 #endif // SecurityPolicyViolationEvent_h | 112 #endif // SecurityPolicyViolationEvent_h |
OLD | NEW |