chromium/components/policy/core/browser/url_blocklist_manager.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// List of schemes of URLs that should not be blocked by the "*" wildcard in
// the blocklist. Note that URLs with these schemes can still be blocked with
// a more specific filter e.g. "chrome-extension://*".
// The schemes are hardcoded here to avoid dependencies on //extensions and
// //chrome.
const char* kBypassBlocklistWildcardForSchemes[] =;

#if BUILDFLAG(IS_IOS)
// The two schemes used on iOS for the NTP.
constexpr char kIosNtpAboutScheme[] = "about";
constexpr char kIosNtpChromeScheme[] = "chrome";
// The host string used on iOS for the NTP.
constexpr char kIosNtpHost[] = "newtab";
#endif

// Returns a blocklist based on the given |block| and |allow| pattern lists.
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) {}

// Determines if the left-hand side `lhs` filter takes precedence over the
// right-hand side `rhs` filter. Returns true if `lhs` takes precedence over
// `rhs`, false otherwise.
bool FilterTakesPrecedence(const FilterComponents& lhs,
                           const FilterComponents& rhs) {}

}  // namespace

// BlocklistSource implementation that blocks URLs, domains and schemes
// specified by the preference  `blocklist_pref_path`. The `allowlist_pref_path`
// preference specifies exceptions to the blocklist.
// Note that this implementation only supports one observer at a time. Adding a
// new observer will remove the previous one.
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 {}

// static
void URLBlocklistManager::RegisterProfilePrefs(
    user_prefs::PrefRegistrySyncable* registry) {}

void URLBlocklistManager::SetOverrideBlockListSource(
    std::unique_ptr<BlocklistSource> blocklist_source) {}

}  // namespace policy