OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "chrome/browser/download/save_package.h" | 5 #include "chrome/browser/download/save_package.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 file_name_count_map_[base_file_name] = 1; | 338 file_name_count_map_[base_file_name] = 1; |
339 ordinal_number = 1; | 339 ordinal_number = 1; |
340 } else { | 340 } else { |
341 // We have met same base-name conflict, use latest ordinal number. | 341 // We have met same base-name conflict, use latest ordinal number. |
342 ordinal_number = it->second; | 342 ordinal_number = it->second; |
343 } | 343 } |
344 | 344 |
345 if (ordinal_number > (kMaxFileOrdinalNumber - 1)) { | 345 if (ordinal_number > (kMaxFileOrdinalNumber - 1)) { |
346 // Use a random file from temporary file. | 346 // Use a random file from temporary file. |
347 FilePath temp_file; | 347 FilePath temp_file; |
348 file_util::CreateTemporaryFileName(&temp_file); | 348 file_util::CreateTemporaryFile(&temp_file); |
349 file_name = temp_file.RemoveExtension().BaseName().value(); | 349 file_name = temp_file.RemoveExtension().BaseName().value(); |
350 // Get safe pure file name. | 350 // Get safe pure file name. |
351 if (!GetSafePureFileName(saved_main_directory_path_, | 351 if (!GetSafePureFileName(saved_main_directory_path_, |
352 FilePath::StringType(), | 352 FilePath::StringType(), |
353 kMaxFilePathLength, &file_name)) | 353 kMaxFilePathLength, &file_name)) |
354 return false; | 354 return false; |
355 } else { | 355 } else { |
356 for (int i = ordinal_number; i < kMaxFileOrdinalNumber; ++i) { | 356 for (int i = ordinal_number; i < kMaxFileOrdinalNumber; ++i) { |
357 FilePath::StringType new_name = base_file_name + | 357 FilePath::StringType new_name = base_file_name + |
358 StringPrintf(FILE_PATH_LITERAL("(%d)"), i) + file_name_ext; | 358 StringPrintf(FILE_PATH_LITERAL("(%d)"), i) + file_name_ext; |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 int index, void* params) { | 1200 int index, void* params) { |
1201 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); | 1201 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); |
1202 ContinueSave(save_params, path, index); | 1202 ContinueSave(save_params, path, index); |
1203 delete save_params; | 1203 delete save_params; |
1204 } | 1204 } |
1205 | 1205 |
1206 void SavePackage::FileSelectionCanceled(void* params) { | 1206 void SavePackage::FileSelectionCanceled(void* params) { |
1207 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); | 1207 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); |
1208 delete save_params; | 1208 delete save_params; |
1209 } | 1209 } |
OLD | NEW |