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

Unified Diff: chrome/browser/bookmarks/chrome_bookmark_client.cc

Issue 331163003: [Refactor] Change FaviconService API to take in a desired pixel size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/bookmarks/chrome_bookmark_client.cc
diff --git a/chrome/browser/bookmarks/chrome_bookmark_client.cc b/chrome/browser/bookmarks/chrome_bookmark_client.cc
index cc590fbc54fb08462e65ba9c0b613afd4458e700..5eaccac8e3d777640ab808b110bc29e02a39f74a 100644
--- a/chrome/browser/bookmarks/chrome_bookmark_client.cc
+++ b/chrome/browser/bookmarks/chrome_bookmark_client.cc
@@ -40,6 +40,20 @@ void NotifyHistoryOfRemovedURLs(Profile* profile,
history_service->URLsNoLongerBookmarked(removed_urls);
}
+void RunCallbackWithImage(
+ const favicon_base::FaviconImageCallback& callback,
+ const favicon_base::FaviconRawBitmapResult& bitmap_result) {
+ favicon_base::FaviconImageResult result;
+ if (bitmap_result.is_valid()) {
+ result.image = gfx::Image::CreateFrom1xPNGBytes(
+ bitmap_result.bitmap_data->front(), bitmap_result.bitmap_data->size());
+ result.icon_url = bitmap_result.icon_url;
+ callback.Run(result);
+ return;
+ }
+ callback.Run(result);
+}
+
} // namespace
ChromeBookmarkClient::ChromeBookmarkClient(Profile* profile)
@@ -99,10 +113,9 @@ bool ChromeBookmarkClient::PreferTouchIcon() {
#endif
}
-base::CancelableTaskTracker::TaskId ChromeBookmarkClient::GetFaviconImageForURL(
+base::CancelableTaskTracker::TaskId
+ChromeBookmarkClient::GetFaviconImageForPageURL(
const GURL& page_url,
- int icon_types,
- int desired_size_in_dip,
const favicon_base::FaviconImageCallback& callback,
base::CancelableTaskTracker* tracker) {
FaviconService* favicon_service =
@@ -110,9 +123,23 @@ base::CancelableTaskTracker::TaskId ChromeBookmarkClient::GetFaviconImageForURL(
if (!favicon_service)
return base::CancelableTaskTracker::kBadTaskId;
return favicon_service->GetFaviconImageForPageURL(
- FaviconService::FaviconForPageURLParams(
- page_url, icon_types, desired_size_in_dip),
- callback,
+ page_url, callback, tracker);
+}
+
+base::CancelableTaskTracker::TaskId
+ChromeBookmarkClient::GetTouchFaviconImageForPageURL(
+ const GURL& page_url,
+ const favicon_base::FaviconImageCallback& callback,
+ base::CancelableTaskTracker* tracker) {
+ FaviconService* favicon_service =
+ FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
+ if (!favicon_service)
+ return base::CancelableTaskTracker::kBadTaskId;
+ return favicon_service->GetRawFaviconForPageURL(
+ page_url,
+ favicon_base::TOUCH_ICON,
+ 0,
+ base::Bind(&RunCallbackWithImage, callback),
tracker);
}

Powered by Google App Engine
This is Rietveld 408576698