| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/shell_download_manager_delegate.h" | 5 #include "content/shell/browser/shell_download_manager_delegate.h" | 
| 6 | 6 | 
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) | 
| 8 #include <windows.h> | 8 #include <windows.h> | 
| 9 #include <commdlg.h> | 9 #include <commdlg.h> | 
| 10 #endif | 10 #endif | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 66   // SetDownloadManager, the system is not fully initialized. | 66   // SetDownloadManager, the system is not fully initialized. | 
| 67   if (default_download_path_.empty()) { | 67   if (default_download_path_.empty()) { | 
| 68     default_download_path_ = download_manager_->GetBrowserContext()->GetPath(). | 68     default_download_path_ = download_manager_->GetBrowserContext()->GetPath(). | 
| 69         Append(FILE_PATH_LITERAL("Downloads")); | 69         Append(FILE_PATH_LITERAL("Downloads")); | 
| 70   } | 70   } | 
| 71 | 71 | 
| 72   if (!download->GetForcedFilePath().empty()) { | 72   if (!download->GetForcedFilePath().empty()) { | 
| 73     callback.Run(download->GetForcedFilePath(), | 73     callback.Run(download->GetForcedFilePath(), | 
| 74                  DownloadItem::TARGET_DISPOSITION_OVERWRITE, | 74                  DownloadItem::TARGET_DISPOSITION_OVERWRITE, | 
| 75                  DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | 75                  DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | 
| 76                  download->GetForcedFilePath()); | 76                  download->GetForcedFilePath(), DOWNLOAD_INTERRUPT_REASON_NONE); | 
| 77     return true; | 77     return true; | 
| 78   } | 78   } | 
| 79 | 79 | 
| 80   FilenameDeterminedCallback filename_determined_callback = | 80   FilenameDeterminedCallback filename_determined_callback = | 
| 81       base::Bind(&ShellDownloadManagerDelegate::OnDownloadPathGenerated, | 81       base::Bind(&ShellDownloadManagerDelegate::OnDownloadPathGenerated, | 
| 82                  weak_ptr_factory_.GetWeakPtr(), | 82                  weak_ptr_factory_.GetWeakPtr(), | 
| 83                  download->GetId(), | 83                  download->GetId(), | 
| 84                  callback); | 84                  callback); | 
| 85 | 85 | 
| 86   BrowserThread::PostTask( | 86   BrowserThread::PostTask( | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 134 | 134 | 
| 135 void ShellDownloadManagerDelegate::OnDownloadPathGenerated( | 135 void ShellDownloadManagerDelegate::OnDownloadPathGenerated( | 
| 136     uint32_t download_id, | 136     uint32_t download_id, | 
| 137     const DownloadTargetCallback& callback, | 137     const DownloadTargetCallback& callback, | 
| 138     const base::FilePath& suggested_path) { | 138     const base::FilePath& suggested_path) { | 
| 139   DCHECK_CURRENTLY_ON(BrowserThread::UI); | 139   DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
| 140   if (suppress_prompting_) { | 140   if (suppress_prompting_) { | 
| 141     // Testing exit. | 141     // Testing exit. | 
| 142     callback.Run(suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, | 142     callback.Run(suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, | 
| 143                  DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | 143                  DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | 
| 144                  suggested_path.AddExtension(FILE_PATH_LITERAL(".crdownload"))); | 144                  suggested_path.AddExtension(FILE_PATH_LITERAL(".crdownload")), | 
|  | 145                  DOWNLOAD_INTERRUPT_REASON_NONE); | 
| 145     return; | 146     return; | 
| 146   } | 147   } | 
| 147 | 148 | 
| 148   ChooseDownloadPath(download_id, callback, suggested_path); | 149   ChooseDownloadPath(download_id, callback, suggested_path); | 
| 149 } | 150 } | 
| 150 | 151 | 
| 151 void ShellDownloadManagerDelegate::ChooseDownloadPath( | 152 void ShellDownloadManagerDelegate::ChooseDownloadPath( | 
| 152     uint32_t download_id, | 153     uint32_t download_id, | 
| 153     const DownloadTargetCallback& callback, | 154     const DownloadTargetCallback& callback, | 
| 154     const base::FilePath& suggested_path) { | 155     const base::FilePath& suggested_path) { | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 178   save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING | | 179   save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING | | 
| 179                   OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; | 180                   OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; | 
| 180 | 181 | 
| 181   if (GetSaveFileName(&save_as)) | 182   if (GetSaveFileName(&save_as)) | 
| 182     result = base::FilePath(std::wstring(save_as.lpstrFile)); | 183     result = base::FilePath(std::wstring(save_as.lpstrFile)); | 
| 183 #else | 184 #else | 
| 184   NOTIMPLEMENTED(); | 185   NOTIMPLEMENTED(); | 
| 185 #endif | 186 #endif | 
| 186 | 187 | 
| 187   callback.Run(result, DownloadItem::TARGET_DISPOSITION_PROMPT, | 188   callback.Run(result, DownloadItem::TARGET_DISPOSITION_PROMPT, | 
| 188                DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, result); | 189                DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, result, | 
|  | 190                DOWNLOAD_INTERRUPT_REASON_NONE); | 
| 189 } | 191 } | 
| 190 | 192 | 
| 191 void ShellDownloadManagerDelegate::SetDownloadBehaviorForTesting( | 193 void ShellDownloadManagerDelegate::SetDownloadBehaviorForTesting( | 
| 192     const base::FilePath& default_download_path) { | 194     const base::FilePath& default_download_path) { | 
| 193   default_download_path_ = default_download_path; | 195   default_download_path_ = default_download_path; | 
| 194   suppress_prompting_ = true; | 196   suppress_prompting_ = true; | 
| 195 } | 197 } | 
| 196 | 198 | 
| 197 }  // namespace content | 199 }  // namespace content | 
| OLD | NEW | 
|---|