| 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/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 256 |
| 257 wait_state_ = START_PROCESS; | 257 wait_state_ = START_PROCESS; |
| 258 | 258 |
| 259 // Initialize the request context and resource dispatcher. | 259 // Initialize the request context and resource dispatcher. |
| 260 content::BrowserContext* browser_context = tab_contents()->browser_context(); | 260 content::BrowserContext* browser_context = tab_contents()->browser_context(); |
| 261 if (!browser_context) { | 261 if (!browser_context) { |
| 262 NOTREACHED(); | 262 NOTREACHED(); |
| 263 return false; | 263 return false; |
| 264 } | 264 } |
| 265 | 265 |
| 266 ResourceDispatcherHost* rdh = | |
| 267 content::GetContentClient()->browser()->GetResourceDispatcherHost(); | |
| 268 | |
| 269 // Create the download item, and add ourself as an observer. | 266 // Create the download item, and add ourself as an observer. |
| 270 download_ = new DownloadItem(download_manager_, | 267 download_ = new DownloadItem(download_manager_, |
| 271 saved_main_file_path_, | 268 saved_main_file_path_, |
| 272 page_url_, | 269 page_url_, |
| 273 browser_context->IsOffTheRecord(), | 270 browser_context->IsOffTheRecord(), |
| 274 rdh->download_file_manager()->GetNextId()); | 271 download_manager_->GetNextId()); |
| 275 download_->AddObserver(this); | 272 download_->AddObserver(this); |
| 276 | 273 |
| 277 // Transfer ownership to the download manager. | 274 // Transfer ownership to the download manager. |
| 278 download_manager_->SavePageDownloadStarted(download_); | 275 download_manager_->SavePageDownloadStarted(download_); |
| 279 | 276 |
| 280 // Check save type and process the save page job. | 277 // Check save type and process the save page job. |
| 281 if (save_type_ == SAVE_AS_COMPLETE_HTML) { | 278 if (save_type_ == SAVE_AS_COMPLETE_HTML) { |
| 282 // Get directory | 279 // Get directory |
| 283 DCHECK(!saved_main_directory_path_.empty()); | 280 DCHECK(!saved_main_directory_path_.empty()); |
| 284 GetAllSavableResourceLinksForCurrentPage(); | 281 GetAllSavableResourceLinksForCurrentPage(); |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 StopObservation(); | 1277 StopObservation(); |
| 1281 } | 1278 } |
| 1282 | 1279 |
| 1283 void SavePackage::FinalizeDownloadEntry() { | 1280 void SavePackage::FinalizeDownloadEntry() { |
| 1284 DCHECK(download_); | 1281 DCHECK(download_); |
| 1285 DCHECK(download_manager_); | 1282 DCHECK(download_manager_); |
| 1286 | 1283 |
| 1287 download_manager_->SavePageDownloadFinished(download_); | 1284 download_manager_->SavePageDownloadFinished(download_); |
| 1288 StopObservation(); | 1285 StopObservation(); |
| 1289 } | 1286 } |
| OLD | NEW |