Chromium Code Reviews| Index: chrome/browser/ui/browser.cc |
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
| index f1d1d7dcd4ee502a62019b6aeec6220704ccb12e..772672f8a075b8e095e3a4f4d4390bca8b834add 100644 |
| --- a/chrome/browser/ui/browser.cc |
| +++ b/chrome/browser/ui/browser.cc |
| @@ -1334,6 +1334,41 @@ void Browser::MaybeUpdateBookmarkBarStateForInstantPreview( |
| } |
| } |
| +void Browser::ShowDownload(content::DownloadItem* download) { |
| + scoped_ptr<DownloadItemModel> download_model(new DownloadItemModel(download)); |
|
Randy Smith (Not in Mondays)
2012/12/25 23:05:54
Why before bailing if the window isn't there?
asanka
2013/01/10 22:12:14
Done. Note that https://codereview.chromium.org/11
|
| + if (!window()) |
| + return; |
| + |
| + // If the download occurs in a new tab, and it's not a save page |
| + // download (started before initial navigation completed) close it. |
| + WebContents* source = download->GetWebContents(); |
| + if (source && source->GetController().IsInitialNavigation() && |
| + tab_count() > 1 && !download->IsSavePackageDownload()) { |
| + CloseContents(source); |
| + } |
| + |
| + // Some (app downloads) are not supposed to appear on the shelf. |
| + if (!download_model->ShouldShowInShelf()) |
| + return; |
| + |
| + // GetDownloadShelf creates the download shelf if it was not yet created. |
| + DownloadShelf* shelf = window()->GetDownloadShelf(); |
| + shelf->AddDownload(download_model.release()); |
| + // Don't show the animation for "Save file" downloads. |
| + // For non-theme extensions, we don't show the download animation. |
| + // Show animation in same window as the download shelf. Download shelf |
| + // may not be in the same window that initiated the download. |
| + // Don't show the animation if the selected tab is not visible (i.e. the |
| + // window is minimized, we're in a unit test, etc.). |
| + WebContents* shelf_tab = chrome::GetActiveWebContents(shelf->browser()); |
| + if ((download->GetTotalBytes() > 0) && |
| + !download_crx_util::IsExtensionDownload(*download) && |
| + platform_util::IsVisible(shelf_tab->GetNativeView()) && |
| + ui::Animation::ShouldRenderRichAnimation()) { |
| + DownloadStartedAnimation::Show(shelf_tab); |
| + } |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| // Browser, content::WebContentsDelegate implementation: |
| @@ -1495,46 +1530,6 @@ int Browser::GetExtraRenderViewHeight() const { |
| return window_->GetExtraRenderViewHeight(); |
| } |
| -void Browser::OnStartDownload(WebContents* source, |
| - content::DownloadItem* download) { |
| - scoped_ptr<DownloadItemModel> download_model(new DownloadItemModel(download)); |
| - if (!download_model->ShouldShowInShelf()) |
| - return; |
| - |
| - WebContents* constrained = GetConstrainingWebContents(source); |
| - if (constrained != source) { |
| - // Download in a constrained popup is shown in the tab that opened it. |
| - constrained->GetDelegate()->OnStartDownload(constrained, download); |
| - return; |
| - } |
| - |
| - if (!window()) |
| - return; |
| - |
| - // GetDownloadShelf creates the download shelf if it was not yet created. |
| - DownloadShelf* shelf = window()->GetDownloadShelf(); |
| - shelf->AddDownload(download_model.release()); |
| - // Don't show the animation for "Save file" downloads. |
| - // For non-theme extensions, we don't show the download animation. |
| - // Show animation in same window as the download shelf. Download shelf |
| - // may not be in the same window that initiated the download. |
| - // Don't show the animation if the selected tab is not visible (i.e. the |
| - // window is minimized, we're in a unit test, etc.). |
| - WebContents* shelf_tab = chrome::GetActiveWebContents(shelf->browser()); |
| - if ((download->GetTotalBytes() > 0) && |
| - !download_crx_util::IsExtensionDownload(*download) && |
| - platform_util::IsVisible(shelf_tab->GetNativeView()) && |
| - ui::Animation::ShouldRenderRichAnimation()) { |
| - DownloadStartedAnimation::Show(shelf_tab); |
| - } |
| - |
| - // If the download occurs in a new tab, and it's not a save page |
| - // download (started before initial navigation completed) close it. |
| - if (source->GetController().IsInitialNavigation() && tab_count() > 1 && |
| - !download->IsSavePackageDownload()) |
| - CloseContents(source); |
| -} |
| - |
| void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { |
| DCHECK(source); |
| chrome::ViewSource(this, source); |