Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: chrome/browser/download/download_manager.cc

Issue 18388: Fix download path bugs (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/history/download_database.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <time.h> 5 #include <time.h>
6 6
7 #include "chrome/browser/download/download_manager.h" 7 #include "chrome/browser/download/download_manager.h"
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 812
813 // Called on the file thread. Renames the downloaded file to its original name. 813 // Called on the file thread. Renames the downloaded file to its original name.
814 void DownloadManager::ProceedWithFinishedDangerousDownload( 814 void DownloadManager::ProceedWithFinishedDangerousDownload(
815 int64 download_handle, 815 int64 download_handle,
816 const FilePath& path, 816 const FilePath& path,
817 const FilePath& original_name) { 817 const FilePath& original_name) {
818 bool success = false; 818 bool success = false;
819 FilePath new_path; 819 FilePath new_path;
820 int uniquifier = 0; 820 int uniquifier = 0;
821 if (file_util::PathExists(path)) { 821 if (file_util::PathExists(path)) {
822 new_path = new_path.DirName().Append(original_name); 822 new_path = path.DirName().Append(original_name);
823 // Make our name unique at this point, as if a dangerous file is downloading 823 // Make our name unique at this point, as if a dangerous file is downloading
824 // and a 2nd download is started for a file with the same name, they would 824 // and a 2nd download is started for a file with the same name, they would
825 // have the same path. This is because we uniquify the name on download 825 // have the same path. This is because we uniquify the name on download
826 // start, and at that time the first file does not exists yet, so the second 826 // start, and at that time the first file does not exists yet, so the second
827 // file gets the same name. 827 // file gets the same name.
828 uniquifier = GetUniquePathNumber(new_path); 828 uniquifier = GetUniquePathNumber(new_path);
829 if (uniquifier > 0) 829 if (uniquifier > 0)
830 AppendNumberToPath(&new_path, uniquifier); 830 AppendNumberToPath(&new_path, uniquifier);
831 success = file_util::Move(path, new_path); 831 success = file_util::Move(path, new_path);
832 } else { 832 } else {
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 searched_downloads.push_back(dit->second); 1380 searched_downloads.push_back(dit->second);
1381 } 1381 }
1382 1382
1383 requestor->SetDownloads(searched_downloads); 1383 requestor->SetDownloads(searched_downloads);
1384 } 1384 }
1385 1385
1386 // Clears the last download path, used to initialize "save as" dialogs. 1386 // Clears the last download path, used to initialize "save as" dialogs.
1387 void DownloadManager::ClearLastDownloadPath() { 1387 void DownloadManager::ClearLastDownloadPath() {
1388 last_download_path_ = FilePath(); 1388 last_download_path_ = FilePath();
1389 } 1389 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/download_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698