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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/common/content_security_policy/csp_directive.cc
diff --git a/content/common/content_security_policy/csp_directive.cc b/content/common/content_security_policy/csp_directive.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8727e82da6cb6e1797d6918e83ca44b4f75877b4
--- /dev/null
+++ b/content/common/content_security_policy/csp_directive.cc
@@ -0,0 +1,51 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/content_security_policy/csp_directive.h"
+
+namespace content {
+
+CSPDirective::CSPDirective() = default;
+
+CSPDirective::CSPDirective(Name name, const CSPSourceList& source_list)
+ : name(name), source_list(source_list) {}
+
+CSPDirective::CSPDirective(const CSPDirective&) = default;
+
+std::string CSPDirective::ToString() const {
+ return NameToString(name) + " " + source_list.ToString();
+}
+
+// static
+std::string CSPDirective::NameToString(CSPDirective::Name name) {
+ switch (name) {
+ case DefaultSrc:
+ return "default-src";
+ case ChildSrc:
+ return "child-src";
+ case FrameSrc:
+ return "frame-src";
+ case FormAction:
+ return "form-action";
+ case Unknown:
+ return "";
+ }
+ NOTREACHED();
+ return "";
+}
+
+// static
+CSPDirective::Name CSPDirective::StringToName(const std::string& name) {
+ if (name == "default-src")
+ return CSPDirective::DefaultSrc;
+ if (name == "child-src")
+ return CSPDirective::ChildSrc;
+ if (name == "frame-src")
+ return CSPDirective::FrameSrc;
+ if (name == "form-action")
+ return CSPDirective::FormAction;
+ return CSPDirective::Unknown;
+}
+
+} // namespace content
« 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