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. | |
| 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 { | |
|
nasko
2017/02/17 01:03:17
Why are these structs instead of classes?
arthursonzogni
2017/02/17 09:30:22
Why not?
ContentSecurityPolicy/CSPDirective/CSPSou
| |
| 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 std::string ToString() const; | |
| 52 | |
| 53 bool IsSchemeOnly() const; | |
| 54 bool HasPort() const; | |
| 55 bool HasHost() const; | |
| 56 bool HasPath() const; | |
| 57 | |
| 58 // Returns true if the |source| matches the |url| for a given |context|. | |
| 59 static bool Allow(const CSPSource& source, | |
| 60 const GURL& url, | |
| 61 CSPContext* context, | |
| 62 bool is_redirect = false); | |
| 63 }; | |
| 64 | |
| 65 } // namespace content | |
| 66 #endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_ | |
| OLD | NEW |