summaryrefslogtreecommitdiffstats
path: root/components/favicon_base/fallback_icon_style.h
diff options
context:
space:
mode:
authorhuangs <huangs@chromium.org>2015-02-11 14:18:38 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-11 22:19:03 +0000
commit3382fc9d60d79fc9d829fd626a4d591d2f2a23ff (patch)
tree67ba7273e057d307aaf37a56262217f1ac2a0e4d /components/favicon_base/fallback_icon_style.h
parent17d1302c86810f3313c18894f601e21eb6a45f19 (diff)
downloadchromium_src-3382fc9d60d79fc9d829fd626a4d591d2f2a23ff.zip
chromium_src-3382fc9d60d79fc9d829fd626a4d591d2f2a23ff.tar.gz
chromium_src-3382fc9d60d79fc9d829fd626a4d591d2f2a23ff.tar.bz2
[Favicon] Add FallbackIconStyle and FallbackIconService.
Design: go/chrome-fallback-icons This implements - FallbackIconStyle: A struct to specify fallback data. - FallbackIconService: Helper class to render the fallback icon as a filled rounded square with a single letter from the URL. - Extra dependencies are needed to convert URL to the icon letter. This CL is sliced off from https://codereview.chromium.org/835903005/ . BUG=455063 Review URL: https://codereview.chromium.org/886163003 Cr-Commit-Position: refs/heads/master@{#315854}
Diffstat (limited to 'components/favicon_base/fallback_icon_style.h')
-rw-r--r--components/favicon_base/fallback_icon_style.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/components/favicon_base/fallback_icon_style.h b/components/favicon_base/fallback_icon_style.h
new file mode 100644
index 0000000..097636b
--- /dev/null
+++ b/components/favicon_base/fallback_icon_style.h
@@ -0,0 +1,42 @@
+// 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.
+
+#ifndef COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_
+#define COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_
+
+#include "third_party/skia/include/core/SkColor.h"
+
+namespace favicon_base {
+
+// Styling specifications of a fallback icon. The icon is composed of a solid
+// rounded square containing a single letter. The specification excludes the
+// icon URL and size, which are given when the icon is rendered.
+struct FallbackIconStyle {
+ FallbackIconStyle();
+ ~FallbackIconStyle();
+
+ // If any member changes, also update FallbackIconStyleBuilder.
+
+ // Icon background fill color.
+ SkColor background_color;
+
+ // Icon text color.
+ SkColor text_color;
+
+ // Ratio in [0.0, 1.0] of the text font size (pixels) to the icon size.
+ double font_size_ratio;
+
+ // The roundness of the icon's corners. 0 => square icon, 1 => circle icon.
+ double roundness;
+};
+
+// Reassigns |style|'s |text_color| to matches well against |background_color|.
+void MatchFallbackIconTextColorAgainstBackgroundColor(FallbackIconStyle* style);
+
+// Returns whether |style| values are within bounds.
+bool ValidateFallbackIconStyle(const FallbackIconStyle& style);
+
+} // namespace favicon_base
+
+#endif // COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_