| 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 // Create the download item, and add ourself as an observer. | 271 // The download manager keeps ownership but adds us as an observer. |
| 272 download_ = new DownloadItemImpl(download_manager_, | 272 download_ = download_manager_->CreateSavePackageDownloadItem( |
| 273 saved_main_file_path_, | 273 saved_main_file_path_, page_url_, |
| 274 page_url_, | 274 browser_context->IsOffTheRecord(), this); |
| 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_); | |
| 281 | 275 |
| 282 // Check save type and process the save page job. | 276 // Check save type and process the save page job. |
| 283 if (save_type_ == SAVE_AS_COMPLETE_HTML) { | 277 if (save_type_ == SAVE_AS_COMPLETE_HTML) { |
| 284 // Get directory | 278 // Get directory |
| 285 DCHECK(!saved_main_directory_path_.empty()); | 279 DCHECK(!saved_main_directory_path_.empty()); |
| 286 GetAllSavableResourceLinksForCurrentPage(); | 280 GetAllSavableResourceLinksForCurrentPage(); |
| 287 } else { | 281 } else { |
| 288 wait_state_ = NET_FILES; | 282 wait_state_ = NET_FILES; |
| 289 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? | 283 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? |
| 290 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : | 284 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 StopObservation(); | 1284 StopObservation(); |
| 1291 } | 1285 } |
| 1292 | 1286 |
| 1293 void SavePackage::FinalizeDownloadEntry() { | 1287 void SavePackage::FinalizeDownloadEntry() { |
| 1294 DCHECK(download_); | 1288 DCHECK(download_); |
| 1295 DCHECK(download_manager_); | 1289 DCHECK(download_manager_); |
| 1296 | 1290 |
| 1297 download_manager_->SavePageDownloadFinished(download_); | 1291 download_manager_->SavePageDownloadFinished(download_); |
| 1298 StopObservation(); | 1292 StopObservation(); |
| 1299 } | 1293 } |
| OLD | NEW |