Index: chrome/browser/download/download_file.cc |
=================================================================== |
--- chrome/browser/download/download_file.cc (revision 7599) |
+++ chrome/browser/download/download_file.cc (working copy) |
@@ -85,22 +85,21 @@ |
void DownloadFile::Cancel() { |
Close(); |
- DeleteFile(full_path_.c_str()); |
+ file_util::Delete(full_path_, false); |
} |
// The UI has provided us with our finalized name. |
-bool DownloadFile::Rename(const std::wstring& new_path) { |
+bool DownloadFile::Rename(const FilePath& new_path) { |
Close(); |
// We cannot rename because rename will keep the same security descriptor |
// on the destination file. We want to recreate the security descriptor |
// with the security that makes sense in the new path. |
- if (!file_util::RenameFileAndResetSecurityDescriptor(full_path_.c_str(), |
- new_path.c_str())) { |
+ if (!file_util::RenameFileAndResetSecurityDescriptor(full_path_, new_path)) { |
return false; |
} |
- DeleteFile(full_path_.c_str()); |
+ file_util::Delete(full_path_, false); |
full_path_ = new_path; |
path_renamed_ = true; |
@@ -512,15 +511,15 @@ |
// Open a download, or show it in a Windows Explorer window. We run on this |
// thread to avoid blocking the UI with (potentially) slow Shell operations. |
// TODO(paulg): File 'stat' operations. |
-void DownloadFileManager::OnShowDownloadInShell(const std::wstring full_path) { |
+void DownloadFileManager::OnShowDownloadInShell(const FilePath& full_path) { |
DCHECK(MessageLoop::current() == file_loop_); |
- win_util::ShowItemInFolder(full_path); |
+ win_util::ShowItemInFolder(full_path.value()); |
} |
// Launches the selected download using ShellExecute 'open' verb. If there is |
// a valid parent window, the 'safer' version will be used which can |
// display a modal dialog asking for user consent on dangerous files. |
-void DownloadFileManager::OnOpenDownloadInShell(const std::wstring full_path, |
+void DownloadFileManager::OnOpenDownloadInShell(const FilePath& full_path, |
const std::wstring& url, |
HWND parent_window) { |
DCHECK(MessageLoop::current() == file_loop_); |
@@ -535,15 +534,13 @@ |
// download specified by 'id'. Rename the in progress download, and remove it |
// from our table if it has been completed or cancelled already. |
void DownloadFileManager::OnFinalDownloadName(int id, |
- const std::wstring& full_path) { |
+ const FilePath& full_path) { |
DCHECK(MessageLoop::current() == file_loop_); |
DownloadFileMap::iterator it = downloads_.find(id); |
if (it == downloads_.end()) |
return; |
- std::wstring download_dir = file_util::GetDirectoryFromPath(full_path); |
- if (!file_util::PathExists(download_dir)) |
- file_util::CreateDirectory(download_dir); |
+ file_util::CreateDirectory(full_path.DirName()); |
DownloadFile* download = it->second; |
if (!download->Rename(full_path)) { |
@@ -576,13 +573,9 @@ |
this, &DownloadFileManager::StopUpdateTimer)); |
} |
-void DownloadFileManager::CreateDirectory(const std::wstring& directory) { |
- if (!file_util::PathExists(directory)) |
- file_util::CreateDirectory(directory); |
-} |
- |
-void DownloadFileManager::DeleteFile(const std::wstring& path) { |
+// static |
+void DownloadFileManager::DeleteFile(const FilePath& path) { |
// Make sure we only delete files. |
- if (file_util::PathExists(path) && !file_util::DirectoryExists(path)) |
+ if (!file_util::DirectoryExists(path)) |
file_util::Delete(path, false); |
} |