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

Side by Side Diff: content/common/content_security_policy/csp_directive.cc

Issue 2612793002: Implement ContentSecurityPolicy on the browser-side. (Closed)
Patch Set: Temporary re-add the parser + transmit parsed CSP over IPC. Created 3 years, 11 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 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <sstream>
6
7 #include "content/common/content_security_policy/csp_directive.h"
8
9 namespace content {
10
11 CSPDirective::CSPDirective() = default;
12 CSPDirective::CSPDirective(Name name, const CSPSourceList& source_list)
13 : name(name), source_list(source_list) {}
14 CSPDirective::CSPDirective(const CSPDirective&) = default;
15
16 std::string CSPDirective::ToString() const {
17 return NameToString(name) + " " + source_list.ToString();
18 }
19
20 // static
21 std::string CSPDirective::NameToString(CSPDirective::Name name) {
22 switch (name) {
23 case DefaultSrc:
24 return "default-src";
25 case FrameAncestors:
26 return "frame-ancestors";
27 case ChildSrc:
28 return "child-src";
29 case FrameSrc:
30 return "frame-src";
31 case FormAction:
32 return "form-action";
33 case ReportURI:
34 return "report-uri";
35 case Unknown:
36 return "";
37 }
38 }
39
40 // static
41 CSPDirective::Name CSPDirective::StringToName(const std::string& name) {
42 if (name == "default-src")
43 return CSPDirective::DefaultSrc;
44 if (name == "frame-ancestors")
45 return CSPDirective::FrameAncestors;
46 if (name == "child-src")
47 return CSPDirective::ChildSrc;
48 if (name == "frame-src")
49 return CSPDirective::FrameSrc;
50 if (name == "form-action")
51 return CSPDirective::FormAction;
52 if (name == "report-uri")
53 return CSPDirective::ReportURI;
54 return CSPDirective::Unknown;
55 }
56
57 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698