#include "extensions/common/manifest_handlers/csp_info.h"
#include <memory>
#include <string_view>
#include <utility>
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "extensions/common/csp_validator.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/install_warning.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/sandboxed_page_info.h"
namespace extensions {
keys;
errors;
ContentSecurityPolicyIsLegal;
SanitizeContentSecurityPolicy;
namespace {
const char kDefaultContentSecurityPolicy[] = …;
const char kDefaultSandboxedPageContentSecurityPolicy[] = …;
static const char kDefaultMV3CSP[] = …;
static const char kMinimumMV3CSP[] = …;
static const char kMinimumUnpackedMV3CSP[] = …;
#define PLATFORM_APP_LOCAL_CSP_SOURCES …
const char kDefaultPlatformAppContentSecurityPolicy[] = …
"default-src 'self' blob: filesystem:;"
" connect-src * data: blob: filesystem:;"
" style-src " PLATFORM_APP_LOCAL_CSP_SOURCES " 'unsafe-inline';"
" img-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";"
" frame-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";"
" font-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";"
" media-src * data: blob: filesystem:;"
" script-src 'self' blob: filesystem: 'wasm-unsafe-eval';";
int GetValidatorOptions(Extension* extension) { … }
std::u16string GetInvalidManifestKeyError(std::string_view key) { … }
const base::Value* GetManifestPath(const Extension* extension,
const char* path) { … }
const char* GetDefaultExtensionPagesCSP(Extension* extension) { … }
const std::string* GetMinimumMV3CSPForExtension(const Extension& extension) { … }
}
CSPInfo::CSPInfo(std::string extension_pages_csp)
: … { … }
CSPInfo::~CSPInfo() { … }
const std::string& CSPInfo::GetExtensionPagesCSP(const Extension* extension) { … }
const std::string* CSPInfo::GetMinimumCSPToAppend(
const Extension& extension,
const std::string& relative_path) { … }
const std::string* CSPInfo::GetIsolatedWorldCSP(const Extension& extension) { … }
const std::string& CSPInfo::GetSandboxContentSecurityPolicy(
const Extension* extension) { … }
const std::string& CSPInfo::GetResourceContentSecurityPolicy(
const Extension* extension,
const std::string& relative_path) { … }
CSPHandler::CSPHandler() = default;
CSPHandler::~CSPHandler() = default;
const char* CSPHandler::GetMinimumMV3CSPForTesting() { … }
const char* CSPHandler::GetMinimumUnpackedMV3CSPForTesting() { … }
bool CSPHandler::Parse(Extension* extension, std::u16string* error) { … }
bool CSPHandler::ParseCSPDictionary(Extension* extension,
std::u16string* error) { … }
bool CSPHandler::ParseExtensionPagesCSP(
Extension* extension,
std::u16string* error,
std::string_view manifest_key,
const base::Value* content_security_policy) { … }
bool CSPHandler::ParseSandboxCSP(Extension* extension,
std::u16string* error,
std::string_view manifest_key,
const base::Value* sandbox_csp,
bool allow_remote_sources) { … }
bool CSPHandler::SetExtensionPagesCSP(Extension* extension,
std::string_view manifest_key,
std::string content_security_policy) { … }
void CSPHandler::SetSandboxCSP(Extension* extension, std::string sandbox_csp) { … }
bool CSPHandler::AlwaysParseForType(Manifest::Type type) const { … }
base::span<const char* const> CSPHandler::Keys() const { … }
}