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

Unified Diff: chrome/browser/android/banners/app_banner_data_fetcher_android.cc

Issue 1310223002: webapps: initial addition of splash screen icon downloading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webapps-database-exp
Patch Set: Fix review comments and update code as discussed Created 5 years, 4 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/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);

Powered by Google App Engine
This is Rietveld 408576698