OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/favicon/chrome_fallback_icon_client.h" |
| 6 |
| 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" |
| 12 #include "url/gurl.h" |
| 13 |
| 14 ChromeFallbackIconClient::ChromeFallbackIconClient() { |
| 15 #if defined(OS_CHROMEOS) |
| 16 font_list_.push_back("Noto Sans"); |
| 17 #elif defined(OS_IOS) |
| 18 font_list_.push_back("Helvetica Neue"); |
| 19 #else |
| 20 font_list_.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY)); |
| 21 #endif |
| 22 } |
| 23 |
| 24 ChromeFallbackIconClient::~ChromeFallbackIconClient() { |
| 25 } |
| 26 |
| 27 const std::vector<std::string>& ChromeFallbackIconClient::GetFontNameList() |
| 28 const { |
| 29 return font_list_; |
| 30 } |
| 31 |
| 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) |
| 35 const { |
| 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))); |
| 41 } |
OLD | NEW |