Chromium Code Reviews| 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..da07fe97a26c59f8c47c43cbe991a23d375f66d4 |
| --- /dev/null |
| +++ b/content/common/content_security_policy/csp_source.h |
| @@ -0,0 +1,70 @@ |
| +// 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; |
| + |
| +// 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.
|
| +// Examples of CSPSource: |
| +// - domain.example.com |
| +// - *.example.com |
| +// - https://cdn.com |
| +// - data: |
| +// - 'none' |
| +// - 'self' |
| +// - * |
| +struct CONTENT_EXPORT CSPSource { |
| + 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, |
|
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?
|
| + 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_ |