diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 20:16:53 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 20:16:53 +0000 |
commit | 5e5954879c3321919b2a9f0fc8525d30f90b582b (patch) | |
tree | dc0fad3d15c2aa5251aa1c4198d30ae1508a2481 /chrome | |
parent | 55a6a095c0fbf341e5773c0f11da57fa1f5572b1 (diff) | |
download | chromium_src-5e5954879c3321919b2a9f0fc8525d30f90b582b.zip chromium_src-5e5954879c3321919b2a9f0fc8525d30f90b582b.tar.gz chromium_src-5e5954879c3321919b2a9f0fc8525d30f90b582b.tar.bz2 |
Skip the download shelf altogether for extension downloads. The current UI looks pretty weird with it. This won't work great for larger extensions that take more than a couple of seconds to download, but we'll address that with extension specific UI when the DL manager is refactored.
TEST=download a crx file, verify that it installs with no shelf. download another type of file, verify that it uses the shelf properly.
Review URL: http://codereview.chromium.org/113038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15450 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/download/download_manager.cc | 48 | ||||
-rw-r--r-- | chrome/browser/download/download_manager.h | 4 |
2 files changed, 35 insertions, 17 deletions
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index 4e0b40e..0081a2d 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -1462,23 +1462,8 @@ void DownloadManager::OnCreateDownloadEntryComplete(DownloadCreateInfo info, DCHECK(downloads_.find(download->db_handle()) == downloads_.end()); downloads_[download->db_handle()] = download; - // The 'contents' may no longer exist if the user closed the tab before we get - // this start completion event. If it does, tell the origin TabContents to - // display its download shelf. - TabContents* contents = - tab_util::GetTabContentsByID(info.render_process_id, info.render_view_id); - - // If the contents no longer exists, we start the download in the last active - // browser. This is not ideal but better than fully hiding the download from - // the user. - if (!contents) { - Browser* last_active = BrowserList::GetLastActive(); - if (last_active) - contents = last_active->GetSelectedTabContents(); - } - - if (contents) - contents->OnStartDownload(download); + // Show in the appropropriate browser UI. + ShowDownloadInBrowser(info, download); // Inform interested objects about the new download. FOR_EACH_OBSERVER(Observer, observers_, ModelChanged()); @@ -1514,6 +1499,35 @@ void DownloadManager::OnSearchComplete(HistoryService::Handle handle, requestor->SetDownloads(searched_downloads); } +void DownloadManager::ShowDownloadInBrowser(const DownloadCreateInfo& info, + DownloadItem* download) { + // Extension downloading skips the shelf. This is a temporary fix until + // we can modularize the download system and develop specific extensiona + // install UI. + FilePath::StringType extension = info.path.Extension(); + // Ignore the leading period. + if (extension.find(chrome::kExtensionFileExtension) == 1) + return; + + // The 'contents' may no longer exist if the user closed the tab before we get + // this start completion event. If it does, tell the origin TabContents to + // display its download shelf. + TabContents* contents = + tab_util::GetTabContentsByID(info.render_process_id, info.render_view_id); + + // If the contents no longer exists, we start the download in the last active + // browser. This is not ideal but better than fully hiding the download from + // the user. + if (!contents) { + Browser* last_active = BrowserList::GetLastActive(); + if (last_active) + contents = last_active->GetSelectedTabContents(); + } + + if (contents) + contents->OnStartDownload(download); +} + // Clears the last download path, used to initialize "save as" dialogs. void DownloadManager::ClearLastDownloadPath() { last_download_path_ = FilePath(); diff --git a/chrome/browser/download/download_manager.h b/chrome/browser/download/download_manager.h index 0fb1675..97b731d 100644 --- a/chrome/browser/download/download_manager.h +++ b/chrome/browser/download/download_manager.h @@ -372,6 +372,10 @@ class DownloadManager : public base::RefCountedThreadSafe<DownloadManager>, void OnSearchComplete(HistoryService::Handle handle, std::vector<int64>* results); + // Display a new download in the appropriate browser UI. + void ShowDownloadInBrowser(const DownloadCreateInfo& info, + DownloadItem* download); + // Opens a download. For Chrome extensions call // ExtensionsServices::InstallExtension, for everything else call // OpenDownloadInShell. |