[LargeSplash:2]Make WebAPK install include splash icon image data from hasher

This CL removes badge icon from webapk&shortcut install, including a2hs
and app banner.

For splash icon, we want to fetch it for building the webapk proto, but
don't want to do it together with primary icon, because it'll increase
latency, and we only need the splash icon data after the user has
initiated the install.

For webapks, we are downloading all useful image data when computing
the murmur2 hash, so we can use the the image data from
webapk_icon_hasher, similar to crrev.com/c/2047166 did for the
best shortcut icon.

Bug: 1043271
Change-Id: Ibbe5b80796794b3f1c4b75cd81cdfc32cc61dfff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032723
Reviewed-by: Dominick Ng <[email protected]>
Reviewed-by: Peter Kotwicz <[email protected]>
Commit-Queue: Ella Ge <[email protected]>
Cr-Commit-Position: refs/heads/master@{#744134}
diff --git a/chrome/browser/android/shortcut_helper.cc b/chrome/browser/android/shortcut_helper.cc
index dde3a09..f86c8660 100644
--- a/chrome/browser/android/shortcut_helper.cc
+++ b/chrome/browser/android/shortcut_helper.cc
@@ -155,14 +155,12 @@
 std::unique_ptr<ShortcutInfo> ShortcutHelper::CreateShortcutInfo(
     const GURL& manifest_url,
     const blink::Manifest& manifest,
-    const GURL& primary_icon_url,
-    const GURL& badge_icon_url) {
+    const GURL& primary_icon_url) {
   auto shortcut_info = std::make_unique<ShortcutInfo>(GURL());
   if (!manifest.IsEmpty()) {
     shortcut_info->UpdateFromManifest(manifest);
     shortcut_info->manifest_url = manifest_url;
     shortcut_info->best_primary_icon_url = primary_icon_url;
-    shortcut_info->best_badge_icon_url = badge_icon_url;
   }
 
   shortcut_info->ideal_splash_image_size_in_px = GetIdealSplashImageSizeInPx();
diff --git a/chrome/browser/android/shortcut_helper.h b/chrome/browser/android/shortcut_helper.h
index b8ed8d4a..2e80d74 100644
--- a/chrome/browser/android/shortcut_helper.h
+++ b/chrome/browser/android/shortcut_helper.h
@@ -32,8 +32,7 @@
   static std::unique_ptr<ShortcutInfo> CreateShortcutInfo(
       const GURL& manifest_url,
       const blink::Manifest& manifest,
-      const GURL& primary_icon_url,
-      const GURL& badge_icon_url);
+      const GURL& primary_icon_url);
 
   // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut
   // added depends on the properties in |info|.
diff --git a/chrome/browser/android/webapk/webapk.proto b/chrome/browser/android/webapk/webapk.proto
index 6d385945..0992e4a 100644
--- a/chrome/browser/android/webapk/webapk.proto
+++ b/chrome/browser/android/webapk/webapk.proto
@@ -103,6 +103,7 @@
   enum Usage {
     PRIMARY_ICON = 1;
     BADGE_ICON = 2;
+    SPLASH_ICON = 3;
   }
 
   // Image's URL.
diff --git a/chrome/browser/android/webapk/webapk_install_service.cc b/chrome/browser/android/webapk/webapk_install_service.cc
index 8a54ac57a..89f5ada 100644
--- a/chrome/browser/android/webapk/webapk_install_service.cc
+++ b/chrome/browser/android/webapk/webapk_install_service.cc
@@ -37,7 +37,6 @@
                                         const ShortcutInfo& shortcut_info,
                                         const SkBitmap& primary_icon,
                                         bool is_primary_icon_maskable,
-                                        const SkBitmap& badge_icon,
                                         WebappInstallSource install_source) {
   if (IsInstallInProgress(shortcut_info.manifest_url)) {
     ShortcutHelper::ShowWebApkInstallInProgressToast();
@@ -56,7 +55,6 @@
   auto observer = std::make_unique<LifetimeObserver>(web_contents);
   WebApkInstaller::InstallAsync(
       browser_context_, shortcut_info, primary_icon, is_primary_icon_maskable,
-      badge_icon,
       base::Bind(&WebApkInstallService::OnFinishedInstall,
                  weak_ptr_factory_.GetWeakPtr(), base::Passed(&observer),
                  shortcut_info, primary_icon, is_primary_icon_maskable));
diff --git a/chrome/browser/android/webapk/webapk_install_service.h b/chrome/browser/android/webapk/webapk_install_service.h
index 0120b28..fead0d7 100644
--- a/chrome/browser/android/webapk/webapk_install_service.h
+++ b/chrome/browser/android/webapk/webapk_install_service.h
@@ -71,7 +71,6 @@
                     const ShortcutInfo& shortcut_info,
                     const SkBitmap& primary_icon,
                     bool is_primary_icon_maskable,
-                    const SkBitmap& badge_icon,
                     WebappInstallSource install_source);
 
   // Talks to the Chrome WebAPK server to update a WebAPK on the server and to
diff --git a/chrome/browser/android/webapk/webapk_installer.cc b/chrome/browser/android/webapk/webapk_installer.cc
index da04415..22e0a30 100644
--- a/chrome/browser/android/webapk/webapk_installer.cc
+++ b/chrome/browser/android/webapk/webapk_installer.cc
@@ -181,11 +181,14 @@
 
 // Populates webapk::WebApk and returns it.
 // Must be called on a worker thread because it encodes an SkBitmap.
+// The splash icon can be passed either via |icon_url_to_murmur2_hash| or via
+// |splash_icon| parameter. |splash_icon| parameter is only used when the
+// splash icon URL is unknown.
 std::unique_ptr<std::string> BuildProtoInBackground(
     const ShortcutInfo& shortcut_info,
     const SkBitmap& primary_icon,
     bool is_primary_icon_maskable,
-    const SkBitmap& badge_icon,
+    const SkBitmap& splash_icon,
     const std::string& package_name,
     const std::string& version,
     std::map<std::string, WebApkIconHasher::Icon> icon_url_to_murmur2_hash,
@@ -262,10 +265,11 @@
       best_primary_icon_image->add_purposes(webapk::Image::ANY);
     }
 
-    if (!badge_icon.drawsNothing()) {
-      webapk::Image* best_badge_icon_image = web_app_manifest->add_icons();
-      SetImageData(best_badge_icon_image, badge_icon);
-      best_badge_icon_image->add_usages(webapk::Image::BADGE_ICON);
+    if (!splash_icon.drawsNothing()) {
+      webapk::Image* splash_icon_image = web_app_manifest->add_icons();
+      SetImageData(splash_icon_image, splash_icon);
+      splash_icon_image->add_usages(webapk::Image::SPLASH_ICON);
+      splash_icon_image->add_purposes(webapk::Image::ANY);
     }
   }
 
@@ -285,12 +289,13 @@
         image->add_purposes(webapk::Image::ANY);
       }
     }
