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_lineNumber(0) |
| 34 , m_columnNumber(0) |
| 35 , m_statusCode(0) |
| 36 { |
| 37 if (initializer.hasDocumentURI()) |
| 38 m_documentURI = initializer.documentURI(); |
| 39 if (initializer.hasReferrer()) |
| 40 m_referrer = initializer.referrer(); |
| 41 if (initializer.hasBlockedURI()) |
| 42 m_blockedURI = initializer.blockedURI(); |
| 43 if (initializer.hasViolatedDirective()) |
| 44 m_violatedDirective = initializer.violatedDirective(); |
| 45 if (initializer.hasEffectiveDirective()) |
| 46 m_effectiveDirective = initializer.effectiveDirective(); |
| 47 if (initializer.hasOriginalPolicy()) |
| 48 m_originalPolicy = initializer.originalPolicy(); |
| 49 if (initializer.hasDisposition()) { |
| 50 if (initializer.disposition() == "report") |
| 51 m_disposition = ContentSecurityPolicyHeaderTypeReport; |
| 52 } |
| 53 if (initializer.hasSourceFile()) |
| 54 m_sourceFile = initializer.sourceFile(); |
| 55 if (initializer.hasLineNumber()) |
| 56 m_lineNumber = initializer.lineNumber(); |
| 57 if (initializer.hasColumnNumber()) |
| 58 m_columnNumber = initializer.columnNumber(); |
| 59 if (initializer.hasStatusCode()) |
| 60 m_statusCode = initializer.statusCode(); |
| 61 } |
| 62 |
| 63 |
| 64 const String& SecurityPolicyViolationEvent::disposition() const |
| 65 { |
| 66 DEFINE_STATIC_LOCAL(const String, enforce, ("enforce")); |
| 67 DEFINE_STATIC_LOCAL(const String, report, ("report")); |
| 68 |
| 69 if (m_disposition == ContentSecurityPolicyHeaderTypeEnforce) |
| 70 return enforce; |
| 71 return report; |
| 72 } |
| 73 |
| 74 } // namespace blink |
OLD | NEW |