OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 261 |
262 wait_state_ = START_PROCESS; | 262 wait_state_ = START_PROCESS; |
263 | 263 |
264 // Initialize the request context and resource dispatcher. | 264 // Initialize the request context and resource dispatcher. |
265 content::BrowserContext* browser_context = tab_contents()->browser_context(); | 265 content::BrowserContext* browser_context = tab_contents()->browser_context(); |
266 if (!browser_context) { | 266 if (!browser_context) { |
267 NOTREACHED(); | 267 NOTREACHED(); |
268 return false; | 268 return false; |
269 } | 269 } |
270 | 270 |
271 // The download manager keeps ownership but adds us as an observer. | 271 // Create the download item, and add ourself as an observer. |
272 download_ = download_manager_->CreateSavePackageDownloadItem( | 272 download_ = new DownloadItemImpl(download_manager_, |
273 saved_main_file_path_, page_url_, | 273 saved_main_file_path_, |
274 browser_context->IsOffTheRecord(), this); | 274 page_url_, |
| 275 browser_context->IsOffTheRecord(), |
| 276 download_manager_->GetNextId()); |
| 277 download_->AddObserver(this); |
| 278 |
| 279 // Transfer ownership to the download manager. |
| 280 download_manager_->SavePageDownloadStarted(download_); |
275 | 281 |
276 // Check save type and process the save page job. | 282 // Check save type and process the save page job. |
277 if (save_type_ == SAVE_AS_COMPLETE_HTML) { | 283 if (save_type_ == SAVE_AS_COMPLETE_HTML) { |
278 // Get directory | 284 // Get directory |
279 DCHECK(!saved_main_directory_path_.empty()); | 285 DCHECK(!saved_main_directory_path_.empty()); |
280 GetAllSavableResourceLinksForCurrentPage(); | 286 GetAllSavableResourceLinksForCurrentPage(); |
281 } else { | 287 } else { |
282 wait_state_ = NET_FILES; | 288 wait_state_ = NET_FILES; |
283 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? | 289 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? |
284 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : | 290 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 StopObservation(); | 1290 StopObservation(); |
1285 } | 1291 } |
1286 | 1292 |
1287 void SavePackage::FinalizeDownloadEntry() { | 1293 void SavePackage::FinalizeDownloadEntry() { |
1288 DCHECK(download_); | 1294 DCHECK(download_); |
1289 DCHECK(download_manager_); | 1295 DCHECK(download_manager_); |
1290 | 1296 |
1291 download_manager_->SavePageDownloadFinished(download_); | 1297 download_manager_->SavePageDownloadFinished(download_); |
1292 StopObservation(); | 1298 StopObservation(); |
1293 } | 1299 } |
OLD | NEW |