| 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 92b58fbc235ea60a0ae96e36109b9956d5615a4b..de0082e37b7eba6a005fb9cdfd257b0856aa28a6 100644
|
| --- a/chrome/browser/android/webapk/webapk_installer.cc
|
| +++ b/chrome/browser/android/webapk/webapk_installer.cc
|
| @@ -100,6 +100,11 @@ std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground(
|
| base::android::BuildInfo::GetInstance()->package_name());
|
| webapk->set_requester_application_version(version_info::GetVersionNumber());
|
|
|
| + // 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(
|
| @@ -116,12 +121,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 GURL& icon_url : shortcut_info.icon_urls) {
|
| + if (icon_url == shortcut_info.best_icon_url)
|
| + continue;
|
| + webapk::Image* image = web_app_manifest->add_icons();
|
| + image->set_src(icon_url.spec());
|
| + }
|
|
|
| return webapk;
|
| }
|
| @@ -311,7 +324,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;
|
| }
|
| @@ -322,7 +335,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()));
|
| }
|
|
|