#include "extensions/common/manifest_handlers/web_accessible_resources_info.h"
#include <stddef.h>
#include <string_view>
#include <utility>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/types/optional_util.h"
#include "components/crx_file/id_util.h"
#include "extensions/common/api/web_accessible_resources.h"
#include "extensions/common/api/web_accessible_resources_mv2.h"
#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "url/url_constants.h"
namespace extensions {
keys;
errors;
const char kExtensionIdWildcard[] = …;
WebAccessibleResourcesManifestKeys;
WebAccessibleResourcesMv2ManifestKeys;
namespace {
const WebAccessibleResourcesInfo* GetResourcesInfo(const Extension* extension) { … }
URLPattern GetPattern(std::string relative_path, const Extension& extension) { … }
std::unique_ptr<WebAccessibleResourcesInfo> ParseResourceStringList(
const Extension& extension,
std::u16string* error) { … }
std::unique_ptr<WebAccessibleResourcesInfo> ParseEntryList(
const Extension& extension,
std::u16string* error) { … }
bool IsResourceWebAccessibleImpl(
const Extension& extension,
const std::optional<url::Origin>& initiator_origin,
const GURL& upstream_url,
const GURL& target_url) { … }
}
WebAccessibleResourcesInfo::WebAccessibleResourcesInfo() = default;
WebAccessibleResourcesInfo::~WebAccessibleResourcesInfo() = default;
bool WebAccessibleResourcesInfo::IsResourceWebAccessible(
const Extension* extension,
const std::string& relative_path,
const url::Origin* initiator_origin) { … }
bool WebAccessibleResourcesInfo::IsResourceWebAccessibleRedirect(
const Extension* extension,
const GURL& target_url,
const std::optional<url::Origin>& initiator_origin,
const GURL& upstream_url) { … }
bool WebAccessibleResourcesInfo::HasWebAccessibleResources(
const Extension* extension) { … }
bool WebAccessibleResourcesInfo::ShouldUseDynamicUrl(const Extension* extension,
const std::string& path) { … }
WebAccessibleResourcesInfo::Entry::Entry() = default;
WebAccessibleResourcesInfo::Entry::Entry(
WebAccessibleResourcesInfo::Entry&& rhs) = default;
WebAccessibleResourcesInfo::Entry::~Entry() = default;
WebAccessibleResourcesInfo::Entry::Entry(URLPatternSet resources,
URLPatternSet matches,
std::vector<ExtensionId> extension_ids,
bool use_dynamic_url,
bool allow_all_extensions)
: … { … }
WebAccessibleResourcesHandler::WebAccessibleResourcesHandler() = default;
WebAccessibleResourcesHandler::~WebAccessibleResourcesHandler() = default;
bool WebAccessibleResourcesHandler::Parse(Extension* extension,
std::u16string* error) { … }
base::span<const char* const> WebAccessibleResourcesHandler::Keys() const { … }
}