| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/download/download_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 if (!download) | 302 if (!download) |
| 303 return; | 303 return; |
| 304 | 304 |
| 305 VLOG(20) << __FUNCTION__ << "()" | 305 VLOG(20) << __FUNCTION__ << "()" |
| 306 << " download = " << download->DebugString(true); | 306 << " download = " << download->DebugString(true); |
| 307 | 307 |
| 308 FilePath suggested_path = download->GetSuggestedPath(); | 308 FilePath suggested_path = download->GetSuggestedPath(); |
| 309 | 309 |
| 310 if (download->PromptUserForSaveLocation()) { | 310 if (download->PromptUserForSaveLocation()) { |
| 311 // We must ask the user for the place to put the download. | 311 // We must ask the user for the place to put the download. |
| 312 TabContents* contents = download->GetTabContents(); | 312 WebContents* contents = download->GetTabContents(); |
| 313 | 313 |
| 314 // |id_ptr| will be deleted in either FileSelected() or | 314 // |id_ptr| will be deleted in either FileSelected() or |
| 315 // FileSelectionCancelled(). | 315 // FileSelectionCancelled(). |
| 316 int32* id_ptr = new int32; | 316 int32* id_ptr = new int32; |
| 317 *id_ptr = download_id; | 317 *id_ptr = download_id; |
| 318 FilePath target_path; | 318 FilePath target_path; |
| 319 // If |download| is a potentially dangerous file, then |suggested_path| | 319 // If |download| is a potentially dangerous file, then |suggested_path| |
| 320 // contains the intermediate name instead of the final download | 320 // contains the intermediate name instead of the final download |
| 321 // filename. The latter is GetTargetName(). | 321 // filename. The latter is GetTargetName(). |
| 322 if (download->GetDangerType() != DownloadStateInfo::NOT_DANGEROUS) | 322 if (download->GetDangerType() != DownloadStateInfo::NOT_DANGEROUS) |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 } | 984 } |
| 985 | 985 |
| 986 void DownloadManagerImpl::ShowDownloadInBrowser(DownloadItem* download) { | 986 void DownloadManagerImpl::ShowDownloadInBrowser(DownloadItem* download) { |
| 987 // The 'contents' may no longer exist if the user closed the tab before we | 987 // The 'contents' may no longer exist if the user closed the tab before we |
| 988 // get this start completion event. | 988 // get this start completion event. |
| 989 WebContents* content = download->GetTabContents(); | 989 WebContents* content = download->GetTabContents(); |
| 990 | 990 |
| 991 // If the contents no longer exists, we ask the embedder to suggest another | 991 // If the contents no longer exists, we ask the embedder to suggest another |
| 992 // tab. | 992 // tab. |
| 993 if (!content) | 993 if (!content) |
| 994 content = delegate_->GetAlternativeTabContentsToNotifyForDownload(); | 994 content = delegate_->GetAlternativeWebContentsToNotifyForDownload(); |
| 995 | 995 |
| 996 if (content && content->GetDelegate()) | 996 if (content && content->GetDelegate()) |
| 997 content->GetDelegate()->OnStartDownload(content, download); | 997 content->GetDelegate()->OnStartDownload(content, download); |
| 998 } | 998 } |
| 999 | 999 |
| 1000 int DownloadManagerImpl::InProgressCount() const { | 1000 int DownloadManagerImpl::InProgressCount() const { |
| 1001 return static_cast<int>(in_progress_.size()); | 1001 return static_cast<int>(in_progress_.size()); |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 // Clears the last download path, used to initialize "save as" dialogs. | 1004 // Clears the last download path, used to initialize "save as" dialogs. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 it != history_downloads_.end(); ++it) { | 1136 it != history_downloads_.end(); ++it) { |
| 1137 if (it->second->IsComplete() && !it->second->GetOpened()) | 1137 if (it->second->IsComplete() && !it->second->GetOpened()) |
| 1138 ++num_unopened; | 1138 ++num_unopened; |
| 1139 } | 1139 } |
| 1140 download_stats::RecordOpensOutstanding(num_unopened); | 1140 download_stats::RecordOpensOutstanding(num_unopened); |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { | 1143 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { |
| 1144 file_manager_ = file_manager; | 1144 file_manager_ = file_manager; |
| 1145 } | 1145 } |
| OLD | NEW |