Index: chrome/browser/ui/browser.cc |
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
index d560e487d2963faa6255d2b62e4fbfb97bbeff31..9d779273048e3fb6ab6db8f2b9609ef930bd6c98 100644 |
--- a/chrome/browser/ui/browser.cc |
+++ b/chrome/browser/ui/browser.cc |
@@ -3299,51 +3299,6 @@ int Browser::GetExtraRenderViewHeight() const { |
return window_->GetExtraRenderViewHeight(); |
} |
-void Browser::OnStartDownload(DownloadItem* download, TabContents* tab) { |
- if (!window()) |
- return; |
- |
-#if defined(OS_CHROMEOS) |
- // Don't show content browser for extension/theme downloads from gallery. |
- if (download->is_extension_install()) { |
- ExtensionService* service = profile_->GetExtensionService(); |
- if (service && service->IsDownloadFromGallery(download->url(), |
- download->referrer_url())) { |
- return; |
- } |
- } |
- // Open the Active Downloads ui for chromeos. |
- ActiveDownloadsUI::OpenPopup(profile_); |
-#else |
- // GetDownloadShelf creates the download shelf if it was not yet created. |
- window()->GetDownloadShelf()->AddDownload(new DownloadItemModel(download)); |
- |
- // Don't show the animation for "Save file" downloads. |
- if (download->total_bytes() <= 0) |
- return; |
- |
- // For non-theme extensions, we don't show the download animation. |
- if (download->is_extension_install() && |
- !ExtensionService::IsDownloadFromMiniGallery(download->url())) |
- return; |
- |
- TabContents* current_tab = GetSelectedTabContents(); |
- // We make this check for the case of minimized windows, unit tests, etc. |
- if (platform_util::IsVisible(current_tab->GetNativeView()) && |
- ui::Animation::ShouldRenderRichAnimation()) { |
- DownloadStartedAnimation::Show(current_tab); |
- } |
-#endif |
- |
- // If the download occurs in a new tab, close it. |
- TabContentsWrapper* wrapper = |
- TabContentsWrapper::GetCurrentWrapperForContents(tab); |
- if (tab->controller().IsInitialNavigation() && |
- GetConstrainingContentsWrapper(wrapper) == wrapper && tab_count() > 1) { |
- CloseContents(tab); |
- } |
-} |
- |
void Browser::ShowPageInfo(Profile* profile, |
const GURL& url, |
const NavigationEntry::SSLStatus& ssl, |
@@ -3483,6 +3438,56 @@ void Browser::URLStarredChanged(TabContentsWrapper* source, bool starred) { |
} |
/////////////////////////////////////////////////////////////////////////////// |
+// Browser, DownloadTabHelperDelegate implementation: |
+ |
+bool Browser::CanDownload(int request_id) { |
+ return true; |
+} |
+ |
+void Browser::OnStartDownload(DownloadItem* download, TabContentsWrapper* tab) { |
+ if (!window()) |
+ return; |
+ |
+#if defined(OS_CHROMEOS) |
+ // Don't show content browser for extension/theme downloads from gallery. |
+ if (download->is_extension_install()) { |
+ ExtensionService* service = profile_->GetExtensionService(); |
+ if (service && service->IsDownloadFromGallery(download->url(), |
+ download->referrer_url())) { |
+ return; |
+ } |
+ } |
+ // Open the Active Downloads ui for chromeos. |
+ ActiveDownloadsUI::OpenPopup(profile_); |
+#else |
+ // GetDownloadShelf creates the download shelf if it was not yet created. |
+ window()->GetDownloadShelf()->AddDownload(new DownloadItemModel(download)); |
+ |
+ // Don't show the animation for "Save file" downloads. |
+ if (download->total_bytes() <= 0) |
+ return; |
+ |
+ // For non-theme extensions, we don't show the download animation. |
+ if (download->is_extension_install() && |
+ !ExtensionService::IsDownloadFromMiniGallery(download->url())) |
+ return; |
+ |
+ TabContents* current_tab = GetSelectedTabContents(); |
+ // We make this check for the case of minimized windows, unit tests, etc. |
+ if (platform_util::IsVisible(current_tab->GetNativeView()) && |
+ ui::Animation::ShouldRenderRichAnimation()) { |
+ DownloadStartedAnimation::Show(current_tab); |
+ } |
+#endif |
+ |
+ // If the download occurs in a new tab, close it. |
+ if (tab->tab_contents()->controller().IsInitialNavigation() && |
+ GetConstrainingContentsWrapper(tab) == tab && tab_count() > 1) { |
+ CloseContents(tab->tab_contents()); |
+ } |
+} |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
// Browser, SelectFileDialog::Listener implementation: |
void Browser::FileSelected(const FilePath& path, int index, void* params) { |
@@ -4392,6 +4397,7 @@ void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) { |
// ...and all the helpers. |
tab->blocked_content_tab_helper()->set_delegate(delegate); |
tab->bookmark_tab_helper()->set_delegate(delegate); |
+ tab->download_tab_helper()->set_delegate(delegate); |
tab->search_engine_tab_helper()->set_delegate(delegate); |
} |