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

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, 5 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 19aa1664d244951b7d54748ac2253f3d6c053a79..6ed8d2fa789d9e84a4642b7d9664eaf79c3c711d 100644
--- a/chrome/browser/bookmarks/chrome_bookmark_client.cc
+++ b/chrome/browser/bookmarks/chrome_bookmark_client.cc
@@ -38,6 +38,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)
@@ -97,21 +111,27 @@ 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,
+ favicon_base::IconType type,
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->GetFaviconImageForPageURL(
- FaviconService::FaviconForPageURLParams(
- page_url, icon_types, desired_size_in_dip),
- callback,
- tracker);
+ if (type == favicon_base::FAVICON) {
+ return favicon_service->GetFaviconImageForPageURL(
+ page_url, callback, tracker);
+ } else {
+ return favicon_service->GetRawFaviconForPageURL(
+ page_url,
+ type,
+ 0,
+ base::Bind(&RunCallbackWithImage, callback),
+ tracker);
+ }
}
bool ChromeBookmarkClient::SupportsTypedCountForNodes() {
« no previous file with comments | « chrome/browser/bookmarks/chrome_bookmark_client.h ('k') | chrome/browser/extensions/api/management/management_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698