chromium/components/url_matcher/url_util.cc

// Copyright 2018 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/url_matcher/url_util.h"

#include <memory>
#include <string>

#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "components/google/core/common/google_util.h"
#include "components/url_formatter/url_fixer.h"
#include "components/url_matcher/url_matcher.h"
#include "net/base/filename_util.h"
#include "net/base/url_util.h"
#include "third_party/re2/src/re2/re2.h"
#include "url/gurl.h"

URLMatcher;
URLMatcherCondition;
URLMatcherConditionFactory;
URLMatcherConditionSet;
URLMatcherPortFilter;
URLMatcherSchemeFilter;
URLQueryElementMatcherCondition;

namespace url_matcher {
namespace util {

namespace {

// Host/regex pattern for Google AMP Cache URLs.
// See https://developers.google.com/amp/cache/overview#amp-cache-url-format
// for a definition of the format of AMP Cache URLs.
const char kGoogleAmpCacheHost[] =;
const char kGoogleAmpCachePathPattern[] =;

// Regex pattern for the path of Google AMP Viewer URLs.
const char kGoogleAmpViewerPathPattern[] =;

// Host, path prefix, and query regex pattern for Google web cache URLs.
const char kGoogleWebCacheHost[] =;
const char kGoogleWebCachePathPrefix[] =;
const char kGoogleWebCacheQueryPattern[] =;

const char kGoogleTranslateSubdomain[] =;
const char kAlternateGoogleTranslateHost[] =;

// Maximum filters allowed. Filters over this index are ignored.
const size_t kMaxFiltersAllowed =;

// Returns a full URL using either "http" or "https" as the scheme.
GURL BuildURL(bool is_https, const std::string& host_and_path) {}

void ProcessQueryToConditions(
    url_matcher::URLMatcherConditionFactory* condition_factory,
    const std::string& query,
    bool allow,
    std::set<URLQueryElementMatcherCondition>* query_conditions) {}

// Helper class for testing the URL against precompiled regexes. This is a
// singleton so the cached regexes are only created once.
class EmbeddedURLExtractor {};

}  // namespace

// Converts a ValueList |value| of strings into a vector. Returns true if
// successful.
bool GetAsStringVector(const base::Value* value,
                       std::vector<std::string>* out) {}

GURL Normalize(const GURL& url) {}

GURL GetEmbeddedURL(const GURL& url) {}

size_t GetMaxFiltersAllowed() {}

FilterComponents::FilterComponents() = default;
FilterComponents::~FilterComponents() = default;
FilterComponents::FilterComponents(FilterComponents&&) = default;

bool FilterComponents::IsWildcard() const {}

scoped_refptr<URLMatcherConditionSet> CreateConditionSet(
    URLMatcher* url_matcher,
    base::MatcherStringPattern::ID id,
    const std::string& scheme,
    const std::string& host,
    bool match_subdomains,
    uint16_t port,
    const std::string& path,
    const std::string& query,
    bool allow) {}

bool FilterToComponents(const std::string& filter,
                        std::string* scheme,
                        std::string* host,
                        bool* match_subdomains,
                        uint16_t* port,
                        std::string* path,
                        std::string* query) {}

void AddFilters(URLMatcher* matcher,
                bool allow,
                base::MatcherStringPattern::ID* id,
                const base::Value::List& patterns,
                std::map<base::MatcherStringPattern::ID,
                         url_matcher::util::FilterComponents>* filters) {}

void AddFilters(URLMatcher* matcher,
                bool allow,
                base::MatcherStringPattern::ID* id,
                const std::vector<std::string>& patterns,
                std::map<base::MatcherStringPattern::ID,
                         url_matcher::util::FilterComponents>* filters) {}

void AddAllowFilters(url_matcher::URLMatcher* matcher,
                     const base::Value::List& patterns) {}

void AddAllowFilters(url_matcher::URLMatcher* matcher,
                     const std::vector<std::string>& patterns) {}

}  // namespace util
}  // namespace url_matcher