| OLD | NEW |
| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // TODO(fgorski): Figure out if the actual URL can be different at | 126 // TODO(fgorski): Figure out if the actual URL can be different at |
| 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.cache_control_policy = blink::WebFrameSerializerCacheControlPolicy:: | |
| 137 SkipAnyFrameOrResourceMarkedNoStore; | |
| 138 params.use_binary_encoding = true; | 136 params.use_binary_encoding = true; |
| 139 | 137 |
| 140 web_contents_->GenerateMHTML( | 138 web_contents_->GenerateMHTML( |
| 141 params, base::Bind(&OfflinePageMHTMLArchiver::OnGenerateMHTMLDone, | 139 params, base::Bind(&OfflinePageMHTMLArchiver::OnGenerateMHTMLDone, |
| 142 weak_ptr_factory_.GetWeakPtr(), url, file_path)); | 140 weak_ptr_factory_.GetWeakPtr(), url, file_path)); |
| 143 } | 141 } |
| 144 | 142 |
| 145 void OfflinePageMHTMLArchiver::OnGenerateMHTMLDone( | 143 void OfflinePageMHTMLArchiver::OnGenerateMHTMLDone( |
| 146 const GURL& url, | 144 const GURL& url, |
| 147 const base::FilePath& file_path, | 145 const base::FilePath& file_path, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 169 } | 167 } |
| 170 | 168 |
| 171 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { | 169 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { |
| 172 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); | 170 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); |
| 173 base::ThreadTaskRunnerHandle::Get()->PostTask( | 171 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 174 FROM_HERE, | 172 FROM_HERE, |
| 175 base::Bind(callback_, this, result, GURL(), base::FilePath(), 0)); | 173 base::Bind(callback_, this, result, GURL(), base::FilePath(), 0)); |
| 176 } | 174 } |
| 177 | 175 |
| 178 } // namespace offline_pages | 176 } // namespace offline_pages |
| OLD | NEW |