| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "content/public/browser/browser_context.h" | 41 #include "content/public/browser/browser_context.h" |
| 42 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
| 43 #include "content/public/browser/content_browser_client.h" | 43 #include "content/public/browser/content_browser_client.h" |
| 44 #include "content/public/browser/download_manager_delegate.h" | 44 #include "content/public/browser/download_manager_delegate.h" |
| 45 #include "content/public/browser/navigation_entry.h" | 45 #include "content/public/browser/navigation_entry.h" |
| 46 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
| 47 #include "content/public/browser/notification_types.h" | 47 #include "content/public/browser/notification_types.h" |
| 48 #include "content/public/browser/render_frame_host.h" | 48 #include "content/public/browser/render_frame_host.h" |
| 49 #include "content/public/browser/resource_context.h" | 49 #include "content/public/browser/resource_context.h" |
| 50 #include "content/public/browser/web_contents.h" | 50 #include "content/public/browser/web_contents.h" |
| 51 #include "content/public/common/mhtml_generation_params.h" |
| 51 #include "net/base/filename_util.h" | 52 #include "net/base/filename_util.h" |
| 52 #include "net/base/io_buffer.h" | 53 #include "net/base/io_buffer.h" |
| 53 #include "net/base/mime_util.h" | 54 #include "net/base/mime_util.h" |
| 54 #include "net/url_request/url_request_context.h" | 55 #include "net/url_request/url_request_context.h" |
| 55 #include "url/url_constants.h" | 56 #include "url/url_constants.h" |
| 56 | 57 |
| 57 namespace content { | 58 namespace content { |
| 58 namespace { | 59 namespace { |
| 59 | 60 |
| 60 // Generates unique ids for SavePackage::unique_id_ field. | 61 // Generates unique ids for SavePackage::unique_id_ field. |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // Confirm above didn't delete the tab out from under us. | 332 // Confirm above didn't delete the tab out from under us. |
| 332 if (!download_created_callback.is_null()) | 333 if (!download_created_callback.is_null()) |
| 333 download_created_callback.Run(download_); | 334 download_created_callback.Run(download_); |
| 334 | 335 |
| 335 // Check save type and process the save page job. | 336 // Check save type and process the save page job. |
| 336 if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) { | 337 if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) { |
| 337 // Get directory | 338 // Get directory |
| 338 DCHECK(!saved_main_directory_path_.empty()); | 339 DCHECK(!saved_main_directory_path_.empty()); |
| 339 GetSavableResourceLinks(); | 340 GetSavableResourceLinks(); |
| 340 } else if (save_type_ == SAVE_PAGE_TYPE_AS_MHTML) { | 341 } else if (save_type_ == SAVE_PAGE_TYPE_AS_MHTML) { |
| 342 MHTMLGenerationParams mhtml_generation_params(saved_main_file_path_); |
| 341 web_contents()->GenerateMHTML( | 343 web_contents()->GenerateMHTML( |
| 342 saved_main_file_path_, false /* use_binary_encoding */, | 344 mhtml_generation_params, |
| 343 base::Bind(&SavePackage::OnMHTMLGenerated, this)); | 345 base::Bind(&SavePackage::OnMHTMLGenerated, this)); |
| 344 } else { | 346 } else { |
| 345 DCHECK_EQ(SAVE_PAGE_TYPE_AS_ONLY_HTML, save_type_); | 347 DCHECK_EQ(SAVE_PAGE_TYPE_AS_ONLY_HTML, save_type_); |
| 346 wait_state_ = NET_FILES; | 348 wait_state_ = NET_FILES; |
| 347 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? | 349 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? |
| 348 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : | 350 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : |
| 349 SaveFileCreateInfo::SAVE_FILE_FROM_NET; | 351 SaveFileCreateInfo::SAVE_FILE_FROM_NET; |
| 350 // Add this item to waiting list. | 352 // Add this item to waiting list. |
| 351 waiting_item_queue_.push_back( | 353 waiting_item_queue_.push_back( |
| 352 new SaveItem(page_url_, Referrer(), this, save_source, | 354 new SaveItem(page_url_, Referrer(), this, save_source, |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 } | 1496 } |
| 1495 | 1497 |
| 1496 void SavePackage::FinalizeDownloadEntry() { | 1498 void SavePackage::FinalizeDownloadEntry() { |
| 1497 DCHECK(download_); | 1499 DCHECK(download_); |
| 1498 | 1500 |
| 1499 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1501 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
| 1500 StopObservation(); | 1502 StopObservation(); |
| 1501 } | 1503 } |
| 1502 | 1504 |
| 1503 } // namespace content | 1505 } // namespace content |
| OLD | NEW |