-    if (icon_url == shortcut_info.best_badge_icon_url.spec()) {
-      if (shortcut_info.best_badge_icon_url !=
+    if (icon_url == shortcut_info.splash_image_url.spec()) {
+      if (shortcut_info.splash_image_url !=
           shortcut_info.best_primary_icon_url) {
-        SetImageData(image, badge_icon);
+        image->set_image_data(it->second.data);
       }
-      image->add_usages(webapk::Image::BADGE_ICON);
+      image->add_usages(webapk::Image::SPLASH_ICON);
+      image->add_purposes(webapk::Image::ANY);
     }
   }
 
@@ -342,8 +347,10 @@
   base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
                                                 base::BlockingType::MAY_BLOCK);
 
+  // TODO(crbug.com/1043271): Passing an empty SkBitmap for now as webapk update
+  // does not include splash_icon image yet.
   std::unique_ptr<std::string> proto = BuildProtoInBackground(
-      shortcut_info, primary_icon, is_primary_icon_maskable, badge_icon,
+      shortcut_info, primary_icon, is_primary_icon_maskable, SkBitmap(),
       package_name, version, std::move(icon_url_to_murmur2_hash),
       is_manifest_stale, update_reason);
 
@@ -385,12 +392,11 @@
                                    const ShortcutInfo& shortcut_info,
                                    const SkBitmap& primary_icon,
                                    bool is_primary_icon_maskable,
-                                   const SkBitmap& badge_icon,
                                    FinishCallback finish_callback) {
   // The installer will delete itself when it is done.
   WebApkInstaller* installer = new WebApkInstaller(context);
   installer->InstallAsync(shortcut_info, primary_icon, is_primary_icon_maskable,
-                          badge_icon, std::move(finish_callback));
+                          std::move(finish_callback));
 }
 
 // static
@@ -407,10 +413,9 @@
                                              const ShortcutInfo& shortcut_info,
                                              const SkBitmap& primary_icon,
                                              bool is_primary_icon_maskable,
-                                             const SkBitmap& badge_icon,
                                              FinishCallback callback) {
   installer->InstallAsync(shortcut_info, primary_icon, is_primary_icon_maskable,
-                          badge_icon, std::move(callback));
+                          std::move(callback));
 }
 
 // static
@@ -437,7 +442,7 @@
     const ShortcutInfo& shortcut_info,
     const SkBitmap& primary_icon,
     bool is_primary_icon_maskable,
-    const SkBitmap& badge_icon,
+    const SkBitmap& splash_icon,
     const std::string& package_name,
     const std::string& version,
     std::map<std::string, WebApkIconHasher::Icon> icon_url_to_murmur2_hash,
@@ -446,7 +451,7 @@
   base::PostTaskAndReplyWithResult(
       GetBackgroundTaskRunner().get(), FROM_HERE,
       base::BindOnce(&BuildProtoInBackground, shortcut_info, primary_icon,
-                     is_primary_icon_maskable, badge_icon, package_name,
+                     is_primary_icon_maskable, splash_icon, package_name,
                      version, std::move(icon_url_to_murmur2_hash),
                      is_manifest_stale, WebApkUpdateReason::NONE),
       std::move(callback));
