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

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

Issue 11640007: Make the UI an observer of downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android clang build Created 7 years, 10 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
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 11d6d4e9c3a3421f297a7fdcba42b8c5e8c9d074..1087a1ee89de0ec66ee9c1076758fa37fd96e5b8 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -1237,6 +1237,27 @@ void Browser::MaybeUpdateBookmarkBarStateForInstantOverlay(
}
}
+void Browser::ShowDownload(content::DownloadItem* download) {
+ 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_strip_model_->count() > 1 && !download->IsSavePackageDownload()) {
+ CloseContents(source);
+ }
+
+ // Some (app downloads) are not supposed to appear on the shelf.
+ if (!DownloadItemModel(download).ShouldShowInShelf())
+ return;
+
+ // GetDownloadShelf creates the download shelf if it was not yet created.
+ DownloadShelf* shelf = window()->GetDownloadShelf();
+ shelf->AddDownload(download);
+}
+
///////////////////////////////////////////////////////////////////////////////
// Browser, content::WebContentsDelegate implementation:
@@ -1402,32 +1423,6 @@ int Browser::GetExtraRenderViewHeight() const {
return window_->GetExtraRenderViewHeight();
}
-void Browser::OnStartDownload(WebContents* source,
- content::DownloadItem* download) {
- if (!DownloadItemModel(download).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);
-
- // 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_strip_model_->count() > 1 && !download->IsSavePackageDownload())
- CloseContents(source);
-}
-
void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) {
DCHECK(source);
chrome::ViewSource(this, source);
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698