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

Side by Side Diff: content/common/content_security_policy/csp_source.h

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 #ifndef CONTENT_BROWSER_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H
6 #define CONTENT_BROWSER_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H
7
8 #include <string>
9
10 #include "base/optional.h"
11 #include "content/common/content_export.h"
12 #include "url/gurl.h"
13
14 namespace content {
15
16 class CSPContext;
17
18 struct CONTENT_EXPORT CSPSource {
19 CSPSource();
20 CSPSource(const std::string& scheme,
21 const std::string& host,
22 bool is_host_wildcard,
23 int port,
24 int is_port_wildcard,
25 const std::string& path);
26 CSPSource(const CSPSource& source);
27 ~CSPSource();
28
29 // Scheme.
30 std::string scheme;
31
32 // Host.
33 std::string host;
34 bool is_host_wildcard;
35
36 // port.
37 int port;
38 bool is_port_wildcard;
39
40 // Path.
41 std::string path;
42
43 static base::Optional<CSPSource> Parse(const std::string& text);
44
45 bool Allow(CSPContext* context,
46 const GURL& url,
47 bool is_redirect = false) const;
48
49 std::string ToString() const;
50
51 private:
52 bool IsSchemeOnly() const;
53 bool has_port() const;
54 bool has_host() const;
55 bool has_path() const;
56
57 bool AllowScheme(const GURL& url, CSPContext* context) const;
58 bool AllowHost(const GURL& url) const;
59 bool AllowPort(const GURL& url) const;
60 bool AllowPath(const GURL& url, bool is_redirect) const;
61 };
62
63 } // namespace content
64 #endif // CONTENT_BROWSER_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698