Index: chrome/browser/android/banners/app_banner_data_fetcher_android.cc |
diff --git a/chrome/browser/android/banners/app_banner_data_fetcher_android.cc b/chrome/browser/android/banners/app_banner_data_fetcher_android.cc |
index 024b456678bcbab1d3a3bd7c6a0208a5491127b1..cc1965211fbde68305298b669efbf21206105ae6 100644 |
--- a/chrome/browser/android/banners/app_banner_data_fetcher_android.cc |
+++ b/chrome/browser/android/banners/app_banner_data_fetcher_android.cc |
@@ -4,19 +4,27 @@ |
#include "chrome/browser/android/banners/app_banner_data_fetcher_android.h" |
+#include "base/bind.h" |
#include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" |
+#include "chrome/browser/android/shortcut_helper.h" |
+#include "chrome/browser/banners/app_banner_debug_log.h" |
#include "chrome/browser/banners/app_banner_metrics.h" |
#include "chrome/browser/infobars/infobar_service.h" |
+#include "chrome/browser/manifest/manifest_icon_downloader.h" |
+#include "chrome/browser/manifest/manifest_icon_selector.h" |
#include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
+#include "ui/gfx/screen.h" |
namespace banners { |
AppBannerDataFetcherAndroid::AppBannerDataFetcherAndroid( |
content::WebContents* web_contents, |
base::WeakPtr<Delegate> weak_delegate, |
+ int ideal_splash_icon_size, |
int ideal_icon_size) |
- : AppBannerDataFetcher(web_contents, weak_delegate, ideal_icon_size) { |
+ : AppBannerDataFetcher(web_contents, weak_delegate, ideal_icon_size), |
+ ideal_splash_icon_size_(ideal_splash_icon_size) { |
} |
AppBannerDataFetcherAndroid::~AppBannerDataFetcherAndroid() { |
@@ -43,6 +51,28 @@ std::string AppBannerDataFetcherAndroid::GetAppIdentifier() { |
? AppBannerDataFetcher::GetAppIdentifier() : native_app_package_; |
} |
+void AppBannerDataFetcherAndroid::FetchWebappSplashscreenIcon( |
+ const std::string& webapp_id) { |
+ content::WebContents* web_contents = GetWebContents(); |
+ DCHECK(web_contents); |
+ |
+ GURL icon_url = |
+ ManifestIconSelector::FindBestMatchingIcon( |
+ web_app_data().icons, |
+ ideal_splash_icon_size_, |
+ gfx::Screen::GetScreenFor(web_contents->GetNativeView())); |
+ |
+ // This is a fire and forget task. It is not vital for the splashscreen icon |
+ // to be downloaded so the result of the download is not checked and neither |
+ // is there any fallback option. |
gone
2015/08/26 02:01:19
You explicitly check if the icon was downloaded in
Lalit Maganti
2015/08/26 13:11:56
Moved to shortcuthelper and clarified there.
|
+ ManifestIconDownloader::Download( |
+ web_contents, |
+ icon_url, |
+ ideal_splash_icon_size_, |
+ base::Bind(&ShortcutHelper::AddSplashscreenIconToWebappData, |
+ webapp_id)); |
+} |
+ |
void AppBannerDataFetcherAndroid::ShowBanner(const SkBitmap* icon, |
const base::string16& title, |
const std::string& referrer) { |
@@ -53,7 +83,8 @@ void AppBannerDataFetcherAndroid::ShowBanner(const SkBitmap* icon, |
if (native_app_data_.is_null()) { |
scoped_ptr<AppBannerInfoBarDelegateAndroid> delegate( |
new AppBannerInfoBarDelegateAndroid( |
- event_request_id(), title, new SkBitmap(*icon), web_app_data())); |
+ event_request_id(), this, title, new SkBitmap(*icon), |
+ web_app_data())); |
infobar = |
new AppBannerInfoBarAndroid(delegate.Pass(), web_app_data().start_url); |