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" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/i18n/file_util_icu.h" | 12 #include "base/i18n/file_util_icu.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/string_piece.h" | 16 #include "base/string_piece.h" |
17 #include "base/string_split.h" | 17 #include "base/string_split.h" |
18 #include "base/sys_string_conversions.h" | 18 #include "base/sys_string_conversions.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
21 #include "content/browser/browser_context.h" | 21 #include "content/browser/browser_context.h" |
22 #include "content/browser/download/download_file_manager.h" | 22 #include "content/browser/download/download_file_manager.h" |
23 #include "content/browser/download/download_item.h" | 23 #include "content/browser/download/download_item_impl.h" |
24 #include "content/browser/download/download_manager.h" | 24 #include "content/browser/download/download_manager.h" |
25 #include "content/browser/download/save_file.h" | 25 #include "content/browser/download/save_file.h" |
26 #include "content/browser/download/save_file_manager.h" | 26 #include "content/browser/download/save_file_manager.h" |
27 #include "content/browser/download/save_item.h" | 27 #include "content/browser/download/save_item.h" |
28 #include "content/browser/renderer_host/render_process_host.h" | 28 #include "content/browser/renderer_host/render_process_host.h" |
29 #include "content/browser/renderer_host/render_view_host.h" | 29 #include "content/browser/renderer_host/render_view_host.h" |
30 #include "content/browser/renderer_host/render_view_host_delegate.h" | 30 #include "content/browser/renderer_host/render_view_host_delegate.h" |
31 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 31 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
32 #include "content/browser/resource_context.h" | 32 #include "content/browser/resource_context.h" |
33 #include "content/browser/tab_contents/tab_contents.h" | 33 #include "content/browser/tab_contents/tab_contents.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Create the download item, and add ourself as an observer. |
269 download_ = new DownloadItem(download_manager_, | 269 download_ = new DownloadItemImpl(download_manager_, |
270 saved_main_file_path_, | 270 saved_main_file_path_, |
271 page_url_, | 271 page_url_, |
272 browser_context->IsOffTheRecord(), | 272 browser_context->IsOffTheRecord(), |
273 download_manager_->GetNextId()); | 273 download_manager_->GetNextId()); |
274 download_->AddObserver(this); | 274 download_->AddObserver(this); |
275 | 275 |
276 // Transfer ownership to the download manager. | 276 // Transfer ownership to the download manager. |
277 download_manager_->SavePageDownloadStarted(download_); | 277 download_manager_->SavePageDownloadStarted(download_); |
278 | 278 |
279 // Check save type and process the save page job. | 279 // Check save type and process the save page job. |
280 if (save_type_ == SAVE_AS_COMPLETE_HTML) { | 280 if (save_type_ == SAVE_AS_COMPLETE_HTML) { |
281 // Get directory | 281 // Get directory |
282 DCHECK(!saved_main_directory_path_.empty()); | 282 DCHECK(!saved_main_directory_path_.empty()); |
283 GetAllSavableResourceLinksForCurrentPage(); | 283 GetAllSavableResourceLinksForCurrentPage(); |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 StopObservation(); | 1279 StopObservation(); |
1280 } | 1280 } |
1281 | 1281 |
1282 void SavePackage::FinalizeDownloadEntry() { | 1282 void SavePackage::FinalizeDownloadEntry() { |
1283 DCHECK(download_); | 1283 DCHECK(download_); |
1284 DCHECK(download_manager_); | 1284 DCHECK(download_manager_); |
1285 | 1285 |
1286 download_manager_->SavePageDownloadFinished(download_); | 1286 download_manager_->SavePageDownloadFinished(download_); |
1287 StopObservation(); | 1287 StopObservation(); |
1288 } | 1288 } |
OLD | NEW |