Index: chrome/browser/android/shortcut_data_fetcher.cc |
diff --git a/chrome/browser/android/shortcut_data_fetcher.cc b/chrome/browser/android/shortcut_data_fetcher.cc |
index e419712d7e50b235b052e697cd38250addb6bfc2..fc936fedc6917d405033d0b90fc54a2fbf16257a 100644 |
--- a/chrome/browser/android/shortcut_data_fetcher.cc |
+++ b/chrome/browser/android/shortcut_data_fetcher.cc |
@@ -9,6 +9,7 @@ |
#include "base/strings/string16.h" |
#include "base/task/cancelable_task_tracker.h" |
#include "chrome/browser/favicon/favicon_service_factory.h" |
+#include "chrome/browser/manifest/manifest_icon_downloader.h" |
#include "chrome/browser/manifest/manifest_icon_selector.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/common/chrome_constants.h" |
@@ -45,6 +46,7 @@ ShortcutDataFetcher::ShortcutDataFetcher( |
icon_timeout_timer_(false, false), |
shortcut_info_(dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( |
web_contents->GetURL())), |
+ icon_downloader_(new ManifestIconDownloader(web_contents)), |
preferred_icon_size_in_px_(kPreferredIconSizeInDp * |
gfx::Screen::GetScreenFor(web_contents->GetNativeView())-> |
GetPrimaryDisplay().device_scale_factor()) { |
@@ -109,16 +111,13 @@ void ShortcutDataFetcher::OnDidGetManifest(const content::Manifest& manifest) { |
manifest.icons, |
kPreferredIconSizeInDp, |
gfx::Screen::GetScreenFor(web_contents()->GetNativeView())); |
- if (icon_src.is_valid()) { |
- // Grab the best icon from the manifest. |
- web_contents()->DownloadImage( |
- icon_src, |
- false, |
- preferred_icon_size_in_px_, |
- false, |
- base::Bind(&ShortcutDataFetcher::OnManifestIconFetched, |
- this)); |
- } else { |
+ bool success = icon_downloader_->Download( |
mlamouri (slow - plz ping)
2015/08/07 10:11:11
nit: no need for the |success| temporary variable.
Lalit Maganti
2015/08/07 13:04:30
Done.
|
+ icon_src, |
+ kPreferredIconSizeInDp, |
+ base::Bind(&ShortcutDataFetcher::NotifyObserver, |
+ this)); |
+ |
+ if (!success) { |
// Grab the best favicon for the page. |
FetchFavicon(); |
} |
@@ -217,34 +216,6 @@ void ShortcutDataFetcher::CreateLauncherIcon( |
base::Bind(&ShortcutDataFetcher::NotifyObserver, this, icon_bitmap)); |
} |
-void ShortcutDataFetcher::OnManifestIconFetched( |
- int id, |
- int http_status_code, |
- const GURL& url, |
- const std::vector<SkBitmap>& bitmaps, |
- const std::vector<gfx::Size>& sizes) { |
- if (!web_contents() || !weak_observer_) return; |
- |
- // If getting the candidate manifest icon failed, the ShortcutHelper should |
- // fallback to the favicon. |
- // Otherwise, it sets the state as if there was no manifest icon pending. |
- if (bitmaps.empty()) { |
- FetchFavicon(); |
- return; |
- } |
- |
- // There might be multiple bitmaps returned. The one to pick is bigger or |
- // equal to the preferred size. |bitmaps| is ordered from bigger to smaller. |
- int preferred_bitmap_index = 0; |
- for (size_t i = 0; i < bitmaps.size(); ++i) { |
- if (bitmaps[i].height() < preferred_icon_size_in_px_) |
- break; |
- preferred_bitmap_index = i; |
- } |
- |
- NotifyObserver(bitmaps[preferred_bitmap_index]); |
-} |
- |
void ShortcutDataFetcher::NotifyObserver(const SkBitmap& bitmap) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
if (!web_contents() || !weak_observer_ || is_icon_saved_) |