@@ -538,13 +543,11 @@
 void WebApkInstaller::InstallAsync(const ShortcutInfo& shortcut_info,
                                    const SkBitmap& primary_icon,
                                    bool is_primary_icon_maskable,
-                                   const SkBitmap& badge_icon,
                                    FinishCallback finish_callback) {
   install_duration_timer_.reset(new base::ElapsedTimer());
 
   install_shortcut_info_.reset(new ShortcutInfo(shortcut_info));
   install_primary_icon_ = primary_icon;
-  install_badge_icon_ = badge_icon;
   is_primary_icon_maskable_ = is_primary_icon_maskable;
   short_name_ = shortcut_info.short_name;
   finish_callback_ = std::move(finish_callback);
@@ -666,10 +669,10 @@
   // should be fast because the icon should be in the HTTP cache.
 
   std::set<GURL> icons{install_shortcut_info_->best_primary_icon_url};
-  if (!install_shortcut_info_->best_badge_icon_url.is_empty() &&
-      install_shortcut_info_->best_badge_icon_url !=
+  if (!install_shortcut_info_->splash_image_url.is_empty() &&
+      install_shortcut_info_->splash_image_url !=
           install_shortcut_info_->best_primary_icon_url) {
-    icons.insert(install_shortcut_info_->best_badge_icon_url);
+    icons.insert(install_shortcut_info_->splash_image_url);
   }
 
   for (const auto& shortcut_icon :
@@ -692,8 +695,10 @@
     return;
   }
 
+  // Using empty |splash_icon| here because in this code path (WebApk install),
+  // we are using the splash icon data from |hashes|.
   BuildProto(*install_shortcut_info_, install_primary_icon_,
-             is_primary_icon_maskable_, install_badge_icon_,
+             is_primary_icon_maskable_, SkBitmap() /* splash_icon */,
              "" /* package_name */, "" /* version */, std::move(*hashes),
              false /* is_manifest_stale */,
              base::BindOnce(&WebApkInstaller::SendRequest,
diff --git a/chrome/browser/android/webapk/webapk_installer.h b/chrome/browser/android/webapk/webapk_installer.h
index 1985baa5..447264b 100644
--- a/chrome/browser/android/webapk/webapk_installer.h
+++ b/chrome/browser/android/webapk/webapk_installer.h
@@ -63,7 +63,6 @@
                            const ShortcutInfo& shortcut_info,
                            const SkBitmap& primary_icon,
                            bool is_primary_icon_maskable,
-                           const SkBitmap& badge_icon,
                            FinishCallback finish_callback);
 
   // Creates a self-owned WebApkInstaller instance and talks to the Chrome
@@ -80,7 +79,6 @@
                                      const ShortcutInfo& shortcut_info,
                                      const SkBitmap& primary_icon,
                                      bool is_primary_icon_maskable,
-                                     const SkBitmap& badge_icon,
                                      FinishCallback callback);
 
   // Calls the private function |UpdateAsync| for testing.
@@ -111,7 +109,7 @@
       const ShortcutInfo& shortcut_info,
       const SkBitmap& primary_icon,
       bool is_primary_icon_maskable,
-      const SkBitmap& badge_icon,
+      const SkBitmap& splash_icon,
       const std::string& package_name,
       const std::string& version,
       std::map<std::string, WebApkIconHasher::Icon> icon_url_to_murmur2_hash,
@@ -126,7 +124,7 @@
       const ShortcutInfo& shortcut_info,
       const SkBitmap& primary_icon,
       bool is_primary_icon_maskable,
-      const SkBitmap& badge_icon,
+      const SkBitmap& splash_icon,
       const std::string& package_name,
       const std::string& version,
       std::map<std::string, WebApkIconHasher::Icon> icon_url_to_murmur2_hash,
@@ -164,7 +162,6 @@
   void InstallAsync(const ShortcutInfo& shortcut_info,
                     const SkBitmap& primary_icon,
                     bool is_primary_icon_maskable,
-                    const SkBitmap& badge_icon,
                     FinishCallback finish_callback);
 
   // Talks to the Chrome WebAPK server to update a WebAPK on the server and to
@@ -212,7 +209,6 @@
   // Data for installs.
   std::unique_ptr<ShortcutInfo> install_shortcut_info_;
   SkBitmap install_primary_icon_;
-  SkBitmap install_badge_icon_;
 
   bool is_primary_icon_maskable_;
 
diff --git a/chrome/browser/android/webapk/webapk_installer_unittest.cc b/chrome/browser/android/webapk/webapk_installer_unittest.cc
index 9f451a8..c4cf1bdf 100644
--- a/chrome/browser/android/webapk/webapk_installer_unittest.cc
+++ b/chrome/browser/android/webapk/webapk_installer_unittest.cc
@@ -48,7 +48,7 @@
 // data directory. Since WebApkInstaller does not try to decode the file as an
 // image it is OK that the file is not an image.
 const char* kBestPrimaryIconUrl = "/simple.html";
-const char* kBestBadgeIconUrl = "/nostore.html";
+const char* kBestSplashIconUrl = "/nostore.html";
 const char* kBestShortcutIconUrl = "/title1.html";
 
 // Icon which has Cross-Origin-Resource-Policy: same-origin set.
@@ -116,7 +116,7 @@
 
     // WebApkInstaller owns itself.
     WebApkInstaller::InstallAsyncForTesting(
-        installer.release(), info, SkBitmap(), false, SkBitmap(),
+        installer.release(), info, SkBitmap(), false,
         base::BindOnce(&WebApkInstallerRunner::OnCompleted,
                        base::Unretained(this)));
 
@@ -208,14 +208,14 @@
 
   void BuildSync(
       const GURL& best_primary_icon_url,
-      const GURL& best_badge_icon_url,
+      const GURL& splash_image_url,
       std::map<std::string, WebApkIconHasher::Icon> icon_url_to_murmur2_hash,
       bool is_manifest_stale,
       const std::vector<GURL>& best_shortcut_icon_urls) {
     ShortcutInfo info(GURL::EmptyGURL());
     info.best_primary_icon_url = best_primary_icon_url;
-    info.best_badge_icon_url = best_badge_icon_url;
-    info.icon_urls = {best_primary_icon_url.spec(), best_badge_icon_url.spec(),
+    info.splash_image_url = splash_image_url;
+    info.icon_urls = {best_primary_icon_url.spec(), splash_image_url.spec(),
                       kUnusedIconPath};
 
     for (const GURL& shortcut_url : best_shortcut_icon_urls) {
@@ -226,9 +226,9 @@
     }
 
     SkBitmap primary_icon(gfx::test::CreateBitmap(144, 144));
-    SkBitmap badge_icon(gfx::test::CreateBitmap(72, 72));
+    SkBitmap splash_icon(gfx::test::CreateBitmap(72, 72));
     WebApkInstaller::BuildProto(
-        info, primary_icon, false /* is_primary_icon_maskable */, badge_icon,
+        info, primary_icon, false /* is_primary_icon_maskable */, splash_icon,
         "" /* package_name */, "" /* version */,
         std::move(icon_url_to_murmur2_hash), is_manifest_stale,
         base::BindOnce(&BuildProtoRunner::OnBuiltWebApkProto,
@@ -311,7 +311,7 @@
   ShortcutInfo DefaultShortcutInfo() {
     ShortcutInfo info(test_server_.GetURL(kStartUrl));
     info.best_primary_icon_url = test_server_.GetURL(kBestPrimaryIconUrl);
-    info.best_badge_icon_url = test_server_.GetURL(kBestBadgeIconUrl);
+    info.splash_image_url = test_server_.GetURL(kBestSplashIconUrl);
     info.best_shortcut_icon_urls.push_back(
         test_server_.GetURL(kBestShortcutIconUrl));
     return info;
@@ -404,12 +404,12 @@
   EXPECT_EQ(WebApkInstallResult::FAILURE, runner.result());
 }
 
-// Test that installation fails if fetching the bitmap at the best badge icon
+// Test that installation fails if fetching the bitmap at the best splash icon
 // URL returns no content. In a perfect world the fetch would always succeed
 // because the fetch for the same icon succeeded recently.
-TEST_F(WebApkInstallerTest, BestBadgeIconUrlDownloadTimesOut) {
+TEST_F(WebApkInstallerTest, BestSplashIconUrlDownloadTimesOut) {
   ShortcutInfo shortcut_info = DefaultShortcutInfo();
-  shortcut_info.best_badge_icon_url = test_server()->GetURL("/nocontent");
+  shortcut_info.splash_image_url = test_server()->GetURL("/nocontent");
 
   WebApkInstallerRunner runner;
   runner.RunInstallWebApk(CreateDefaultWebApkInstaller(), shortcut_info);
@@ -526,7 +526,7 @@
 }
 
 // When there is no Web Manifest available for a site, an empty
-// |best_primary_icon_url| and an empty |best_badge_icon_url| is used to build a
+// |best_primary_icon_url| and an empty |splash_image_url| is used to build a
 // WebApk update request. Tests the request can be built properly.
 TEST_F(WebApkInstallerTest, BuildWebApkProtoWhenManifestIsObsolete) {
   std::string icon_url_1 = test_server()->GetURL("/icon1.png").spec();
@@ -571,18 +571,18 @@
   std::string icon_url_1 = test_server()->GetURL("/icon.png").spec();
   std::string best_primary_icon_url =
       test_server()->GetURL(kBestPrimaryIconUrl).spec();
-  std::string best_badge_icon_url =
-      test_server()->GetURL(kBestBadgeIconUrl).spec();
+  std::string best_splash_icon_url =
+      test_server()->GetURL(kBestSplashIconUrl).spec();
   std::string best_shortcut_icon_url =
       test_server()->GetURL(kBestShortcutIconUrl).spec();
   std::map<std::string, WebApkIconHasher::Icon> icon_url_to_murmur2_hash;
   icon_url_to_murmur2_hash[icon_url_1] = {"data0", "0"};
   icon_url_to_murmur2_hash[best_primary_icon_url] = {"data1", "1"};
-  icon_url_to_murmur2_hash[best_badge_icon_url] = {"data2", "2"};
+  icon_url_to_murmur2_hash[best_splash_icon_url] = {"data2", "2"};
   icon_url_to_murmur2_hash[best_shortcut_icon_url] = {"data3", "3"};
 
   std::unique_ptr<BuildProtoRunner> runner = CreateBuildProtoRunner();
-  runner->BuildSync(GURL(best_primary_icon_url), GURL(best_badge_icon_url),
+  runner->BuildSync(GURL(best_primary_icon_url), GURL(best_splash_icon_url),
                     icon_url_to_murmur2_hash, false /* is_manifest_stale*/,
                     {GURL(best_shortcut_icon_url)});
   webapk::WebApk* webapk_request = runner->GetWebApkRequest();
@@ -599,13 +599,14 @@
               testing::ElementsAre(webapk::Image::PRIMARY_ICON));
   EXPECT_TRUE(manifest.icons(0).has_image_data());
 
-  // Check protobuf fields for kBestBadgeIconUrl.
-  EXPECT_EQ(best_badge_icon_url, manifest.icons(1).src());
-  EXPECT_EQ(icon_url_to_murmur2_hash[best_badge_icon_url].hash,
+  // Check protobuf fields for kBestSplashIconUrl.
+  EXPECT_EQ(best_splash_icon_url, manifest.icons(1).src());
+  EXPECT_EQ(icon_url_to_murmur2_hash[best_splash_icon_url].hash,
             manifest.icons(1).hash());
   EXPECT_THAT(manifest.icons(1).usages(),
-              testing::ElementsAre(webapk::Image::BADGE_ICON));
-  EXPECT_TRUE(manifest.icons(1).has_image_data());
+              testing::ElementsAre(webapk::Image::SPLASH_ICON));
+  EXPECT_EQ(icon_url_to_murmur2_hash[best_splash_icon_url].data,
+            manifest.icons(1).image_data());
 
   // Check protobuf fields for unused icon.
   EXPECT_EQ(kUnusedIconPath, manifest.icons(2).src());
@@ -624,8 +625,8 @@
 
 // Tests a WebApk install or update request is built properly when the Chrome
 // knows the best icon URL of a site after fetching its Web Manifest, and
-// primary icon and badge icon share the same URL.
-TEST_F(WebApkInstallerTest, BuildWebApkProtoPrimaryIconAndBadgeIconSameUrl) {
+// primary icon and splash icon share the same URL.
+TEST_F(WebApkInstallerTest, BuildWebApkProtoPrimaryIconAndSplashIconSameUrl) {
   std::string icon_url_1 = test_server()->GetURL("/icon.png").spec();
   std::string best_icon_url = test_server()->GetURL(kBestPrimaryIconUrl).spec();
   std::map<std::string, WebApkIconHasher::Icon> icon_url_to_murmur2_hash;
@@ -648,7 +649,7 @@
             manifest.icons(0).hash());
   EXPECT_THAT(manifest.icons(0).usages(),
               testing::ElementsAre(webapk::Image::PRIMARY_ICON,
-                                   webapk::Image::BADGE_ICON));
+                                   webapk::Image::SPLASH_ICON));
   EXPECT_TRUE(manifest.icons(0).has_image_data());
 
   EXPECT_EQ(best_icon_url, manifest.icons(1).src());
@@ -656,7 +657,7 @@
             manifest.icons(1).hash());
   EXPECT_THAT(manifest.icons(1).usages(),
               testing::ElementsAre(webapk::Image::PRIMARY_ICON,
-                                   webapk::Image::BADGE_ICON));
+                                   webapk::Image::SPLASH_ICON));
   EXPECT_TRUE(manifest.icons(1).has_image_data());
 
   // Check protobuf fields for unused icon.
@@ -741,3 +742,55 @@
   // This is a duplicate icon, so the data won't be included again.
   EXPECT_EQ(manifest.shortcuts(1).icons(0).image_data(), "");
 }
+
+TEST_F(WebApkInstallerTest, BuildWebApkProtoSplashIconAndShortcutIconSameUrl) {
+  std::string icon_url_1 = test_server()->GetURL("/icon.png").spec();
+  std::string best_icon_url = test_server()->GetURL(kBestPrimaryIconUrl).spec();
+  std::map<std::string, WebApkIconHasher::Icon> icon_url_to_murmur2_hash;
+  icon_url_to_murmur2_hash[icon_url_1] = {"data1", "1"};
+  icon_url_to_murmur2_hash[best_icon_url] = {"data0", "0"};
+
+  std::unique_ptr<BuildProtoRunner> runner = CreateBuildProtoRunner();
+  runner->BuildSync(GURL(icon_url_1), GURL(best_icon_url),
+                    icon_url_to_murmur2_hash, false /* is_manifest_stale*/,
+                    {GURL(best_icon_url)});
+  webapk::WebApk* webapk_request = runner->GetWebApkRequest();
+  ASSERT_NE(nullptr, webapk_request);
+
+  webapk::WebAppManifest manifest = webapk_request->manifest();
+  ASSERT_EQ(3, manifest.icons_size());
+  ASSERT_EQ(manifest.shortcuts_size(), 1);
+
+  // Check primary icon fields.
+  EXPECT_EQ(icon_url_1, manifest.icons(0).src());
+  EXPECT_EQ(icon_url_to_murmur2_hash[icon_url_1].hash,
+            manifest.icons(0).hash());
+  EXPECT_THAT(manifest.icons(0).usages(),
+              testing::ElementsAre(webapk::Image::PRIMARY_ICON));
+  EXPECT_TRUE(manifest.icons(0).has_image_data());
+
+  // Check splash icon fields
+  EXPECT_EQ(best_icon_url, manifest.icons(1).src());
+  EXPECT_EQ(icon_url_to_murmur2_hash[best_icon_url].hash,
+            manifest.icons(1).hash());
+  EXPECT_THAT(manifest.icons(1).usages(),
+              testing::ElementsAre(webapk::Image::SPLASH_ICON));
+  EXPECT_TRUE(manifest.icons(1).has_image_data());
+  EXPECT_EQ(manifest.icons(1).image_data(),
+            icon_url_to_murmur2_hash[best_icon_url].data);
+
+  // Check protobuf fields for unused icon.
+  EXPECT_EQ(kUnusedIconPath, manifest.icons(2).src());
+  EXPECT_FALSE(manifest.icons(2).has_hash());
+  EXPECT_FALSE(manifest.icons(2).has_image_data());
+
+  // Check shortcut fields.
+  ASSERT_EQ(manifest.shortcuts_size(), 1);
+  ASSERT_EQ(manifest.shortcuts(0).icons_size(), 1);
+  EXPECT_EQ(manifest.shortcuts(0).icons(0).src(), best_icon_url);
+  EXPECT_EQ(manifest.shortcuts(0).icons(0).hash(),
+            icon_url_to_murmur2_hash[best_icon_url].hash);
+  EXPECT_TRUE(manifest.shortcuts(0).icons(0).has_image_data());
+  EXPECT_EQ(manifest.shortcuts(0).icons(0).image_data(),
+            icon_url_to_murmur2_hash[best_icon_url].data);
+}
diff --git a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
index 619b8e6..28261d5 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
+++ b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
@@ -53,7 +53,6 @@
   params.valid_primary_icon = true;
   params.prefer_maskable_icon =
       ShortcutHelper::DoesAndroidSupportMaskableIcons();
-  params.valid_badge_icon = true;
   params.wait_for_worker = true;
   return params;
 }
@@ -254,10 +253,6 @@
           data.manifest->icons, shortcut_info_.ideal_splash_image_size_in_px,
           shortcut_info_.minimum_splash_image_size_in_px,
           blink::Manifest::ImageResource::Purpose::ANY);
-  if (data.badge_icon) {
-    shortcut_info_.best_badge_icon_url = data.badge_icon_url;
-    badge_icon_ = *data.badge_icon;
-  }
 
   installable_manager_->GetData(
       ParamsToPerformInstallableCheck(),
@@ -378,5 +373,6 @@
     primary_icon_ = icon_for_view;
   if (is_icon_generated)
     shortcut_info_.best_primary_icon_url = GURL();
-  observer_->OnDataAvailable(shortcut_info_, icon_for_view, badge_icon_);
+
+  observer_->OnDataAvailable(shortcut_info_, icon_for_view);
 }
diff --git a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h
index 291f3d2..4af2cae6 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h
+++ b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h
@@ -39,8 +39,7 @@
     // Called when all the data needed to prompt the user to add to home screen
     // is available.
     virtual void OnDataAvailable(const ShortcutInfo& info,
-                                 const SkBitmap& primary_icon,
-                                 const SkBitmap& badge_icon) = 0;
+                                 const SkBitmap& primary_icon) = 0;
 
    protected:
     virtual ~Observer() {}
