Commit e32c79ad authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Polish Collections Fallback Icon Styling

Set text color to a custom gray color and do not set the background color provided by the fallback style.

Bug: 851390
Change-Id: I185b609577652f8b23a92d0dcc76a485fb967f28
Reviewed-on: https://chromium-review.googlesource.com/1112632
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570834}
parent c98557a9
...@@ -32,6 +32,7 @@ source_set("favicon") { ...@@ -32,6 +32,7 @@ source_set("favicon") {
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/history", "//ios/chrome/browser/history",
"//ios/chrome/browser/ui:ui_util",
"//ios/chrome/common/favicon", "//ios/chrome/common/favicon",
"//ios/web", "//ios/web",
"//skia", "//skia",
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "components/favicon_base/fallback_icon_style.h" #include "components/favicon_base/fallback_icon_style.h"
#include "components/favicon_base/favicon_callback.h" #include "components/favicon_base/favicon_callback.h"
#include "ios/chrome/browser/experimental_flags.h" #include "ios/chrome/browser/experimental_flags.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/chrome/common/favicon/favicon_attributes.h" #import "ios/chrome/common/favicon/favicon_attributes.h"
#include "skia/ext/skia_utils_ios.h" #include "skia/ext/skia_utils_ios.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -22,6 +23,10 @@ ...@@ -22,6 +23,10 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
namespace {
extern const CGFloat kFallbackIconDefaultTextColor = 0xAAAAAA;
} // namespace
FaviconLoader::FaviconLoader(favicon::LargeIconService* large_icon_service) FaviconLoader::FaviconLoader(favicon::LargeIconService* large_icon_service)
: large_icon_service_(large_icon_service), : large_icon_service_(large_icon_service),
favicon_cache_([[NSCache alloc] init]) {} favicon_cache_([[NSCache alloc] init]) {}
...@@ -59,15 +64,22 @@ FaviconAttributes* FaviconLoader::FaviconForUrl( ...@@ -59,15 +64,22 @@ FaviconAttributes* FaviconLoader::FaviconForUrl(
return; return;
} }
DCHECK(result.fallback_icon_style); DCHECK(result.fallback_icon_style);
UIColor* textColor =
skia::UIColorFromSkColor(result.fallback_icon_style->text_color);
UIColor* backgroundColor =
skia::UIColorFromSkColor(result.fallback_icon_style->background_color);
if (experimental_flags::IsCollectionsUIRebootEnabled()) {
textColor = UIColorFromRGB(kFallbackIconDefaultTextColor);
backgroundColor = [UIColor clearColor];
}
FaviconAttributes* attributes = [FaviconAttributes FaviconAttributes* attributes = [FaviconAttributes
attributesWithMonogram:base::SysUTF16ToNSString( attributesWithMonogram:base::SysUTF16ToNSString(
favicon::GetFallbackIconText(block_url)) favicon::GetFallbackIconText(block_url))
textColor:skia::UIColorFromSkColor( textColor:textColor
result.fallback_icon_style->text_color) backgroundColor:backgroundColor
backgroundColor:skia::UIColorFromSkColor(
result.fallback_icon_style->background_color)
defaultBackgroundColor:result.fallback_icon_style-> defaultBackgroundColor:result.fallback_icon_style->
is_default_background_color]; is_default_background_color];
[favicon_cache_ setObject:attributes forKey:key]; [favicon_cache_ setObject:attributes forKey:key];
block(attributes); block(attributes);
}; };
......
...@@ -16,6 +16,7 @@ source_set("favicon") { ...@@ -16,6 +16,7 @@ source_set("favicon") {
"//components/favicon/core", "//components/favicon/core",
"//components/favicon_base", "//components/favicon_base",
"//ios/chrome/browser/favicon", "//ios/chrome/browser/favicon",
"//ios/chrome/browser/ui:ui_util",
"//ios/chrome/common/favicon", "//ios/chrome/common/favicon",
"//url", "//url",
] ]
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
namespace { namespace {
// Default corner radius for the favicon image view. // Default corner radius for the favicon image view.
const CGFloat kDefaultCornerRadius = 3; const CGFloat kDefaultCornerRadius = 3;
// Percentage of white for the default background, when there is no attributes.
const CGFloat kDefaultWhitePercentage = 0.47;
} }
@interface FaviconViewNew () { @interface FaviconViewNew () {
...@@ -41,9 +39,9 @@ const CGFloat kDefaultWhitePercentage = 0.47; ...@@ -41,9 +39,9 @@ const CGFloat kDefaultWhitePercentage = 0.47;
_faviconImageView.image = nil; _faviconImageView.image = nil;
_faviconFallbackLabel = [[UILabel alloc] initWithFrame:self.bounds]; _faviconFallbackLabel = [[UILabel alloc] initWithFrame:self.bounds];
_faviconFallbackLabel.backgroundColor =
[UIColor colorWithWhite:kDefaultWhitePercentage alpha:1];
_faviconFallbackLabel.textAlignment = NSTextAlignmentCenter; _faviconFallbackLabel.textAlignment = NSTextAlignmentCenter;
_faviconFallbackLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
_faviconFallbackLabel.isAccessibilityElement = NO; _faviconFallbackLabel.isAccessibilityElement = NO;
_faviconFallbackLabel.clipsToBounds = YES; _faviconFallbackLabel.clipsToBounds = YES;
_faviconFallbackLabel.layer.cornerRadius = kDefaultCornerRadius; _faviconFallbackLabel.layer.cornerRadius = kDefaultCornerRadius;
...@@ -64,8 +62,6 @@ const CGFloat kDefaultWhitePercentage = 0.47; ...@@ -64,8 +62,6 @@ const CGFloat kDefaultWhitePercentage = 0.47;
- (void)configureWithAttributes:(FaviconAttributes*)attributes { - (void)configureWithAttributes:(FaviconAttributes*)attributes {
if (!attributes) { if (!attributes) {
self.faviconFallbackLabel.backgroundColor =
[UIColor colorWithWhite:kDefaultWhitePercentage alpha:1];
self.faviconFallbackLabel.text = nil; self.faviconFallbackLabel.text = nil;
self.faviconFallbackLabel.hidden = NO; self.faviconFallbackLabel.hidden = NO;
self.faviconImageView.hidden = YES; self.faviconImageView.hidden = YES;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment