Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_ | |
| 6 #define CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "content/common/content_export.h" | |
| 11 #include "url/gurl.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 class CSPContext; | |
| 16 | |
| 17 // A CSPSource represents an expression that matches a set of urls. | |
|
Mike West
2017/02/15 16:18:18
Perhaps:
"""
CSPSource represents a single Conten
arthursonzogni
2017/02/16 13:30:25
Perfect.
| |
| 18 // Examples of CSPSource: | |
| 19 // - domain.example.com | |
| 20 // - *.example.com | |
| 21 // - https://cdn.com | |
| 22 // - data: | |
| 23 // - 'none' | |
| 24 // - 'self' | |
| 25 // - * | |
| 26 struct CONTENT_EXPORT CSPSource { | |
| 27 CSPSource(); | |
| 28 CSPSource(const std::string& scheme, | |
| 29 const std::string& host, | |
| 30 bool is_host_wildcard, | |
| 31 int port, | |
| 32 bool is_port_wildcard, | |
| 33 const std::string& path); | |
| 34 CSPSource(const CSPSource& source); | |
| 35 ~CSPSource(); | |
| 36 | |
| 37 // Scheme. | |
| 38 std::string scheme; | |
| 39 | |
| 40 // Host. | |
| 41 std::string host; | |
| 42 bool is_host_wildcard; | |
| 43 | |
| 44 // port. | |
| 45 int port; | |
| 46 bool is_port_wildcard; | |
| 47 | |
| 48 // Path. | |
| 49 std::string path; | |
| 50 | |
| 51 bool Allow(CSPContext* context, | |
|
Mike West
2017/02/15 16:18:18
Or perhaps this could move to `CSPContext` entirel
arthursonzogni
2017/02/16 13:30:25
Why do you think it should be moved to CSPContext?
| |
| 52 const GURL& url, | |
| 53 bool is_redirect = false) const; | |
| 54 | |
| 55 std::string ToString() const; | |
| 56 | |
| 57 private: | |
| 58 bool IsSchemeOnly() const; | |
| 59 bool HasPort() const; | |
| 60 bool HasHost() const; | |
| 61 bool HasPath() const; | |
| 62 | |
| 63 bool AllowScheme(const GURL& url, CSPContext* context) const; | |
| 64 bool AllowHost(const GURL& url) const; | |
| 65 bool AllowPort(const GURL& url) const; | |
| 66 bool AllowPath(const GURL& url, bool is_redirect) const; | |
| 67 }; | |
| 68 | |
| 69 } // namespace content | |
| 70 #endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_ | |
| OLD | NEW |