Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3830)

Unified Diff: chrome/browser/ui/browser.cc

Issue 7374008: Move download stuff from download helper back to TabContents. This is basically a revert of r8576... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/browser.cc
===================================================================
--- chrome/browser/ui/browser.cc (revision 92629)
+++ chrome/browser/ui/browser.cc (working copy)
@@ -3326,6 +3326,57 @@
return window_->GetExtraRenderViewHeight();
}
+void Browser::OnStartDownload(DownloadItem* download, TabContents* tab) {
+ TabContentsWrapper* wrapper =
+ TabContentsWrapper::GetCurrentWrapperForContents(tab);
+ TabContentsWrapper* constrained = GetConstrainingContentsWrapper(wrapper);
+ if (constrained != wrapper) {
+ // Download in a constrained popup is shown in the tab that opened it.
+ TabContents* constrained_tab = constrained->tab_contents();
+ constrained_tab->delegate()->OnStartDownload(download, constrained_tab);
+ return;
+ }
+
+ 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->GetURL(),
+ 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->GetURL()))
+ 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->controller().IsInitialNavigation() && tab_count() > 1)
+ CloseContents(tab);
+}
+
void Browser::ShowPageInfo(Profile* profile,
const GURL& url,
const NavigationEntry::SSLStatus& ssl,
@@ -3487,56 +3538,6 @@
}
///////////////////////////////////////////////////////////////////////////////
-// 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->GetURL(),
- 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->GetURL()))
- 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) {
@@ -4506,7 +4507,6 @@
// ...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);
}

Powered by Google App Engine
This is Rietveld 408576698