@@ -63,7 +62,6 @@
       const WebApplicationInfo& web_app_info);
 
   // Accessors, etc.
-  const SkBitmap& badge_icon() const { return badge_icon_; }
   const SkBitmap& primary_icon() const { return primary_icon_; }
   ShortcutInfo& shortcut_info() { return shortcut_info_; }
   bool has_maskable_primary_icon() const { return has_maskable_primary_icon_; }
@@ -101,7 +99,6 @@
 
   // The icons must only be set on the UI thread for thread safety.
   SkBitmap raw_primary_icon_;
-  SkBitmap badge_icon_;
   SkBitmap primary_icon_;
   ShortcutInfo shortcut_info_;
   bool has_maskable_primary_icon_;
diff --git a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc
index 43969ce..55cc520 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc
+++ b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc
@@ -74,8 +74,7 @@
   }
 
   void OnDataAvailable(const ShortcutInfo& info,
-                       const SkBitmap& primary_icon,
-                       const SkBitmap& badge_icon) override {
+                       const SkBitmap& primary_icon) override {
     // This should only be called once.
     EXPECT_FALSE(data_available_);
     EXPECT_TRUE(title_available_);
@@ -162,9 +161,8 @@
         {std::move(errors), GURL(kDefaultManifestUrl), &manifest_,
          params.valid_primary_icon ? primary_icon_url_ : GURL(),
          params.valid_primary_icon ? primary_icon_.get() : nullptr,
-         params.prefer_maskable_icon,
-         params.valid_badge_icon ? badge_icon_url_ : GURL(),
-         params.valid_badge_icon ? badge_icon_.get() : nullptr,
+         params.prefer_maskable_icon, GURL() /* splash_icon_url */,
+         nullptr /* splash_icon */,
          params.valid_manifest ? is_installable : false,
          params.has_worker ? is_installable : false});
   }
