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

Unified Diff: content/common/content_security_policy/csp_source.h

Issue 2612793002: Implement ContentSecurityPolicy on the browser-side. (Closed)
Patch Set: Rename SchemeShouldBypass => SchemeShouldBypassCSP. 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_source.h
diff --git a/content/common/content_security_policy/csp_source.h b/content/common/content_security_policy/csp_source.h
new file mode 100644
index 0000000000000000000000000000000000000000..a1e82d498725d489cc5e7bacb135a42377e20e91
--- /dev/null
+++ b/content/common/content_security_policy/csp_source.h
@@ -0,0 +1,61 @@
+// 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.
+
+#ifndef CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_
+#define CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_
+
+#include <string>
+
+#include "content/common/content_export.h"
+#include "url/gurl.h"
+
+namespace content {
+
+class CSPContext;
+
+struct CONTENT_EXPORT CSPSource {
Mike West 2017/02/13 14:10:51 If your struct has methods and private members, it
arthursonzogni 2017/02/14 17:07:03 Yes, but I really want this struct to be a struct
Mike West 2017/02/15 16:18:17 I'll defer to //content/common OWNERS, I suppose,
+ CSPSource();
+ CSPSource(const std::string& scheme,
+ const std::string& host,
+ bool is_host_wildcard,
+ int port,
+ bool is_port_wildcard,
+ const std::string& path);
+ CSPSource(const CSPSource& source);
+ ~CSPSource();
+
+ // Scheme.
+ std::string scheme;
+
+ // Host.
+ std::string host;
+ bool is_host_wildcard;
+
+ // port.
+ int port;
+ bool is_port_wildcard;
+
+ // Path.
+ std::string path;
+
+ bool Allow(CSPContext* context,
+ const GURL& url,
+ bool is_redirect = false) const;
+
+ std::string ToString() const;
+
+ private:
+ bool IsSchemeOnly() const;
+ bool HasPort() const;
+ bool HasHost() const;
+ bool HasPath() const;
+
+ bool AllowScheme(const GURL& url, CSPContext* context) const;
+ bool AllowHost(const GURL& url) const;
+ bool AllowPort(const GURL& url) const;
+ bool AllowPath(const GURL& url, bool is_redirect) const;
+};
+
+} // namespace content
+#endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_

Powered by Google App Engine
This is Rietveld 408576698