Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: third_party/WebKit/Source/core/events/SecurityPolicyViolationEvent.cpp

Issue 2331213002: Add `disposition` to SecurityPolicyViolationEvent (Closed)
Patch Set: Fix a typo in rebased test expectation Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 namespace {
32
33 const char kEnforce[] = "enforce";
34 const char kReport[] = "report";
35
36 } // namespace
37
38 SecurityPolicyViolationEvent::SecurityPolicyViolationEvent(
39 const AtomicString& type,
40 const SecurityPolicyViolationEventInit& initializer)
41 : Event(type, initializer),
42 m_disposition(ContentSecurityPolicyHeaderTypeEnforce),
43 m_lineNumber(0),
44 m_columnNumber(0),
45 m_statusCode(0) {
46 if (initializer.hasDocumentURI())
47 m_documentURI = initializer.documentURI();
48 if (initializer.hasReferrer())
49 m_referrer = initializer.referrer();
50 if (initializer.hasBlockedURI())
51 m_blockedURI = initializer.blockedURI();
52 if (initializer.hasViolatedDirective())
53 m_violatedDirective = initializer.violatedDirective();
54 if (initializer.hasEffectiveDirective())
55 m_effectiveDirective = initializer.effectiveDirective();
56 if (initializer.hasOriginalPolicy())
57 m_originalPolicy = initializer.originalPolicy();
58 m_disposition = initializer.disposition() == kReport
59 ? ContentSecurityPolicyHeaderTypeReport
60 : ContentSecurityPolicyHeaderTypeEnforce;
61 if (initializer.hasSourceFile())
62 m_sourceFile = initializer.sourceFile();
63 if (initializer.hasLineNumber())
64 m_lineNumber = initializer.lineNumber();
65 if (initializer.hasColumnNumber())
66 m_columnNumber = initializer.columnNumber();
67 if (initializer.hasStatusCode())
68 m_statusCode = initializer.statusCode();
69 }
70
71 const String& SecurityPolicyViolationEvent::disposition() const {
72 DEFINE_STATIC_LOCAL(const String, enforce, (kEnforce));
73 DEFINE_STATIC_LOCAL(const String, report, (kReport));
74
75 if (m_disposition == ContentSecurityPolicyHeaderTypeReport)
76 return report;
77 return enforce;
78 }
79
80 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698