@@ -178,10 +176,6 @@
       primary_icon_url_ = manifest_.icons[0].src;
       primary_icon_.reset(
           new SkBitmap(gfx::test::CreateBitmap(kIconSizePx, kIconSizePx)));
-
-      badge_icon_url_ = manifest_.icons[0].src;
-      badge_icon_.reset(
-          new SkBitmap(gfx::test::CreateBitmap(kIconSizePx, kIconSizePx)));
     }
   }
 
@@ -196,9 +190,7 @@
  private:
   blink::Manifest manifest_;
   GURL primary_icon_url_;
-  GURL badge_icon_url_;
   std::unique_ptr<SkBitmap> primary_icon_;
-  std::unique_ptr<SkBitmap> badge_icon_;
 
   bool is_installable_ = true;
 
@@ -324,8 +316,7 @@
   CheckHistograms(histograms);
 
   EXPECT_TRUE(fetcher->shortcut_info().best_primary_icon_url.is_empty());
-  EXPECT_TRUE(fetcher->badge_icon().drawsNothing());
-  EXPECT_TRUE(fetcher->shortcut_info().best_badge_icon_url.is_empty());
+  EXPECT_TRUE(fetcher->shortcut_info().splash_image_url.is_empty());
 }
 
 // Check that the AddToHomescreenDataFetcher::Observer methods are called
