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/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // TODO(fgorski): Figure out if the actual URL can be different at | 114 // TODO(fgorski): Figure out if the actual URL can be different at |
115 // the end of MHTML generation. Perhaps we should pull it out after the MHTML | 115 // the end of MHTML generation. Perhaps we should pull it out after the MHTML |
116 // is generated. | 116 // is generated. |
117 GURL url(web_contents_->GetLastCommittedURL()); | 117 GURL url(web_contents_->GetLastCommittedURL()); |
118 base::string16 title(web_contents_->GetTitle()); | 118 base::string16 title(web_contents_->GetTitle()); |
119 base::FilePath file_path( | 119 base::FilePath file_path( |
120 archives_dir.Append( | 120 archives_dir.Append( |
121 GenerateFileName(url, base::UTF16ToUTF8(title), archive_id))); | 121 GenerateFileName(url, base::UTF16ToUTF8(title), archive_id))); |
122 | 122 |
123 content::MHTMLGenerationParams params(file_path); | 123 content::MHTMLGenerationParams params(file_path); |
124 params.cache_control_policy = | 124 params.cache_control_policy = blink::WebFrameSerializerCacheControlPolicy:: |
125 content::MHTMLCacheControlPolicy::FAIL_FOR_NO_STORE_MAIN_FRAME; | 125 SkipAnyFrameOrResourceMarkedNoStore; |
126 params.use_binary_encoding = true; | 126 params.use_binary_encoding = true; |
127 | 127 |
128 web_contents_->GenerateMHTML( | 128 web_contents_->GenerateMHTML( |
129 params, base::Bind(&OfflinePageMHTMLArchiver::OnGenerateMHTMLDone, | 129 params, base::Bind(&OfflinePageMHTMLArchiver::OnGenerateMHTMLDone, |
130 weak_ptr_factory_.GetWeakPtr(), url, file_path)); | 130 weak_ptr_factory_.GetWeakPtr(), url, file_path)); |
131 } | 131 } |
132 | 132 |
133 void OfflinePageMHTMLArchiver::OnGenerateMHTMLDone( | 133 void OfflinePageMHTMLArchiver::OnGenerateMHTMLDone( |
134 const GURL& url, | 134 const GURL& url, |
135 const base::FilePath& file_path, | 135 const base::FilePath& file_path, |
(...skipping 18 matching lines...) Expand all Loading... |
154 } | 154 } |
155 | 155 |
156 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { | 156 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { |
157 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); | 157 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); |
158 base::ThreadTaskRunnerHandle::Get()->PostTask( | 158 base::ThreadTaskRunnerHandle::Get()->PostTask( |
159 FROM_HERE, | 159 FROM_HERE, |
160 base::Bind(callback_, this, result, GURL(), base::FilePath(), 0)); | 160 base::Bind(callback_, this, result, GURL(), base::FilePath(), 0)); |
161 } | 161 } |
162 | 162 |
163 } // namespace offline_pages | 163 } // namespace offline_pages |
OLD | NEW |