#include "components/url_formatter/elide_url.h"
#include <stddef.h>
#include <string_view>
#include "base/check_op.h"
#include "base/i18n/rtl.h"
#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/robolectric_buildflags.h"
#include "components/url_formatter/url_formatter.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "url/url_constants.h"
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_ROBOLECTRIC)
#include "ui/gfx/text_constants.h"
#include "ui/gfx/text_elider.h"
#include "ui/gfx/text_utils.h"
#endif
namespace {
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_ROBOLECTRIC)
const char16_t kDot = …;
std::u16string BuildPathFromComponents(
const std::u16string& path_prefix,
const std::vector<std::u16string>& path_elements,
const std::u16string& filename,
size_t num_components) { … }
std::u16string ElideComponentizedPath(
const std::u16string& url_path_prefix,
const std::vector<std::u16string>& url_path_elements,
const std::u16string& url_filename,
const std::u16string& url_query,
const gfx::FontList& font_list,
float available_pixel_width) { … }
#endif
bool ShouldShowScheme(std::string_view scheme,
const url_formatter::SchemeDisplay scheme_display) { … }
std::u16string HostForDisplay(std::string_view host_in_puny) { … }
}
namespace url_formatter {
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_ROBOLECTRIC)
std::u16string ElideUrl(const GURL& url,
const gfx::FontList& font_list,
float available_pixel_width) { … }
std::u16string ElideHost(const GURL& url,
const gfx::FontList& font_list,
float available_pixel_width) { … }
#endif
std::u16string FormatUrlForSecurityDisplay(const GURL& url,
const SchemeDisplay scheme_display) { … }
std::u16string FormatOriginForSecurityDisplay(
const url::Origin& origin,
const SchemeDisplay scheme_display) { … }
std::u16string FormatUrlForDisplayOmitSchemePathAndTrivialSubdomains(
const GURL& url) { … }
#if BUILDFLAG(IS_IOS)
std::u16string
FormatUrlForDisplayOmitSchemePathTrivialSubdomainsAndMobilePrefix(
const GURL& url) {
return url_formatter::FormatUrl(
url,
url_formatter::kFormatUrlOmitDefaults |
url_formatter::kFormatUrlTrimAfterHost |
url_formatter::kFormatUrlOmitHTTPS |
url_formatter::kFormatUrlOmitTrivialSubdomains |
url_formatter::kFormatUrlOmitMobilePrefix,
base::UnescapeRule::SPACES, nullptr, nullptr, nullptr);
}
#endif
void SplitHost(const GURL& url,
std::u16string* url_host,
std::u16string* url_domain,
std::u16string* url_subdomain) { … }
}