1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/favicon/chrome_fallback_icon_client.h"
7 #include "base/i18n/case_conversion.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "grit/platform_locale_settings.h"
10 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
11 #include "ui/base/l10n/l10n_util.h"
14 ChromeFallbackIconClient::ChromeFallbackIconClient() {
15 #if defined(OS_CHROMEOS)
16 font_list_
.push_back("Noto Sans");
18 font_list_
.push_back("Helvetica Neue");
20 font_list_
.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY
));
24 ChromeFallbackIconClient::~ChromeFallbackIconClient() {
27 const std::vector
<std::string
>& ChromeFallbackIconClient::GetFontNameList()
32 // Returns a single character to represent |url|. To do this we take the first
33 // letter in a domain's name and make it upper case.
34 base::string16
ChromeFallbackIconClient::GetFallbackIconText(const GURL
& url
)
36 // TODO(huangs): Handle non-ASCII ("xn--") domain names.
37 std::string domain
= net::registry_controlled_domains::GetDomainAndRegistry(
38 url
, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES
);
39 return domain
.empty() ? base::string16() :
40 base::i18n::ToUpper(base::ASCIIToUTF16(domain
.substr(0, 1)));