Chromium Code Reviews| Index: chrome/browser/favicon/chrome_fallback_icon_client.cc |
| diff --git a/chrome/browser/favicon/chrome_fallback_icon_client.cc b/chrome/browser/favicon/chrome_fallback_icon_client.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..23bf55da559022e7e976f36013e85034591313ac |
| --- /dev/null |
| +++ b/chrome/browser/favicon/chrome_fallback_icon_client.cc |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/favicon/chrome_fallback_icon_client.h" |
| + |
| +#include "base/i18n/case_conversion.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "grit/platform_locale_settings.h" |
| +#include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| +#include "url/gurl.h" |
| + |
| +ChromeFallbackIconClient::ChromeFallbackIconClient() { |
| +#if defined(OS_CHROMEOS) |
| + font_list_.push_back("Noto Sans"); |
| +#elif defined(OS_IOS) |
| + font_list_.push_back("Helvetica Neue"); |
| +#else |
| + font_list_.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY)); |
| +#endif |
| +} |
| + |
| +ChromeFallbackIconClient::~ChromeFallbackIconClient() { |
| +} |
| + |
| +const std::vector<std::string>& ChromeFallbackIconClient::GetFontNameList() |
| + const { |
| + return font_list_; |
| +} |
| + |
| +// Returns a single character to represent a page URL. To do this we take the |
| +// first letter in a domain's name and make it upper case. |
| +// TODO(huangs): Handle non-ASCII ("xn--") domain names. |
|
pkotwicz
2015/03/27 03:52:09
Nit: Move the comment inside the function.
Return
huangs
2015/03/27 17:33:07
Done, but keeping "Returns". My observation of the
|
| +base::string16 ChromeFallbackIconClient::GetFallbackIconText(const GURL& url) |
| + const { |
| + std::string domain = net::registry_controlled_domains::GetDomainAndRegistry( |
| + url, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| + return domain.empty() ? base::string16() : |
| + base::i18n::ToUpper(base::ASCIIToUTF16(domain.substr(0, 1))); |
| +} |