Move download shelf from per-tab to per-window.  Also disable auto-hiding of
the shelf.

BUG=9025
TEST=Download file in one tab, open new tab, and check that download shelf is
still open. Also try the shelf's close button and the "show all downloads"
link. When saving a file, the download animation should not show up.

Review URL: http://codereview.chromium.org/115740


git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17595 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 92c8ab67..fe99bdd 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -18,7 +18,10 @@
 #include "chrome/browser/character_encoding.h"
 #include "chrome/browser/debugger/debugger_host.h"
 #include "chrome/browser/debugger/devtools_manager.h"
+#include "chrome/browser/download/download_item_model.h"
 #include "chrome/browser/download/download_manager.h"
+#include "chrome/browser/download/download_shelf.h"
+#include "chrome/browser/download/download_started_animation.h"
 #include "chrome/browser/find_bar.h"
 #include "chrome/browser/find_bar_controller.h"
 #include "chrome/browser/location_bar.h"
@@ -42,6 +45,7 @@
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/notification_service.h"
 #include "chrome/common/page_transition_types.h"
+#include "chrome/common/platform_util.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/pref_service.h"
 #include "chrome/common/url_constants.h"
@@ -1153,6 +1157,25 @@
                 false, NULL);
 }
 
+void Browser::OnStartDownload(DownloadItem* download) {
+  if (!window())
+    return;
+
+  // GetDownloadShelf creates the download shelf if it was not yet created.
+  window()->GetDownloadShelf()->AddDownload(new DownloadItemModel(download));
+
+// TODO(port): port for mac.
+#if defined(OS_WIN) || defined(OS_LINUX)
+  // Don't show the animation for "Save file" downloads.
+  if (download->total_bytes() > 0) {
+    TabContents* current_tab = GetSelectedTabContents();
+    // We make this check for the case of minimized windows, unit tests, etc.
+    if (platform_util::IsVisible(current_tab->GetNativeView()))
+      DownloadStartedAnimation::Show(current_tab);
+  }
+#endif
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 
 // static