chromium/components/google/core/common/google_util.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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/google/core/common/google_util.h"

#include <stddef.h>

#include <string>
#include <string_view>
#include <vector>

#include "base/command_line.h"
#include "base/containers/fixed_flat_set.h"
#include "base/no_destructor.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/google/core/common/google_switches.h"
#include "components/google/core/common/google_tld_list.h"
#include "components/url_formatter/url_fixer.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/base/url_util.h"
#include "url/gurl.h"

namespace google_util {

// Helpers --------------------------------------------------------------------

namespace {

bool IsPathHomePageBase(std::string_view path) {}

// Removes a single trailing dot if present in |host|.
void StripTrailingDot(std::string_view* host) {}

// True if the given canonical |host| is "[www.]<domain_in_lower_case>.<TLD>"
// with a valid TLD that appears in |allowed_tlds|. If |subdomain_permission| is
// ALLOW_SUBDOMAIN, we check against host "*.<domain_in_lower_case>.<TLD>"
// instead.
template <typename Container>
bool IsValidHostName(std::string_view host,
                     std::string_view domain_in_lower_case,
                     SubdomainPermission subdomain_permission,
                     const Container& allowed_tlds) {}

// True if |url| is a valid URL with HTTP or HTTPS scheme. If |port_permission|
// is DISALLOW_NON_STANDARD_PORTS, this also requires |url| to use the standard
// port for its scheme (80 for HTTP, 443 for HTTPS).
bool IsValidURL(const GURL& url, PortPermission port_permission) {}

bool IsCanonicalHostGoogleHostname(std::string_view canonical_host,
                                   SubdomainPermission subdomain_permission) {}

bool IsCanonicalHostYoutubeHostname(std::string_view canonical_host,
                                    SubdomainPermission subdomain_permission) {}

// True if |url| is a valid URL with a host that is in the static list of
// Google subdomains for google search, and an HTTP or HTTPS scheme. Requires
// |url| to use the standard port for its scheme (80 for HTTP, 443 for HTTPS).
bool IsGoogleSearchSubdomainUrl(const GURL& url) {}

}  // namespace

// Global functions -----------------------------------------------------------

const char kGoogleHomepageURL[] =;

bool HasGoogleSearchQueryParam(std::string_view str) {}

std::string GetGoogleLocale(const std::string& application_locale) {}

GURL AppendGoogleLocaleParam(const GURL& url,
                             const std::string& application_locale) {}

std::string GetGoogleCountryCode(const GURL& google_homepage_url) {}

GURL GetGoogleSearchURL(const GURL& google_homepage_url) {}

const GURL& CommandLineGoogleBaseURL() {}

bool StartsWithCommandLineGoogleBaseURL(const GURL& url) {}

bool IsGoogleDomainUrl(const GURL& url,
                       SubdomainPermission subdomain_permission,
                       PortPermission port_permission) {}

bool IsGoogleHostname(std::string_view host,
                      SubdomainPermission subdomain_permission) {}

bool IsGoogleHomePageUrl(const GURL& url) {}

bool IsGoogleSearchUrl(const GURL& url) {}

bool IsYoutubeDomainUrl(const GURL& url,
                        SubdomainPermission subdomain_permission,
                        PortPermission port_permission) {}

bool IsGoogleAssociatedDomainUrl(const GURL& url) {}

const std::vector<std::string>& GetGoogleRegistrableDomains() {}

GURL AppendToAsyncQueryParam(const GURL& url,
                             const std::string& key,
                             const std::string& value) {}

GoogleSearchMode GoogleSearchModeFromUrl(const GURL& url) {}

}  // namespace google_util