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 |
266 // Create the download item, and add ourself as an observer. | 269 // Create the download item, and add ourself as an observer. |
267 download_ = new DownloadItem(download_manager_, | 270 download_ = new DownloadItem(download_manager_, |
268 saved_main_file_path_, | 271 saved_main_file_path_, |
269 page_url_, | 272 page_url_, |
270 browser_context->IsOffTheRecord(), | 273 browser_context->IsOffTheRecord(), |
271 download_manager_->GetNextId()); | 274 rdh->download_file_manager()->GetNextId()); |
272 download_->AddObserver(this); | 275 download_->AddObserver(this); |
273 | 276 |
274 // Transfer ownership to the download manager. | 277 // Transfer ownership to the download manager. |
275 download_manager_->SavePageDownloadStarted(download_); | 278 download_manager_->SavePageDownloadStarted(download_); |
276 | 279 |
277 // Check save type and process the save page job. | 280 // Check save type and process the save page job. |
278 if (save_type_ == SAVE_AS_COMPLETE_HTML) { | 281 if (save_type_ == SAVE_AS_COMPLETE_HTML) { |
279 // Get directory | 282 // Get directory |
280 DCHECK(!saved_main_directory_path_.empty()); | 283 DCHECK(!saved_main_directory_path_.empty()); |
281 GetAllSavableResourceLinksForCurrentPage(); | 284 GetAllSavableResourceLinksForCurrentPage(); |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 StopObservation(); | 1280 StopObservation(); |
1278 } | 1281 } |
1279 | 1282 |
1280 void SavePackage::FinalizeDownloadEntry() { | 1283 void SavePackage::FinalizeDownloadEntry() { |
1281 DCHECK(download_); | 1284 DCHECK(download_); |
1282 DCHECK(download_manager_); | 1285 DCHECK(download_manager_); |
1283 | 1286 |
1284 download_manager_->SavePageDownloadFinished(download_); | 1287 download_manager_->SavePageDownloadFinished(download_); |
1285 StopObservation(); | 1288 StopObservation(); |
1286 } | 1289 } |
OLD | NEW |