Chromium Code Reviews| Index: chrome/browser/favicon/favicon_service.cc |
| diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc |
| index fd0f9eb557c4cd9931b4a70dee6df9e80020add7..36e3f49f9d1f7556b4c947d1f730072387917ba4 100644 |
| --- a/chrome/browser/favicon/favicon_service.cc |
| +++ b/chrome/browser/favicon/favicon_service.cc |
| @@ -45,6 +45,21 @@ CancelableTaskTracker::TaskId RunWithEmptyResultAsync( |
| Bind(callback, std::vector<chrome::FaviconBitmapResult>())); |
| } |
| +CancelableTaskTracker::TaskId GetFaviconForChromeURL( |
|
sky
2013/10/15 15:03:47
Add description.
michaelbai
2013/10/15 19:36:31
Done.
|
| + Profile* profile, |
| + const GURL& page_url, |
| + const std::vector<ui::ScaleFactor>& desired_scale_factors, |
| + const FaviconService::FaviconResultsCallback& callback, |
| + CancelableTaskTracker* tracker) { |
| + CancelableTaskTracker::IsCanceledCallback is_canceled_cb; |
| + CancelableTaskTracker::TaskId id = tracker->NewTrackedTaskId(&is_canceled_cb); |
| + FaviconService::FaviconResultsCallback cancelable_cb = |
| + Bind(&CancelOrRunFaviconResultsCallback, is_canceled_cb, callback); |
| + ChromeWebUIControllerFactory::GetInstance()->GetFaviconForURL(profile, |
| + page_url, desired_scale_factors, cancelable_cb); |
| + return id; |
|
sky
2013/10/15 15:03:47
nit: indentation is off.
michaelbai
2013/10/15 19:36:31
Done.
|
| +} |
| + |
| } // namespace |
| FaviconService::FaviconService(HistoryService* history_service) |
| @@ -169,6 +184,23 @@ CancelableTaskTracker::TaskId FaviconService::GetRawFaviconForURL( |
| tracker); |
| } |
| +CancelableTaskTracker::TaskId FaviconService::GetLargestRawFaviconForURL( |
| + Profile* profile, |
| + const GURL& page_url, |
| + const std::vector<int>& icon_types, |
| + int minimal_size_in_pixel, |
| + const FaviconRawCallback& callback, |
| + CancelableTaskTracker* tracker) { |
| + return GetLargestRawFaviconForURLImpl( |
| + profile, page_url, icon_types, minimal_size_in_pixel, |
| + Bind(&FaviconService::RunFaviconRawCallbackWithBitmapResults, |
| + base::Unretained(this), |
| + callback, |
| + 0, |
| + ui::ScaleFactor()), |
| + tracker); |
| +} |
| + |
| CancelableTaskTracker::TaskId FaviconService::GetFaviconForURL( |
| const FaviconForURLParams& params, |
| const FaviconResultsCallback& callback, |
| @@ -284,15 +316,8 @@ CancelableTaskTracker::TaskId FaviconService::GetFaviconForURLImpl( |
| CancelableTaskTracker* tracker) { |
| if (params.page_url.SchemeIs(chrome::kChromeUIScheme) || |
| params.page_url.SchemeIs(extensions::kExtensionScheme)) { |
| - CancelableTaskTracker::IsCanceledCallback is_canceled_cb; |
| - CancelableTaskTracker::TaskId id = |
| - tracker->NewTrackedTaskId(&is_canceled_cb); |
| - |
| - FaviconResultsCallback cancelable_cb = |
| - Bind(&CancelOrRunFaviconResultsCallback, is_canceled_cb, callback); |
| - ChromeWebUIControllerFactory::GetInstance()->GetFaviconForURL( |
| - params.profile, params.page_url, desired_scale_factors, cancelable_cb); |
| - return id; |
| + return GetFaviconForChromeURL(params.profile, params.page_url, |
| + desired_scale_factors, callback, tracker); |
| } else if (history_service_) { |
| return history_service_->GetFaviconsForURL(params.page_url, |
| params.icon_types, |
| @@ -305,6 +330,25 @@ CancelableTaskTracker::TaskId FaviconService::GetFaviconForURLImpl( |
| } |
| } |
| +CancelableTaskTracker::TaskId FaviconService::GetLargestRawFaviconForURLImpl( |
| + Profile* profile, |
| + const GURL& page_url, |
| + const std::vector<int>& icon_types, |
| + int minimal_size_in_pixel, |
| + const FaviconResultsCallback& callback, |
| + CancelableTaskTracker* tracker) { |
| + if (page_url.SchemeIs(chrome::kChromeUIScheme) || |
| + page_url.SchemeIs(extensions::kExtensionScheme)) { |
| + return GetFaviconForChromeURL(profile, page_url, |
| + std::vector<ui::ScaleFactor>(), callback, tracker); |
| + } else if (history_service_) { |
| + return history_service_->GetLargestFaviconForURL(page_url, icon_types, |
| + minimal_size_in_pixel, callback, tracker); |
| + } else { |
| + return RunWithEmptyResultAsync(callback, tracker); |
| + } |
| +} |
| + |
| void FaviconService::RunFaviconImageCallbackWithBitmapResults( |
| const FaviconImageCallback& callback, |
| int desired_size_in_dip, |