Commit a5e8bc4e authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

🦁Show favicons retrieved from cache immediately, preventing flashing

Before, the favicon completion was always called asynchronously,
leading to the original icon appearing for a split second when a
favicon was found in the cache. Now, that completion will be displayed
instantly.

The asynchronicity was there to simplify the FaviconRetriever logic
(the completion was always called asynchronously), but that isn't
actually super important.

Bug: 964918
Change-Id: I30b7d2f8d9fe0ed9324e48eb994ce677398b388b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626861
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662595}
parent d1a5b230
...@@ -12,7 +12,8 @@ class GURL; ...@@ -12,7 +12,8 @@ class GURL;
// favicon retrieving logic from the View layer. // favicon retrieving logic from the View layer.
@protocol FaviconRetriever <NSObject> @protocol FaviconRetriever <NSObject>
// Fetches favicon given a page URL. // Fetches favicon given a page URL.
// |completion| is guaranteed to only be called asynchronously on main thread. // |completion| is guaranteed to only be called on main thread, but could be
// called at any time, even before this returns.
// It might never be called if the favicon is not available. // It might never be called if the favicon is not available.
// It might be called multiple times per request. // It might be called multiple times per request.
- (void)fetchFavicon:(GURL)pageURL completion:(void (^)(UIImage*))completion; - (void)fetchFavicon:(GURL)pageURL completion:(void (^)(UIImage*))completion;
......
...@@ -195,9 +195,7 @@ const CGFloat kOmniboxIconSize = 16; ...@@ -195,9 +195,7 @@ const CGFloat kOmniboxIconSize = 16;
// Only use cached attributes when they are a non-default icon. Never show // Only use cached attributes when they are a non-default icon. Never show
// monograms or default globe icon. // monograms or default globe icon.
if (cachedAttributes.faviconImage && !cachedAttributes.usesDefaultImage) { if (cachedAttributes.faviconImage && !cachedAttributes.usesDefaultImage) {
dispatch_async(dispatch_get_main_queue(), ^() {
completion(cachedAttributes.faviconImage); completion(cachedAttributes.faviconImage);
});
} }
} }
......
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