| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell/shell_download_manager_delegate.h" | 5 #include "content/shell/shell_download_manager_delegate.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 ChooseDownloadPath(download_id, callback, suggested_path); | 118 ChooseDownloadPath(download_id, callback, suggested_path); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void ShellDownloadManagerDelegate::ChooseDownloadPath( | 121 void ShellDownloadManagerDelegate::ChooseDownloadPath( |
| 122 int32 download_id, | 122 int32 download_id, |
| 123 const DownloadTargetCallback& callback, | 123 const DownloadTargetCallback& callback, |
| 124 const FilePath& suggested_path) { | 124 const FilePath& suggested_path) { |
| 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 126 DownloadItem* item = | 126 DownloadItem* item = download_manager_->GetDownload(download_id); |
| 127 download_manager_->GetActiveDownloadItem(download_id); | 127 if (!item || (item->GetState() != DownloadItem::IN_PROGRESS)) |
| 128 if (!item) | |
| 129 return; | 128 return; |
| 130 | 129 |
| 131 FilePath result; | 130 FilePath result; |
| 132 #if defined(OS_WIN) && !defined(USE_AURA) | 131 #if defined(OS_WIN) && !defined(USE_AURA) |
| 133 std::wstring file_part = FilePath(suggested_path).BaseName().value(); | 132 std::wstring file_part = FilePath(suggested_path).BaseName().value(); |
| 134 wchar_t file_name[MAX_PATH]; | 133 wchar_t file_name[MAX_PATH]; |
| 135 base::wcslcpy(file_name, file_part.c_str(), arraysize(file_name)); | 134 base::wcslcpy(file_name, file_part.c_str(), arraysize(file_name)); |
| 136 OPENFILENAME save_as; | 135 OPENFILENAME save_as; |
| 137 ZeroMemory(&save_as, sizeof(save_as)); | 136 ZeroMemory(&save_as, sizeof(save_as)); |
| 138 save_as.lStructSize = sizeof(OPENFILENAME); | 137 save_as.lStructSize = sizeof(OPENFILENAME); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 item->GetId(), --last_download_db_handle_); | 186 item->GetId(), --last_download_db_handle_); |
| 188 } | 187 } |
| 189 | 188 |
| 190 void ShellDownloadManagerDelegate::SetDownloadBehaviorForTesting( | 189 void ShellDownloadManagerDelegate::SetDownloadBehaviorForTesting( |
| 191 const FilePath& default_download_path) { | 190 const FilePath& default_download_path) { |
| 192 default_download_path_ = default_download_path; | 191 default_download_path_ = default_download_path; |
| 193 suppress_prompting_ = true; | 192 suppress_prompting_ = true; |
| 194 } | 193 } |
| 195 | 194 |
| 196 } // namespace content | 195 } // namespace content |
| OLD | NEW |