1/*
2 * Copyright (C) 2013 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
6 * are met:
7 * 1.  Redistributions of source code must retain the above copyright
8 *     notice, this list of conditions and the following disclaimer.
9 * 2.  Redistributions in binary form must reproduce the above copyright
10 *     notice, this list of conditions and the following disclaimer in the
11 *     documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
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 ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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 ON
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
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#ifndef SecurityPolicyViolationEvent_h
26#define SecurityPolicyViolationEvent_h
27
28#if ENABLE(CSP_NEXT)
29
30#include "Event.h"
31#include "EventNames.h"
32
33namespace WebCore {
34
35struct SecurityPolicyViolationEventInit : public EventInit {
36    SecurityPolicyViolationEventInit()
37    {
38    }
39
40    String documentURI;
41    String referrer;
42    String blockedURI;
43    String violatedDirective;
44    String effectiveDirective;
45    String originalPolicy;
46    String sourceFile;
47    int lineNumber;
48};
49
50class SecurityPolicyViolationEvent : public Event {
51public:
52    static PassRefPtr<SecurityPolicyViolationEvent> create()
53    {
54        return adoptRef(new SecurityPolicyViolationEvent());
55    }
56
57    static PassRefPtr<SecurityPolicyViolationEvent> create(const AtomicString& type, const SecurityPolicyViolationEventInit& initializer)
58    {
59        return adoptRef(new SecurityPolicyViolationEvent(type, initializer));
60    }
61
62    const String& documentURI() const { return m_documentURI; }
63    const String& referrer() const { return m_referrer; }
64    const String& blockedURI() const { return m_blockedURI; }
65    const String& violatedDirective() const { return m_violatedDirective; }
66    const String& effectiveDirective() const { return m_effectiveDirective; }
67    const String& originalPolicy() const { return m_originalPolicy; }
68    const String& sourceFile() const { return m_sourceFile; }
69    int lineNumber() const { return m_lineNumber; }
70
71    virtual EventInterface eventInterface() const { return SecurityPolicyViolationEventInterfaceType; }
72
73private:
74    SecurityPolicyViolationEvent()
75    {
76    }
77
78    SecurityPolicyViolationEvent(const AtomicString& type, const SecurityPolicyViolationEventInit& initializer)
79        : Event(type, initializer)
80        , m_documentURI(initializer.documentURI)
81        , m_referrer(initializer.referrer)
82        , m_blockedURI(initializer.blockedURI)
83        , m_violatedDirective(initializer.violatedDirective)
84        , m_effectiveDirective(initializer.effectiveDirective)
85        , m_originalPolicy(initializer.originalPolicy)
86        , m_sourceFile(initializer.sourceFile)
87        , m_lineNumber(initializer.lineNumber)
88    {
89    }
90
91    String m_documentURI;
92    String m_referrer;
93    String m_blockedURI;
94    String m_violatedDirective;
95    String m_effectiveDirective;
96    String m_originalPolicy;
97    String m_sourceFile;
98    int m_lineNumber;
99};
100
101} // namespace WebCore
102
103#endif // ENABLE(CSP_NEXT)
104
105#endif // SecurityPolicyViolationEvent_h
106