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 12 matching lines...) Expand all Loading... | |
23 #include "content/browser/download/download_file_manager.h" | 23 #include "content/browser/download/download_file_manager.h" |
24 #include "content/browser/download/download_item.h" | 24 #include "content/browser/download/download_item.h" |
25 #include "content/browser/download/download_manager.h" | 25 #include "content/browser/download/download_manager.h" |
26 #include "content/browser/download/save_file.h" | 26 #include "content/browser/download/save_file.h" |
27 #include "content/browser/download/save_file_manager.h" | 27 #include "content/browser/download/save_file_manager.h" |
28 #include "content/browser/download/save_item.h" | 28 #include "content/browser/download/save_item.h" |
29 #include "content/browser/renderer_host/render_process_host.h" | 29 #include "content/browser/renderer_host/render_process_host.h" |
30 #include "content/browser/renderer_host/render_view_host.h" | 30 #include "content/browser/renderer_host/render_view_host.h" |
31 #include "content/browser/renderer_host/render_view_host_delegate.h" | 31 #include "content/browser/renderer_host/render_view_host_delegate.h" |
32 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 32 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
33 #include "content/browser/resource_context.h" | |
33 #include "content/browser/tab_contents/tab_contents.h" | 34 #include "content/browser/tab_contents/tab_contents.h" |
34 #include "content/common/view_messages.h" | 35 #include "content/common/view_messages.h" |
35 #include "content/public/browser/content_browser_client.h" | 36 #include "content/public/browser/content_browser_client.h" |
36 #include "content/public/browser/download_manager_delegate.h" | 37 #include "content/public/browser/download_manager_delegate.h" |
37 #include "content/public/common/url_constants.h" | 38 #include "content/public/common/url_constants.h" |
38 #include "net/base/io_buffer.h" | 39 #include "net/base/io_buffer.h" |
39 #include "net/base/mime_util.h" | 40 #include "net/base/mime_util.h" |
40 #include "net/base/net_util.h" | 41 #include "net/base/net_util.h" |
41 #include "net/url_request/url_request_context.h" | 42 #include "net/url_request/url_request_context.h" |
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClie nt.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClie nt.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 wait_state_ = START_PROCESS; | 258 wait_state_ = START_PROCESS; |
258 | 259 |
259 // Initialize the request context and resource dispatcher. | 260 // Initialize the request context and resource dispatcher. |
260 content::BrowserContext* browser_context = tab_contents()->browser_context(); | 261 content::BrowserContext* browser_context = tab_contents()->browser_context(); |
261 if (!browser_context) { | 262 if (!browser_context) { |
262 NOTREACHED(); | 263 NOTREACHED(); |
263 return false; | 264 return false; |
264 } | 265 } |
265 | 266 |
266 // Create the download item, and add ourself as an observer. | 267 // Create the download item, and add ourself as an observer. |
267 download_ = new DownloadItem(download_manager_, | 268 download_ = new DownloadItem( |
268 saved_main_file_path_, | 269 download_manager_, |
269 page_url_, | 270 saved_main_file_path_, |
270 browser_context->IsOffTheRecord(), | 271 page_url_, |
271 download_manager_->GetNextId()); | 272 browser_context->IsOffTheRecord(), |
273 browser_context->GetDownloadManager()->GetNextId()); | |
Randy Smith (Not in Mondays)
2011/10/28 13:35:44
nit: Why the shift to browser_context?
benjhayden
2011/10/28 14:37:55
Done.
| |
272 download_->AddObserver(this); | 274 download_->AddObserver(this); |
273 | 275 |
274 // Transfer ownership to the download manager. | 276 // Transfer ownership to the download manager. |
275 download_manager_->SavePageDownloadStarted(download_); | 277 download_manager_->SavePageDownloadStarted(download_); |
276 | 278 |
277 // Check save type and process the save page job. | 279 // Check save type and process the save page job. |
278 if (save_type_ == SAVE_AS_COMPLETE_HTML) { | 280 if (save_type_ == SAVE_AS_COMPLETE_HTML) { |
279 // Get directory | 281 // Get directory |
280 DCHECK(!saved_main_directory_path_.empty()); | 282 DCHECK(!saved_main_directory_path_.empty()); |
281 GetAllSavableResourceLinksForCurrentPage(); | 283 GetAllSavableResourceLinksForCurrentPage(); |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1277 StopObservation(); | 1279 StopObservation(); |
1278 } | 1280 } |
1279 | 1281 |
1280 void SavePackage::FinalizeDownloadEntry() { | 1282 void SavePackage::FinalizeDownloadEntry() { |
1281 DCHECK(download_); | 1283 DCHECK(download_); |
1282 DCHECK(download_manager_); | 1284 DCHECK(download_manager_); |
1283 | 1285 |
1284 download_manager_->SavePageDownloadFinished(download_); | 1286 download_manager_->SavePageDownloadFinished(download_); |
1285 StopObservation(); | 1287 StopObservation(); |
1286 } | 1288 } |
OLD | NEW |