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/browser/download/save_package.h" | 5 #include "content/browser/download/save_package.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 | 1395 |
1396 void SavePackage::OnPathPicked( | 1396 void SavePackage::OnPathPicked( |
1397 const base::FilePath& final_name, | 1397 const base::FilePath& final_name, |
1398 SavePageType type, | 1398 SavePageType type, |
1399 const SavePackageDownloadCreatedCallback& download_created_callback) { | 1399 const SavePackageDownloadCreatedCallback& download_created_callback) { |
1400 DCHECK((type == SAVE_PAGE_TYPE_AS_ONLY_HTML) || | 1400 DCHECK((type == SAVE_PAGE_TYPE_AS_ONLY_HTML) || |
1401 (type == SAVE_PAGE_TYPE_AS_MHTML) || | 1401 (type == SAVE_PAGE_TYPE_AS_MHTML) || |
1402 (type == SAVE_PAGE_TYPE_AS_COMPLETE_HTML)) << type; | 1402 (type == SAVE_PAGE_TYPE_AS_COMPLETE_HTML)) << type; |
1403 // Ensure the filename is safe. | 1403 // Ensure the filename is safe. |
1404 saved_main_file_path_ = final_name; | 1404 saved_main_file_path_ = final_name; |
1405 // TODO(asanka): This call may block on IO and shouldn't be made | 1405 net::EnsureSafePortableFileName(std::string(), |
1406 // from the UI thread. See http://crbug.com/61827. | 1406 net::EXTENSION_OPTION_KEEP_EXISTING, |
1407 net::GenerateSafeFileName(web_contents()->GetContentsMimeType(), false, | 1407 &saved_main_file_path_); |
1408 &saved_main_file_path_); | |
1409 | 1408 |
1410 saved_main_directory_path_ = saved_main_file_path_.DirName(); | 1409 saved_main_directory_path_ = saved_main_file_path_.DirName(); |
1411 save_type_ = type; | 1410 save_type_ = type; |
1412 if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) { | 1411 if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) { |
1413 // Make new directory for saving complete file. | 1412 // Make new directory for saving complete file. |
1414 saved_main_directory_path_ = saved_main_directory_path_.Append( | 1413 saved_main_directory_path_ = saved_main_directory_path_.Append( |
1415 saved_main_file_path_.RemoveExtension().BaseName().value() + | 1414 saved_main_file_path_.RemoveExtension().BaseName().value() + |
1416 FILE_PATH_LITERAL("_files")); | 1415 FILE_PATH_LITERAL("_files")); |
1417 } | 1416 } |
1418 | 1417 |
(...skipping 15 matching lines...) Expand all Loading... |
1434 | 1433 |
1435 void SavePackage::FinalizeDownloadEntry() { | 1434 void SavePackage::FinalizeDownloadEntry() { |
1436 DCHECK(download_); | 1435 DCHECK(download_); |
1437 DCHECK(download_manager_); | 1436 DCHECK(download_manager_); |
1438 | 1437 |
1439 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1438 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
1440 StopObservation(); | 1439 StopObservation(); |
1441 } | 1440 } |
1442 | 1441 |
1443 } // namespace content | 1442 } // namespace content |
OLD | NEW |