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

Unified Diff: chrome/browser/android/webapk/webapk_installer.cc

Issue 2453423002: Send all of the icon URLs listed in Web Manifest to WebAPK Server. (Closed)
Patch Set: Nits. Created 4 years, 1 month 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/webapk/webapk_installer.cc
diff --git a/chrome/browser/android/webapk/webapk_installer.cc b/chrome/browser/android/webapk/webapk_installer.cc
index 4bb94ba61ca12602c6d366c8835ed3e59f1b6f7a..bb9e030916de819706c9df62fcac2f8e18429aad 100644
--- a/chrome/browser/android/webapk/webapk_installer.cc
+++ b/chrome/browser/android/webapk/webapk_installer.cc
@@ -122,6 +122,11 @@ std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground(
webapk->set_requester_application_version(version_info::GetVersionNumber());
webapk->set_android_abi(getCurrentAbi());
+ // TODO(hanxi): crbug.com/665078. Add a flag in WebAPK's proto to indicate
+ // that the Web Manifest data in the proto might be stale.
+ if (shortcut_icon_murmur2_hash.empty())
+ return webapk;
+
webapk::WebAppManifest* web_app_manifest = webapk->mutable_manifest();
web_app_manifest->set_name(base::UTF16ToUTF8(shortcut_info.name));
web_app_manifest->set_short_name(
@@ -138,12 +143,20 @@ std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground(
std::string* scope = web_app_manifest->add_scopes();
scope->assign(GetScope(shortcut_info).spec());
- webapk::Image* image = web_app_manifest->add_icons();
- image->set_src(shortcut_info.icon_url.spec());
- image->set_hash(shortcut_icon_murmur2_hash);
+
+ webapk::Image* best_image = web_app_manifest->add_icons();
+ best_image->set_src(shortcut_info.best_icon_url.spec());
+ best_image->set_hash(shortcut_icon_murmur2_hash);
std::vector<unsigned char> png_bytes;
gfx::PNGCodec::EncodeBGRASkBitmap(shortcut_icon, false, &png_bytes);
- image->set_image_data(&png_bytes.front(), png_bytes.size());
+ best_image->set_image_data(&png_bytes.front(), png_bytes.size());
+
+ for (const std::string& icon_url : shortcut_info.icon_urls) {
+ if (icon_url == shortcut_info.best_icon_url.spec())
+ continue;
+ webapk::Image* image = web_app_manifest->add_icons();
+ image->set_src(icon_url);
+ }
return webapk;
}
@@ -333,7 +346,7 @@ void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) {
void WebApkInstaller::DownloadAppIconAndComputeMurmur2Hash() {
// Safeguard. WebApkIconHasher crashes if asked to fetch an invalid URL.
- if (!shortcut_info_.icon_url.is_valid()) {
+ if (!shortcut_info_.best_icon_url.is_valid()) {
OnFailure();
return;
}
@@ -344,7 +357,7 @@ void WebApkInstaller::DownloadAppIconAndComputeMurmur2Hash() {
icon_hasher_.reset(new WebApkIconHasher());
icon_hasher_->DownloadAndComputeMurmur2Hash(
- request_context_getter_, shortcut_info_.icon_url,
+ request_context_getter_, shortcut_info_.best_icon_url,
base::Bind(&WebApkInstaller::OnGotIconMurmur2Hash,
weak_ptr_factory_.GetWeakPtr()));
}

Powered by Google App Engine
This is Rietveld 408576698