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

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

Issue 2612793002: Implement ContentSecurityPolicy on the browser-side. (Closed)
Patch Set: Add the TODO and bug ids that was forgotten. Created 3 years, 10 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 "content/common/content_security_policy/csp_directive.h"
6
7 namespace content {
8
9 CSPDirective::CSPDirective() = default;
10
11 CSPDirective::CSPDirective(Name name, const CSPSourceList& source_list)
12 : name(name), source_list(source_list) {}
13
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 ChildSrc:
26 return "child-src";
27 case FrameSrc:
28 return "frame-src";
29 case FormAction:
30 return "form-action";
31 case Unknown:
32 return "";
33 }
34 NOTREACHED();
35 return "";
36 }
37
38 // static
39 CSPDirective::Name CSPDirective::StringToName(const std::string& name) {
40 if (name == "default-src")
41 return CSPDirective::DefaultSrc;
42 if (name == "child-src")
43 return CSPDirective::ChildSrc;
44 if (name == "frame-src")
45 return CSPDirective::FrameSrc;
46 if (name == "form-action")
47 return CSPDirective::FormAction;
48 return CSPDirective::Unknown;
49 }
50
51 } // namespace content
OLDNEW
« no previous file with comments | « content/common/content_security_policy/csp_directive.h ('k') | content/common/content_security_policy/csp_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698