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

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

Issue 835903005: [Favicon] Add new fallback icon rendering flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor by extracting FallbackIconSpecsBuilder. Created 5 years, 11 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_service.cc
diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc
index 064151e925a10491667a4d449234b26602522807..5e33fcb5714ed6c5b0c6d56f8733fd83d43ae7ef 100644
--- a/chrome/browser/favicon/favicon_service.cc
+++ b/chrome/browser/favicon/favicon_service.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
#include "chrome/common/importer/imported_favicon_usage.h"
#include "chrome/common/url_constants.h"
-#include "components/favicon_base/favicon_types.h"
+#include "components/favicon_base/fallback_icon_service.h"
#include "components/favicon_base/favicon_util.h"
#include "components/favicon_base/select_favicon_frames.h"
#include "extensions/common/constants.h"
@@ -22,11 +22,14 @@
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image_skia.h"
+#include "url/gurl.h"
using base::Bind;
namespace {
+const int kMaxFallbackFaviconSize = 288;
+
void CancelOrRunFaviconResultsCallback(
const base::CancelableTaskTracker::IsCanceledCallback& is_canceled,
const favicon_base::FaviconResultsCallback& callback,
@@ -81,6 +84,7 @@ FaviconService::FaviconService(Profile* profile, FaviconClient* favicon_client)
: history_service_(HistoryServiceFactory::GetForProfile(
profile,
ServiceAccessType::EXPLICIT_ACCESS)),
+ fallback_icon_service_(new favicon_base::FallbackIconService()),
profile_(profile),
favicon_client_(favicon_client) {
}
@@ -170,6 +174,29 @@ base::CancelableTaskTracker::TaskId FaviconService::GetFaviconImageForPageURL(
tracker);
}
+base::CancelableTaskTracker::TaskId FaviconService::GetRawFallbackFaviconImage(
+ const GURL& icon_url,
+ favicon_base::IconType icon_type,
+ int desired_size_in_pixel,
+ const favicon_base::FallbackIconSpecs& specs,
+ const favicon_base::FaviconRawBitmapCallback& callback,
+ base::CancelableTaskTracker* tracker) {
+ int size_to_use = desired_size_in_pixel;
+ if (desired_size_in_pixel == 0 ||
+ desired_size_in_pixel > kMaxFallbackFaviconSize) {
+ size_to_use = kMaxFallbackFaviconSize;
+ }
+
+ favicon_base::FaviconResultsCallback callback_runner =
+ Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults,
+ base::Unretained(this),
+ callback,
+ size_to_use);
+
+ return fallback_icon_service_->GetFallbackIcon(
+ icon_url, size_to_use, specs, callback_runner, tracker);
+}
+
base::CancelableTaskTracker::TaskId FaviconService::GetRawFaviconForPageURL(
const GURL& page_url,
int icon_types,

Powered by Google App Engine
This is Rietveld 408576698