Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: content/browser/download/save_package.cc

Issue 1947263004: Introduces a new MHTML generation parameter specifying different behvaior for cache-control headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work on compile. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/i18n/file_util_icu.h" 13 #include "base/i18n/file_util_icu.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
19 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
20 #include "base/strings/sys_string_conversions.h" 20 #include "base/strings/sys_string_conversions.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "components/url_formatter/url_formatter.h" 24 #include "components/url_formatter/url_formatter.h"
25 #include "content/browser/bad_message.h" 25 #include "content/browser/bad_message.h"
26 #include "content/browser/download/download_item_impl.h" 26 #include "content/browser/download/download_item_impl.h"
27 #include "content/browser/download/download_manager_impl.h" 27 #include "content/browser/download/download_manager_impl.h"
28 #include "content/browser/download/download_stats.h" 28 #include "content/browser/download/download_stats.h"
29 #include "content/browser/download/mhtml_generation_manager.h"
Łukasz Anforowicz 2016/05/12 18:56:48 Is the new include needed? I thought that save_pa
dewittj 2016/05/12 22:58:01 Done. Yes, I went through quite a few revisions h
29 #include "content/browser/download/save_file.h" 30 #include "content/browser/download/save_file.h"
30 #include "content/browser/download/save_file_manager.h" 31 #include "content/browser/download/save_file_manager.h"
31 #include "content/browser/download/save_item.h" 32 #include "content/browser/download/save_item.h"
32 #include "content/browser/frame_host/frame_tree.h" 33 #include "content/browser/frame_host/frame_tree.h"
33 #include "content/browser/frame_host/frame_tree_node.h" 34 #include "content/browser/frame_host/frame_tree_node.h"
34 #include "content/browser/frame_host/render_frame_host_impl.h" 35 #include "content/browser/frame_host/render_frame_host_impl.h"
35 #include "content/browser/loader/resource_dispatcher_host_impl.h" 36 #include "content/browser/loader/resource_dispatcher_host_impl.h"
36 #include "content/browser/renderer_host/render_process_host_impl.h" 37 #include "content/browser/renderer_host/render_process_host_impl.h"
37 #include "content/browser/renderer_host/render_view_host_delegate.h" 38 #include "content/browser/renderer_host/render_view_host_delegate.h"
38 #include "content/browser/renderer_host/render_view_host_impl.h" 39 #include "content/browser/renderer_host/render_view_host_impl.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698