| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 | 1002 |
| 1003 // Collect all saved success items. | 1003 // Collect all saved success items. |
| 1004 // SECURITY NOTE: We don't send *all* urls / local paths, but only | 1004 // SECURITY NOTE: We don't send *all* urls / local paths, but only |
| 1005 // those that the given frame had access to already (because it contained | 1005 // those that the given frame had access to already (because it contained |
| 1006 // the savable resources / subframes associated with save items). | 1006 // the savable resources / subframes associated with save items). |
| 1007 std::map<GURL, base::FilePath> url_to_local_path; | 1007 std::map<GURL, base::FilePath> url_to_local_path; |
| 1008 auto it = frame_tree_node_id_to_contained_save_items_.find( | 1008 auto it = frame_tree_node_id_to_contained_save_items_.find( |
| 1009 target_frame_tree_node_id); | 1009 target_frame_tree_node_id); |
| 1010 if (it != frame_tree_node_id_to_contained_save_items_.end()) { | 1010 if (it != frame_tree_node_id_to_contained_save_items_.end()) { |
| 1011 for (SaveItem* save_item : it->second) { | 1011 for (SaveItem* save_item : it->second) { |
| 1012 DCHECK(save_item->has_final_name()); | 1012 // Skip items that failed to save. |
| 1013 if (!save_item->has_final_name()) { |
| 1014 DCHECK_EQ(SaveItem::SaveState::COMPLETE, save_item->state()); |
| 1015 DCHECK(!save_item->success()); |
| 1016 continue; |
| 1017 } |
| 1018 |
| 1019 // Calculate the relative path for referring to the |save_item|. |
| 1013 base::FilePath local_path(base::FilePath::kCurrentDirectory); | 1020 base::FilePath local_path(base::FilePath::kCurrentDirectory); |
| 1014 if (target_tree_node->IsMainFrame()) { | 1021 if (target_tree_node->IsMainFrame()) { |
| 1015 local_path = local_path.Append(saved_main_directory_path_.BaseName()); | 1022 local_path = local_path.Append(saved_main_directory_path_.BaseName()); |
| 1016 } | 1023 } |
| 1017 local_path = local_path.Append(save_item->file_name()); | 1024 local_path = local_path.Append(save_item->file_name()); |
| 1018 url_to_local_path[save_item->url()] = local_path; | 1025 url_to_local_path[save_item->url()] = local_path; |
| 1019 } | 1026 } |
| 1020 } | 1027 } |
| 1021 | 1028 |
| 1022 // Ask target frame to serialize itself. | 1029 // Ask target frame to serialize itself. |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 | 1501 |
| 1495 void SavePackage::FinalizeDownloadEntry() { | 1502 void SavePackage::FinalizeDownloadEntry() { |
| 1496 DCHECK(download_); | 1503 DCHECK(download_); |
| 1497 DCHECK(download_manager_); | 1504 DCHECK(download_manager_); |
| 1498 | 1505 |
| 1499 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1506 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
| 1500 StopObservation(); | 1507 StopObservation(); |
| 1501 } | 1508 } |
| 1502 | 1509 |
| 1503 } // namespace content | 1510 } // namespace content |
| OLD | NEW |