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"
15 const char* kFallbackIconTextForIP
= "IP";
18 ChromeFallbackIconClient::ChromeFallbackIconClient() {
19 #if defined(OS_CHROMEOS)
20 font_list_
.push_back("Noto Sans");
22 font_list_
.push_back("Helvetica Neue");
24 font_list_
.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY
));
28 ChromeFallbackIconClient::~ChromeFallbackIconClient() {
31 const std::vector
<std::string
>& ChromeFallbackIconClient::GetFontNameList()
36 // Returns a single character to represent |url|. To do this we take the first
37 // letter in a domain's name and make it upper case.
38 base::string16
ChromeFallbackIconClient::GetFallbackIconText(const GURL
& url
)
41 return base::string16();
42 std::string domain
= net::registry_controlled_domains::GetDomainAndRegistry(
43 url
, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES
);
44 if (domain
.empty()) { // E.g., http://localhost/ or http://192.168.0.1/
45 if (url
.HostIsIPAddress())
46 return base::ASCIIToUTF16(kFallbackIconTextForIP
);
50 return base::string16();
51 // TODO(huangs): Handle non-ASCII ("xn--") domain names.
52 return base::i18n::ToUpper(base::ASCIIToUTF16(domain
.substr(0, 1)));