@@ -467,9 +458,8 @@
   EXPECT_EQ(fetcher->shortcut_info().best_primary_icon_url,
             GURL(kDefaultIconUrl));
 
-  // No badge icon as InstallableManager does not fetch badge icon.
-  EXPECT_TRUE(fetcher->badge_icon().drawsNothing());
-  EXPECT_TRUE(fetcher->shortcut_info().best_badge_icon_url.is_empty());
+  // Check that splash icon url has been selected.
+  EXPECT_EQ(fetcher->shortcut_info().splash_image_url, GURL(kDefaultIconUrl));
   CheckHistograms(histograms);
 }
 
diff --git a/chrome/browser/android/webapps/add_to_homescreen_installer.cc b/chrome/browser/android/webapps/add_to_homescreen_installer.cc
index b4b8831..6d547f1 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_installer.cc
+++ b/chrome/browser/android/webapps/add_to_homescreen_installer.cc
@@ -66,8 +66,7 @@
     const AddToHomescreenParams& params) {
   WebApkInstallService::Get(web_contents->GetBrowserContext())
       ->InstallAsync(web_contents, *(params.shortcut_info), params.primary_icon,
-                     params.has_maskable_primary_icon, params.badge_icon,
-                     params.install_source);
+                     params.has_maskable_primary_icon, params.install_source);
 }
 
 // static
