#include "components/policy/core/browser/url_blocklist_manager.h"
#include <stdint.h>
#include <algorithm>
#include <limits>
#include <set>
#include <string>
#include <utility>
#include "base/check.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/not_fatal_until.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/policy/core/browser/url_blocklist_policy_handler.h"
#include "components/policy/core/common/policy_pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/url_formatter/url_fixer.h"
#include "net/base/filename_util.h"
#include "net/base/net_errors.h"
#include "url/third_party/mozilla/url_parse.h"
#include "url/url_constants.h"
#include "url/url_util.h"
#if BUILDFLAG(IS_IOS)
#include <string_view>
#include "base/strings/string_util.h"
#endif
namespace policy {
URLMatcher;
FilterComponents;
namespace {
const char* kBypassBlocklistWildcardForSchemes[] = …;
#if BUILDFLAG(IS_IOS)
constexpr char kIosNtpAboutScheme[] = "about";
constexpr char kIosNtpChromeScheme[] = "chrome";
constexpr char kIosNtpHost[] = "newtab";
#endif
std::unique_ptr<URLBlocklist> BuildBlocklist(const base::Value::List* block,
const base::Value::List* allow) { … }
const base::Value::List* GetPrefList(const PrefService* pref_service,
std::optional<std::string> pref_path) { … }
bool BypassBlocklistWildcardForURL(const GURL& url) { … }
bool IsWildcardBlocklist(const FilterComponents& filter) { … }
bool FilterTakesPrecedence(const FilterComponents& lhs,
const FilterComponents& rhs) { … }
}
class DefaultBlocklistSource : public BlocklistSource { … };
URLBlocklist::URLBlocklist() : … { … }
URLBlocklist::~URLBlocklist() = default;
void URLBlocklist::Block(const base::Value::List& filters) { … }
void URLBlocklist::Allow(const base::Value::List& filters) { … }
bool URLBlocklist::IsURLBlocked(const GURL& url) const { … }
URLBlocklist::URLBlocklistState URLBlocklist::GetURLBlocklistState(
const GURL& url) const { … }
const FilterComponents* URLBlocklist::GetHighestPriorityFilterFor(
const GURL& url) const { … }
URLBlocklistManager::URLBlocklistManager(
PrefService* pref_service,
std::optional<std::string> blocklist_pref_path,
std::optional<std::string> allowlist_pref_path)
: … { … }
URLBlocklistManager::~URLBlocklistManager() { … }
void URLBlocklistManager::ScheduleUpdate() { … }
void URLBlocklistManager::Update() { … }
void URLBlocklistManager::SetBlocklist(
std::unique_ptr<URLBlocklist> blocklist) { … }
bool URLBlocklistManager::IsURLBlocked(const GURL& url) const { … }
URLBlocklist::URLBlocklistState URLBlocklistManager::GetURLBlocklistState(
const GURL& url) const { … }
void URLBlocklistManager::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
void URLBlocklistManager::SetOverrideBlockListSource(
std::unique_ptr<BlocklistSource> blocklist_source) { … }
}