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

Unified Diff: chrome/browser/favicon/favicon_handler.cc

Issue 1010783002: [Icons NTP] Working prototype to fetch, store, and display big icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
Index: chrome/browser/favicon/favicon_handler.cc
diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc
index a1bbe173e233fe2a84ef2239ba01678f1c2f9afc..e9d894f573e23f18546ce1ce680556e9052953a0 100644
--- a/chrome/browser/favicon/favicon_handler.cc
+++ b/chrome/browser/favicon/favicon_handler.cc
@@ -198,14 +198,12 @@ FaviconHandler::FaviconCandidate::FaviconCandidate(
FaviconHandler::FaviconHandler(FaviconClient* client,
FaviconDriver* driver,
- Type icon_type,
+ Type handler_type,
bool download_largest_icon)
: got_favicon_from_history_(false),
favicon_expired_or_incomplete_(false),
- icon_types_(icon_type == FAVICON
- ? favicon_base::FAVICON
- : favicon_base::TOUCH_ICON |
- favicon_base::TOUCH_PRECOMPOSED_ICON),
+ handler_type_(handler_type),
+ icon_types_(FaviconHandler::GetIconTypesFromHandlerType(handler_type)),
download_largest_icon_(download_largest_icon),
client_(client),
driver_(driver) {
@@ -215,6 +213,14 @@ FaviconHandler::FaviconHandler(FaviconClient* client,
FaviconHandler::~FaviconHandler() {
}
+// static
+int FaviconHandler::GetIconTypesFromHandlerType(
+ FaviconHandler::Type handler_type) {
+ if (handler_type == FAVICON)
+ return favicon_base::FAVICON;
+ return favicon_base::TOUCH_ICON | favicon_base::TOUCH_PRECOMPOSED_ICON;
+}
+
void FaviconHandler::FetchFavicon(const GURL& url) {
cancelable_task_tracker_.TryCancelAll();
@@ -496,6 +502,7 @@ void FaviconHandler::SetHistoryFavicons(const GURL& page_url,
const GURL& icon_url,
favicon_base::IconType icon_type,
const gfx::Image& image) {
+ // TODO(huangs): Get the following to garbage collect if handler_type_ == ALL.
client_->GetFaviconService()->SetFavicons(
page_url, icon_url, icon_type, image);
}
@@ -538,7 +545,7 @@ void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService(
preferred_icon_size(), favicon_bitmap_results);
bool has_valid_result = HasValidResult(favicon_bitmap_results);
- if (has_results && icon_types_ == favicon_base::FAVICON &&
+ if (has_results && handler_type_ == FAVICON &&
!download_largest_icon_ && !driver_->GetActiveFaviconValidity() &&
(!current_candidate() ||
DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results))) {
@@ -576,8 +583,7 @@ void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService(
// else we haven't got the icon url. When we get it we'll ask the
// renderer to download the icon.
- if (has_valid_result &&
- (icon_types_ != favicon_base::FAVICON || download_largest_icon_))
+ if (has_valid_result && (handler_type_ != FAVICON || download_largest_icon_))
NotifyFaviconAvailable(favicon_bitmap_results, false);
}
@@ -621,8 +627,7 @@ void FaviconHandler::OnFaviconData(const std::vector<
preferred_icon_size(), favicon_bitmap_results);
bool has_valid_result = HasValidResult(favicon_bitmap_results);
- if (has_results && icon_types_ == favicon_base::FAVICON &&
- !download_largest_icon_) {
+ if (has_results && handler_type_ == FAVICON && !download_largest_icon_) {
if (has_valid_result) {
// There is a favicon, set it now. If expired we'll download the current
// one again, but at least the user will get some icon instead of the
@@ -647,7 +652,7 @@ void FaviconHandler::OnFaviconData(const std::vector<
history_results_ = favicon_bitmap_results;
if (has_valid_result &&
- (icon_types_ != favicon_base::FAVICON || download_largest_icon_)) {
+ (handler_type_ != FAVICON || download_largest_icon_)) {
NotifyFaviconAvailable(favicon_bitmap_results, false);
}
}

Powered by Google App Engine
This is Rietveld 408576698