diff --git a/chrome/browser/android/webapps/add_to_homescreen_mediator.cc b/chrome/browser/android/webapps/add_to_homescreen_mediator.cc
index 4674b575..56228b4 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_mediator.cc
+++ b/chrome/browser/android/webapps/add_to_homescreen_mediator.cc
@@ -154,15 +154,13 @@
 }
 
 void AddToHomescreenMediator::OnDataAvailable(const ShortcutInfo& info,
-                                              const SkBitmap& display_icon,
-                                              const SkBitmap& badge_icon) {
+                                              const SkBitmap& display_icon) {
   params_ = std::make_unique<AddToHomescreenParams>();
   params_->app_type = info.source == ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA
                           ? AddToHomescreenParams::AppType::WEBAPK
                           : AddToHomescreenParams::AppType::SHORTCUT;
   params_->shortcut_info = std::make_unique<ShortcutInfo>(info);
   params_->primary_icon = data_fetcher_->primary_icon();
-  params_->badge_icon = badge_icon;
   params_->has_maskable_primary_icon =
       data_fetcher_->has_maskable_primary_icon();
   params_->install_source = InstallableMetrics::GetInstallSource(
diff --git a/chrome/browser/android/webapps/add_to_homescreen_mediator.h b/chrome/browser/android/webapps/add_to_homescreen_mediator.h
index f4a672be3..49a8357 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_mediator.h
+++ b/chrome/browser/android/webapps/add_to_homescreen_mediator.h
@@ -76,8 +76,7 @@
                             bool is_webapk_compatible) override;
 
   void OnDataAvailable(const ShortcutInfo& info,
-                       const SkBitmap& display_icon,
-                       const SkBitmap& badge_icon) override;
+                       const SkBitmap& display_icon) override;
 
   void RecordEventForAppMenu(AddToHomescreenInstaller::Event event,
                              const AddToHomescreenParams& a2hs_params);
