Lines Matching refs:download

5 #include "chrome/browser/download/download_manager.h"
19 #include "chrome/browser/download/download_extensions.h"
20 #include "chrome/browser/download/download_file_manager.h"
21 #include "chrome/browser/download/download_history.h"
22 #include "chrome/browser/download/download_item.h"
23 #include "chrome/browser/download/download_prefs.h"
24 #include "chrome/browser/download/download_safe_browsing_client.h"
25 #include "chrome/browser/download/download_status_updater.h"
26 #include "chrome/browser/download/download_util.h"
86 DownloadItem* download = *it;
93 if (download->safety_state() == DownloadItem::DANGEROUS &&
94 download->IsPartialDownload()) {
101 // the download was deleted if-and-only-if it was removed
103 download->Delete(DownloadItem::DELETE_DUE_TO_BROWSER_SHUTDOWN);
104 } else if (download->IsPartialDownload()) {
105 download->Cancel(false);
106 download_history_->UpdateEntry(download);
248 // We have received a message from DownloadFileManager about a new download. We
249 // create a download item and store it in our download map, and inform the
250 // history system of a new download. Since this method can be called while the
254 // finalization of the the download creation as a callback from the
259 // Create a client to verify download URL with safebrowsing.
274 // Check whether this download is for an extension install or not.
305 // Determine the proper path for a download, by either one of the following:
306 // 1) using the default download directory.
324 // We need to move over to the download thread because we don't want to stat
326 // We can only access preferences on the UI thread, so check the download path
342 // Make sure the default download directory exists.
358 // If the download is deemed dangerous, we'll use a temporary name for it.
362 // download.
431 // We must ask the user for the place to put the download.
453 // No prompting for download, just continue with the suggested name.
462 DownloadItem* download = new DownloadItem(this, *info,
466 downloads_.insert(download);
467 active_downloads_[info->download_id] = download;
482 DownloadItem* download = active_downloads_[info->download_id];
483 DCHECK(download != NULL);
484 DCHECK(ContainsKey(downloads_, download));
486 download->SetFileCheckResults(info->path,
493 in_progress_[info->download_id] = download;
499 // The download is not safe. We can now rename the file to its
505 // The download is a safe download. We need to
516 download->id(), download_path));
518 download->Rename(download_path);
520 download_history_->AddEntry(*info, download,
528 DownloadItem* download = it->second;
529 if (download->IsInProgress()) {
530 download->Update(size);
532 download_history_->UpdateEntry(download);
545 // and Safari 5.0.4 - treat the download as complete in this case, so we
566 DownloadItem* download = active_downloads_[download_id];
567 download->OnAllDataSaved(size);
570 // or there is error while it is calculated. We will skip the download hash
575 download->url_chain(),
576 download->referrer_url());
580 MaybeCompleteDownload(download);
593 // the download already finished.
601 bool DownloadManager::IsDownloadReadyForCompletion(DownloadItem* download) {
602 // If we don't have all the data, the download is not ready for
604 if (!download->all_data_saved())
607 // If the download is dangerous, but not yet validated, it's not ready for
609 if (download->safety_state() == DownloadItem::DANGEROUS)
612 // If the download isn't active (e.g. has been cancelled) it's not
614 if (active_downloads_.count(download->id()) == 0)
617 // If the download hasn't been inserted into the history system
620 return (download->db_handle() != DownloadHistory::kUninitializedHandle);
623 void DownloadManager::MaybeCompleteDownload(DownloadItem* download) {
625 VLOG(20) << __FUNCTION__ << "()" << " download = "
626 << download->DebugString(false);
628 if (!IsDownloadReadyForCompletion(download))
632 // once per download. The natural way to do this is by a state
637 DCHECK_NE(DownloadItem::DANGEROUS, download->safety_state());
638 DCHECK_EQ(1u, in_progress_.count(download->id()));
639 DCHECK(download->all_data_saved());
640 DCHECK(download->db_handle() != DownloadHistory::kUninitializedHandle);
641 DCHECK_EQ(1u, history_downloads_.count(download->db_handle()));
643 VLOG(20) << __FUNCTION__ << "()" << " executing: download = "
644 << download->DebugString(false);
647 in_progress_.erase(download->id());
650 download_history_->UpdateEntry(download);
652 // Finish the download.
653 download->OnDownloadCompleting(file_manager_);
658 DownloadItem* download = GetDownloadItem(download_id);
659 DCHECK(download);
660 download_history_->UpdateEntry(download);
697 DownloadItem* download = it->second;
700 << " download = " << download->DebugString(true);
704 if (download->db_handle() != DownloadHistory::kUninitializedHandle) {
708 download_history_->UpdateEntry(download);
712 download->render_process_id(),
713 download->request_id());
739 // A cancel at the right time could remove the download from the
744 DownloadItem* download = it->second;
747 << download->received_bytes() << " for download = "
748 << download->DebugString(true);
751 // downloads, as we will keep the download item around in that case.
755 if (download->db_handle() != DownloadHistory::kUninitializedHandle) {
759 download_history_->UpdateEntry(download);
762 download->Interrupted(size, os_error);
775 DownloadItem* download = it->second;
776 if (pause == download->is_paused())
784 download->render_process_id(),
785 download->request_id(),
808 DownloadItem* download = it->second;
809 download_history_->RemoveEntry(download);
813 int downloads_count = downloads_.erase(download);
819 delete download;
831 DownloadItem* download = it->second;
832 if (download->start_time() >= remove_begin &&
833 (remove_end.is_null() || download->start_time() < remove_end) &&
834 (download->IsComplete() ||
835 download->IsCancelled() ||
836 download->IsInterrupted())) {
841 pending_deletes.push_back(download);
862 // Delete the download items themselves.
877 // This is an incognito downloader. Clear All should clear main download
892 // Initiate a download of a specific URL. We send the request to the
894 // download.
988 // download that's already in progress to the temporary location.
995 void DownloadManager::DangerousDownloadValidated(DownloadItem* download) {
997 DCHECK_EQ(DownloadItem::DANGEROUS, download->safety_state());
998 download->set_safety_state(DownloadItem::DANGEROUS_BUT_VALIDATED);
999 download->UpdateObservers();
1001 MaybeCompleteDownload(download);
1006 // The history service has retrieved all download entries. 'entries' contains
1011 DownloadItem* download = new DownloadItem(this, entries->at(i));
1012 DCHECK(!ContainsKey(history_downloads_, download->db_handle()));
1013 downloads_.insert(download);
1014 history_downloads_[download->db_handle()] = download;
1016 << " download = " << download->DebugString(true);
1031 DownloadItem* download = it->second;
1034 << " download = " << download->DebugString(true);
1044 DCHECK(download->db_handle() == DownloadHistory::kUninitializedHandle);
1045 download->set_db_handle(db_handle);
1047 DCHECK(!ContainsKey(history_downloads_, download->db_handle()));
1048 history_downloads_[download->db_handle()] = download;
1051 // This includes buttons to save or cancel, for a dangerous download.
1052 ShowDownloadInBrowser(info, download);
1054 // Inform interested objects about the new download.
1057 // If the download is still in progress, try to complete it.
1059 // Otherwise, download has been cancelled or interrupted before we've
1064 if (download->IsInProgress()) {
1065 MaybeCompleteDownload(download);
1067 DCHECK(download->IsCancelled())
1068 << " download = " << download->DebugString(true);
1071 download_history_->UpdateEntry(download);
1072 download->UpdateObservers();
1077 DownloadItem* download) {
1080 // to display its download shelf.
1084 // If the contents no longer exists, we start the download in the last active
1085 // browser. This is not ideal but better than fully hiding the download from
1094 contents->OnStartDownload(download);
1097 // Clears the last download path, used to initialize "save as" dialogs.