OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (C) 2016 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Neither the name of Google Inc. nor the names of its | |
11 * contributors may be used to endorse or promote products derived from | |
12 * this software without specific prior written permission. | |
13 * | |
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 */ | |
26 | |
27 #include "core/events/SecurityPolicyViolationEvent.h" | |
28 | |
29 namespace blink { | |
30 | |
31 SecurityPolicyViolationEvent::SecurityPolicyViolationEvent(const AtomicString& t ype, const SecurityPolicyViolationEventInit& initializer) | |
32 : Event(type, initializer) | |
33 , m_disposition(ContentSecurityPolicyHeaderTypeEnforce) | |
34 , m_lineNumber(0) | |
35 , m_columnNumber(0) | |
36 , m_statusCode(0) | |
37 { | |
38 if (initializer.hasDocumentURI()) | |
39 m_documentURI = initializer.documentURI(); | |
40 if (initializer.hasReferrer()) | |
41 m_referrer = initializer.referrer(); | |
42 if (initializer.hasBlockedURI()) | |
43 m_blockedURI = initializer.blockedURI(); | |
44 if (initializer.hasViolatedDirective()) | |
45 m_violatedDirective = initializer.violatedDirective(); | |
46 if (initializer.hasEffectiveDirective()) | |
47 m_effectiveDirective = initializer.effectiveDirective(); | |
48 if (initializer.hasOriginalPolicy()) | |
49 m_originalPolicy = initializer.originalPolicy(); | |
50 if (initializer.hasDisposition()) { | |
51 if (initializer.disposition() == "report") | |
52 m_disposition = ContentSecurityPolicyHeaderTypeReport; | |
53 else | |
54 m_disposition = ContentSecurityPolicyHeaderTypeEnforce; | |
Mike West
2016/09/29 10:11:50
Nit: This seems simpler as a ternary if (e.g. `m_d
| |
55 } | |
56 if (initializer.hasSourceFile()) | |
57 m_sourceFile = initializer.sourceFile(); | |
58 if (initializer.hasLineNumber()) | |
59 m_lineNumber = initializer.lineNumber(); | |
60 if (initializer.hasColumnNumber()) | |
61 m_columnNumber = initializer.columnNumber(); | |
62 if (initializer.hasStatusCode()) | |
63 m_statusCode = initializer.statusCode(); | |
64 } | |
65 | |
66 | |
67 const String& SecurityPolicyViolationEvent::disposition() const | |
68 { | |
69 DEFINE_STATIC_LOCAL(const String, enforce, ("enforce")); | |
70 DEFINE_STATIC_LOCAL(const String, report, ("report")); | |
Mike West
2016/09/29 10:11:50
Nit: If you pull these up into an anonymous namesp
| |
71 | |
72 if (m_disposition == ContentSecurityPolicyHeaderTypeReport) | |
73 return report; | |
74 return enforce; | |
75 } | |
76 | |
77 } // namespace blink | |
OLD | NEW |