diff --git a/chrome/browser/android/webapps/add_to_homescreen_params.h b/chrome/browser/android/webapps/add_to_homescreen_params.h
index 86a4525e..fe379856 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_params.h
+++ b/chrome/browser/android/webapps/add_to_homescreen_params.h
@@ -25,7 +25,6 @@
 
   AppType app_type;
   SkBitmap primary_icon;
-  SkBitmap badge_icon;
   bool has_maskable_primary_icon = false;
   std::unique_ptr<ShortcutInfo> shortcut_info;
   WebappInstallSource install_source;
diff --git a/chrome/browser/banners/app_banner_manager_android.cc b/chrome/browser/banners/app_banner_manager_android.cc
index c7df9395..3cc8415 100644
--- a/chrome/browser/banners/app_banner_manager_android.cc
+++ b/chrome/browser/banners/app_banner_manager_android.cc
@@ -165,7 +165,6 @@
 AppBannerManagerAndroid::ParamsToPerformInstallableWebAppCheck() {
   InstallableParams params =
       AppBannerManager::ParamsToPerformInstallableWebAppCheck();
-  params.valid_badge_icon = true;
   params.prefer_maskable_icon =
       ShortcutHelper::DoesAndroidSupportMaskableIcons();
 
@@ -187,18 +186,6 @@
   AppBannerManager::PerformInstallableWebAppCheck();
 }
 
-void AppBannerManagerAndroid::OnDidPerformInstallableWebAppCheck(
-    const InstallableData& data) {
-  if (data.badge_icon && !data.badge_icon->drawsNothing()) {
-    DCHECK(!data.badge_icon_url.is_empty());
-
-    badge_icon_url_ = data.badge_icon_url;
-    badge_icon_ = *data.badge_icon;
-  }
-
-  AppBannerManager::OnDidPerformInstallableWebAppCheck(data);
-}
-
 void AppBannerManagerAndroid::ResetCurrentPageData() {
   AppBannerManager::ResetCurrentPageData();
   native_app_data_.Reset();
@@ -214,9 +201,8 @@
   if (native_app_data_.is_null()) {
     a2hs_params->app_type = AddToHomescreenParams::AppType::WEBAPK;
     a2hs_params->shortcut_info = ShortcutHelper::CreateShortcutInfo(
-        manifest_url_, manifest_, primary_icon_url_, badge_icon_url_);
+        manifest_url_, manifest_, primary_icon_url_);
     a2hs_params->install_source = install_source;
-    a2hs_params->badge_icon = badge_icon_;
     a2hs_params->has_maskable_primary_icon = has_maskable_primary_icon_;
   } else {
     a2hs_params->app_type = AddToHomescreenParams::AppType::NATIVE;
diff --git a/chrome/browser/banners/app_banner_manager_android.h b/chrome/browser/banners/app_banner_manager_android.h
index b11c3b7..3782f6b 100644
--- a/chrome/browser/banners/app_banner_manager_android.h
+++ b/chrome/browser/banners/app_banner_manager_android.h
@@ -84,8 +84,6 @@
   void PerformInstallableChecks() override;
   InstallableParams ParamsToPerformInstallableWebAppCheck() override;
   void PerformInstallableWebAppCheck() override;
-  void OnDidPerformInstallableWebAppCheck(
-      const InstallableData& result) override;
   void ResetCurrentPageData() override;
   void ShowBannerUi(WebappInstallSource install_source) override;
   void MaybeShowAmbientBadge() override;
@@ -133,12 +131,6 @@
   void RecordEventForAppBanner(AddToHomescreenInstaller::Event event,
                                const AddToHomescreenParams& a2hs_params);
 
-  // The URL of the badge icon.
-  GURL badge_icon_url_;
-
-  // The badge icon object.
-  SkBitmap badge_icon_;
-
   // The Java-side AppBannerManager.
   base::android::ScopedJavaGlobalRef<jobject> java_banner_manager_;