Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: components/favicon/core/fallback_icon_service.cc

Issue 2883053003: Delete unused chrome://fallback-icon/ handling (Closed)
Patch Set: Merge branch 'master' into searchbox3 Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/favicon/core/fallback_icon_service.h ('k') | components/favicon_base/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/favicon/core/fallback_icon_service.cc
diff --git a/components/favicon/core/fallback_icon_service.cc b/components/favicon/core/fallback_icon_service.cc
deleted file mode 100644
index 291e1fac8a9ddd9cd3f8e6eb2c7aa8a7990e2db7..0000000000000000000000000000000000000000
--- a/components/favicon/core/fallback_icon_service.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// 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 "components/favicon/core/fallback_icon_service.h"
-
-#include <stddef.h>
-
-#include <algorithm>
-
-#include "cc/paint/skia_paint_canvas.h"
-#include "components/favicon/core/fallback_icon_client.h"
-#include "components/favicon/core/fallback_url_util.h"
-#include "components/favicon_base/fallback_icon_style.h"
-#include "third_party/skia/include/core/SkPaint.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/codec/png_codec.h"
-#include "ui/gfx/font_list.h"
-#include "ui/gfx/geometry/rect.h"
-#include "ui/gfx/geometry/size.h"
-#include "url/gurl.h"
-
-namespace favicon {
-namespace {
-
-// Arbitrary maximum icon size, can be reasonably increased if needed.
-const int kMaxFallbackFaviconSize = 288;
-
-} // namespace
-
-FallbackIconService::FallbackIconService(
- FallbackIconClient* fallback_icon_client)
- : fallback_icon_client_(fallback_icon_client) {
-}
-
-FallbackIconService::~FallbackIconService() {
-}
-
-std::vector<unsigned char> FallbackIconService::RenderFallbackIconBitmap(
- const GURL& icon_url,
- int size,
- const favicon_base::FallbackIconStyle& style) {
- int size_to_use = std::min(kMaxFallbackFaviconSize, size);
- SkBitmap bitmap;
- bitmap.allocN32Pixels(size_to_use, size_to_use, false);
- cc::SkiaPaintCanvas paint_canvas(bitmap);
- gfx::Canvas canvas(&paint_canvas, 1.f);
-
- DrawFallbackIcon(icon_url, size_to_use, style, &canvas);
-
- std::vector<unsigned char> bitmap_data;
- if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &bitmap_data))
- bitmap_data.clear();
- return bitmap_data;
-}
-
-void FallbackIconService::DrawFallbackIcon(
- const GURL& icon_url,
- int size,
- const favicon_base::FallbackIconStyle& style,
- gfx::Canvas* canvas) {
- const int kOffsetX = 0;
- const int kOffsetY = 0;
- cc::PaintFlags flags;
- flags.setStyle(cc::PaintFlags::kFill_Style);
- flags.setAntiAlias(true);
-
- // Draw a filled, colored rounded square.
- flags.setColor(style.background_color);
- int corner_radius = static_cast<int>(size * style.roundness * 0.5 + 0.5);
- canvas->DrawRoundRect(gfx::Rect(kOffsetX, kOffsetY, size, size),
- corner_radius, flags);
-
- // Draw text.
- base::string16 icon_text = GetFallbackIconText(icon_url);
- if (icon_text.empty())
- return;
- int font_size = static_cast<int>(size * style.font_size_ratio);
- if (font_size <= 0)
- return;
-
- canvas->DrawStringRectWithFlags(
- icon_text,
- gfx::FontList(fallback_icon_client_->GetFontNameList(), gfx::Font::NORMAL,
- font_size, gfx::Font::Weight::NORMAL),
- style.text_color, gfx::Rect(kOffsetX, kOffsetY, size, size),
- gfx::Canvas::TEXT_ALIGN_CENTER);
-}
-
-} // namespace favicon
« no previous file with comments | « components/favicon/core/fallback_icon_service.h ('k') | components/favicon_base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698