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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc

Issue 2540483002: Allow Offline MHTML save operations to succeed even with missing frames.
Patch Set: Address code review comments. Created 4 years 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
« no previous file with comments | « no previous file | content/browser/download/mhtml_generation_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 5 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // the end of MHTML generation. Perhaps we should pull it out after the MHTML 127 // the end of MHTML generation. Perhaps we should pull it out after the MHTML
128 // is generated. 128 // is generated.
129 GURL url(web_contents_->GetLastCommittedURL()); 129 GURL url(web_contents_->GetLastCommittedURL());
130 base::string16 title(web_contents_->GetTitle()); 130 base::string16 title(web_contents_->GetTitle());
131 base::FilePath file_path( 131 base::FilePath file_path(
132 archives_dir.Append( 132 archives_dir.Append(
133 GenerateFileName(url, base::UTF16ToUTF8(title), archive_id))); 133 GenerateFileName(url, base::UTF16ToUTF8(title), archive_id)));
134 134
135 content::MHTMLGenerationParams params(file_path); 135 content::MHTMLGenerationParams params(file_path);
136 params.use_binary_encoding = true; 136 params.use_binary_encoding = true;
137 params.ignore_missing_frames = true;
137 138
138 web_contents_->GenerateMHTML( 139 web_contents_->GenerateMHTML(
139 params, 140 params,
140 base::Bind(&OfflinePageMHTMLArchiver::OnGenerateMHTMLDone, 141 base::Bind(&OfflinePageMHTMLArchiver::OnGenerateMHTMLDone,
141 weak_ptr_factory_.GetWeakPtr(), url, file_path, title)); 142 weak_ptr_factory_.GetWeakPtr(), url, file_path, title));
142 } 143 }
143 144
144 void OfflinePageMHTMLArchiver::OnGenerateMHTMLDone( 145 void OfflinePageMHTMLArchiver::OnGenerateMHTMLDone(
145 const GURL& url, 146 const GURL& url,
146 const base::FilePath& file_path, 147 const base::FilePath& file_path,
(...skipping 24 matching lines...) Expand all
171 } 172 }
172 173
173 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { 174 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) {
174 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); 175 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED);
175 base::ThreadTaskRunnerHandle::Get()->PostTask( 176 base::ThreadTaskRunnerHandle::Get()->PostTask(
176 FROM_HERE, base::Bind(callback_, this, result, GURL(), base::FilePath(), 177 FROM_HERE, base::Bind(callback_, this, result, GURL(), base::FilePath(),
177 base::string16(), 0)); 178 base::string16(), 0));
178 } 179 }
179 180
180 } // namespace offline_pages 181 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/mhtml_generation_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698