| 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..203133183b609726a5528685d2455c21081cdeaa
|
| --- /dev/null
|
| +++ b/content/common/content_security_policy/csp_source.h
|
| @@ -0,0 +1,64 @@
|
| +// 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_BROWSER_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H
|
| +#define CONTENT_BROWSER_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/optional.h"
|
| +#include "content/common/content_export.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace content {
|
| +
|
| +class CSPContext;
|
| +
|
| +struct CONTENT_EXPORT CSPSource {
|
| + CSPSource();
|
| + CSPSource(const std::string& scheme,
|
| + const std::string& host,
|
| + bool is_host_wildcard,
|
| + int port,
|
| + int 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;
|
| +
|
| + static base::Optional<CSPSource> Parse(const std::string& text);
|
| +
|
| + bool Allow(CSPContext* context,
|
| + const GURL& url,
|
| + bool is_redirect = false) const;
|
| +
|
| + std::string ToString() const;
|
| +
|
| + private:
|
| + bool IsSchemeOnly() const;
|
| + bool has_port() const;
|
| + bool has_host() const;
|
| + bool has_path() 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_BROWSER_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H
|
|
|