Fix issue in which stale downloads were added to holding space.

Previously downloads were being observed prior to download manager
initialization. When the download manager updated, these downloads
were then being added to holding space despite being stale.

(cherry picked from commit bf65024f1630c29ee292da4ae632f52f91f52018)

Bug: 1137035
Change-Id: Icc53367f5d0d00248da2e29a2ee53a562687b22d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2464262
Reviewed-by: Ahmed Mehfooz <[email protected]>
Commit-Queue: David Black <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#815918}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2466198
Reviewed-by: David Black <[email protected]>
Cr-Commit-Position: refs/branch-heads/4280@{#243}
Cr-Branched-From: ea420fb963f9658c9969b6513c56b8f47efa1a2a-refs/heads/master@{#812852}
diff --git a/chrome/browser/ui/ash/holding_space/holding_space_downloads_delegate.cc b/chrome/browser/ui/ash/holding_space/holding_space_downloads_delegate.cc
index 990683b..85cc3269 100644
--- a/chrome/browser/ui/ash/holding_space/holding_space_downloads_delegate.cc
+++ b/chrome/browser/ui/ash/holding_space/holding_space_downloads_delegate.cc
@@ -134,7 +134,10 @@
 void HoldingSpaceDownloadsDelegate::OnDownloadCreated(
     content::DownloadManager* manager,
     download::DownloadItem* item) {
-  download_item_observer_.Add(item);
+  // Ignore `OnDownloadCreated()` events prior to `manager` initialization. For
+  // those events we bind any observers necessary in `OnManagerInitialized()`.
+  if (!is_restoring_persistence() && manager->IsManagerInitialized())
+    download_item_observer_.Add(item);
 }
 
 void HoldingSpaceDownloadsDelegate::OnDownloadUpdated(