Index: components/favicon_base/favicon_types.cc |
diff --git a/components/favicon_base/favicon_types.cc b/components/favicon_base/favicon_types.cc |
index eb0e7bcfa6b0a662720117c33c24ff5abd1b43de..033c7a2ef627bb1e1d677dce8dda190d6547f36a 100644 |
--- a/components/favicon_base/favicon_types.cc |
+++ b/components/favicon_base/favicon_types.cc |
@@ -3,17 +3,38 @@ |
// found in the LICENSE file. |
#include "components/favicon_base/favicon_types.h" |
+#include "ui/gfx/color_utils.h" |
namespace favicon_base { |
-// FaviconImageResult --------------------------------------------------------- |
+namespace { |
+ |
+// Luminance threshold for background color determine whether to use dark or |
+// light text color. |
+int kDarkTextLuminanceThreshold = 190; |
+ |
+// Default values for FallbackIconStyle. |
+SkColor kDefaultBackgroundColor = SkColorSetRGB(0x80, 0x80, 0x80); |
+SkColor kDefaultTextColorDark = SK_ColorBLACK; |
+SkColor kDefaultTextColorLight = SK_ColorWHITE; |
+double kDefaultFontSizeRatio = 0.8; |
+double kDefaultRoundness = 0.125; // 1 / 8. |
+ |
+// Bounds for mebers of FallbackIconStyle; |
+double kMaxFontSizeRatio = 1.0; |
+double kMaxRoundness = 1.0; |
pkotwicz
2015/01/23 16:00:48
Nit: Remove these. It does not make sense to have
huangs
2015/01/23 19:47:52
Removed.
|
+ |
+} // namespace |
+ |
+// --------------------------------------------------------- |
+// FaviconImageResult |
FaviconImageResult::FaviconImageResult() {} |
FaviconImageResult::~FaviconImageResult() {} |
-// FaviconRawBitmapResult |
// -------------------------------------------------------- |
+// FaviconRawBitmapResult |
FaviconRawBitmapResult::FaviconRawBitmapResult() |
: expired(false), icon_type(INVALID_ICON) { |
@@ -22,4 +43,28 @@ FaviconRawBitmapResult::FaviconRawBitmapResult() |
FaviconRawBitmapResult::~FaviconRawBitmapResult() { |
} |
-} // namespace chrome |
+// -------------------------------------------------------- |
+// FallbackIconStyle |
+ |
+FallbackIconStyle::FallbackIconStyle() |
+ : background_color(kDefaultBackgroundColor), |
+ text_color(kDefaultTextColorLight), |
+ font_size_ratio(kDefaultFontSizeRatio), |
+ roundness(kDefaultRoundness) { |
+} |
+ |
+FallbackIconStyle::~FallbackIconStyle() { |
+} |
+ |
+void FallbackIconStyle::MatchTextColorWithBackgroundColor() { |
pkotwicz
2015/01/23 16:00:48
Optional: color_utils::GetReadableColor(SK_ColorBL
huangs
2015/01/23 19:47:52
I just tried this, and got
background #757575 or d
|
+ int luminance = color_utils::GetLuminanceForColor(background_color); |
+ text_color = (luminance >= kDarkTextLuminanceThreshold ? |
+ kDefaultTextColorDark : kDefaultTextColorLight); |
+} |
+ |
+bool FallbackIconStyle::is_valid() const { |
+ return font_size_ratio >= 0.0 && font_size_ratio <= kMaxFontSizeRatio |
+ && roundness >= 0.0 && roundness <= kMaxRoundness; |
pkotwicz
2015/01/23 16:00:48
Style: && goes on the previous line
huangs
2015/01/23 19:47:52
Done.
|
+} |
+ |
+} // namespace favicon_base |