| OLD | NEW |
| 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 "chrome/browser/download/save_package.h" | 5 #include "chrome/browser/download/save_package.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 | 120 |
| 121 STLDeleteValues(&saved_success_items_); | 121 STLDeleteValues(&saved_success_items_); |
| 122 STLDeleteValues(&in_progress_items_); | 122 STLDeleteValues(&in_progress_items_); |
| 123 STLDeleteValues(&saved_failed_items_); | 123 STLDeleteValues(&saved_failed_items_); |
| 124 | 124 |
| 125 if (download_) { | 125 if (download_) { |
| 126 // We call this to remove the view from the shelf. It will invoke | 126 // We call this to remove the view from the shelf. It will invoke |
| 127 // DownloadManager::RemoveDownload, but since the fake DownloadItem is not | 127 // DownloadManager::RemoveDownload, but since the fake DownloadItem is not |
| 128 // owned by DownloadManager, it will do nothing to our fake item. | 128 // owned by DownloadManager, it will do nothing to our fake item. |
| 129 download_->Remove(); | 129 download_->Remove(false); |
| 130 delete download_; | 130 delete download_; |
| 131 download_ = NULL; | 131 download_ = NULL; |
| 132 } | 132 } |
| 133 file_manager_ = NULL; | 133 file_manager_ = NULL; |
| 134 } | 134 } |
| 135 | 135 |
| 136 // Cancel all in progress request, might be called by user or internal error. | 136 // Cancel all in progress request, might be called by user or internal error. |
| 137 void SavePackage::Cancel(bool user_action) { | 137 void SavePackage::Cancel(bool user_action) { |
| 138 if (!canceled()) { | 138 if (!canceled()) { |
| 139 if (user_action) | 139 if (user_action) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 167 return false; | 167 return false; |
| 168 } | 168 } |
| 169 | 169 |
| 170 file_manager_ = rdh->save_file_manager(); | 170 file_manager_ = rdh->save_file_manager(); |
| 171 if (!file_manager_) { | 171 if (!file_manager_) { |
| 172 NOTREACHED(); | 172 NOTREACHED(); |
| 173 return false; | 173 return false; |
| 174 } | 174 } |
| 175 | 175 |
| 176 // Create the fake DownloadItem and display the view. | 176 // Create the fake DownloadItem and display the view. |
| 177 download_ = new DownloadItem(1, saved_main_file_path_, | 177 download_ = new DownloadItem(1, saved_main_file_path_, page_url_, |
| 178 page_url_, Time::Now(), 0, -1, -1); | 178 std::wstring(), Time::Now(), 0, -1, -1, false); |
| 179 download_->set_manager(web_contents_->profile()->GetDownloadManager()); | 179 download_->set_manager(web_contents_->profile()->GetDownloadManager()); |
| 180 DownloadShelfView* shelf = web_contents_->GetDownloadShelfView(); | 180 DownloadShelfView* shelf = web_contents_->GetDownloadShelfView(); |
| 181 shelf->AddDownloadView(new DownloadItemView( | 181 shelf->AddDownloadView(new DownloadItemView( |
| 182 download_, shelf, new SavePageModel(this, download_))); | 182 download_, shelf, new SavePageModel(this, download_))); |
| 183 web_contents_->SetDownloadShelfVisible(true); | 183 web_contents_->SetDownloadShelfVisible(true); |
| 184 | 184 |
| 185 // Check save type and process the save page job. | 185 // Check save type and process the save page job. |
| 186 if (save_type_ == SAVE_AS_COMPLETE_HTML) { | 186 if (save_type_ == SAVE_AS_COMPLETE_HTML) { |
| 187 // Get directory | 187 // Get directory |
| 188 DCHECK(!saved_main_directory_path_.empty()); | 188 DCHECK(!saved_main_directory_path_.empty()); |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 if (available_length > dir_path_length) { | 1054 if (available_length > dir_path_length) { |
| 1055 *pure_file_name = | 1055 *pure_file_name = |
| 1056 pure_file_name->substr(0, available_length - dir_path_length); | 1056 pure_file_name->substr(0, available_length - dir_path_length); |
| 1057 return true; | 1057 return true; |
| 1058 } else { | 1058 } else { |
| 1059 pure_file_name->clear(); | 1059 pure_file_name->clear(); |
| 1060 return false; | 1060 return false; |
| 1061 } | 1061 } |
| 1062 } | 1062 } |
| 1063 | 1063 |
| OLD | NEW |