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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 258 |
259 wait_state_ = START_PROCESS; | 259 wait_state_ = START_PROCESS; |
260 | 260 |
261 // Initialize the request context and resource dispatcher. | 261 // Initialize the request context and resource dispatcher. |
262 content::BrowserContext* browser_context = tab_contents()->browser_context(); | 262 content::BrowserContext* browser_context = tab_contents()->browser_context(); |
263 if (!browser_context) { | 263 if (!browser_context) { |
264 NOTREACHED(); | 264 NOTREACHED(); |
265 return false; | 265 return false; |
266 } | 266 } |
267 | 267 |
268 // Create the download item, and add ourself as an observer. | 268 // The download manager keeps ownership but adds us as an observer. |
269 download_ = new DownloadItemImpl(download_manager_, | 269 download_ = download_manager_->CreateSavePackageDownloadItem( |
270 saved_main_file_path_, | 270 saved_main_file_path_, page_url_, |
271 page_url_, | 271 browser_context->IsOffTheRecord(), this); |
272 browser_context->IsOffTheRecord(), | |
273 download_manager_->GetNextId()); | |
274 download_->AddObserver(this); | |
275 | |
276 // Transfer ownership to the download manager. | |
277 download_manager_->SavePageDownloadStarted(download_); | |
278 | 272 |
279 // Check save type and process the save page job. | 273 // Check save type and process the save page job. |
280 if (save_type_ == SAVE_AS_COMPLETE_HTML) { | 274 if (save_type_ == SAVE_AS_COMPLETE_HTML) { |
281 // Get directory | 275 // Get directory |
282 DCHECK(!saved_main_directory_path_.empty()); | 276 DCHECK(!saved_main_directory_path_.empty()); |
283 GetAllSavableResourceLinksForCurrentPage(); | 277 GetAllSavableResourceLinksForCurrentPage(); |
284 } else { | 278 } else { |
285 wait_state_ = NET_FILES; | 279 wait_state_ = NET_FILES; |
286 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? | 280 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? |
287 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : | 281 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 StopObservation(); | 1275 StopObservation(); |
1282 } | 1276 } |
1283 | 1277 |
1284 void SavePackage::FinalizeDownloadEntry() { | 1278 void SavePackage::FinalizeDownloadEntry() { |
1285 DCHECK(download_); | 1279 DCHECK(download_); |
1286 DCHECK(download_manager_); | 1280 DCHECK(download_manager_); |
1287 | 1281 |
1288 download_manager_->SavePageDownloadFinished(download_); | 1282 download_manager_->SavePageDownloadFinished(download_); |
1289 StopObservation(); | 1283 StopObservation(); |
1290 } | 1284 } |
OLD | NEW |