Chromium Code Reviews| Index: chrome/browser/ui/browser.cc |
| =================================================================== |
| --- chrome/browser/ui/browser.cc (revision 92561) |
| +++ chrome/browser/ui/browser.cc (working copy) |
| @@ -3314,6 +3314,61 @@ |
| 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->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, |
| @@ -3475,56 +3530,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) { |
|
jam
2011/07/15 00:53:26
btw I took out the "GetConstrainingContentsWrapper
|
| - CloseContents(tab->tab_contents()); |
| - } |
| -} |
| - |
| -/////////////////////////////////////////////////////////////////////////////// |
| // Browser, SelectFileDialog::Listener implementation: |
| void Browser::FileSelected(const FilePath& path, int index, void* params) { |
| @@ -4494,7 +4499,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); |
| } |