| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ReportFailure(ArchiverResult::ERROR_CONTENT_UNAVAILABLE); | 80 ReportFailure(ArchiverResult::ERROR_CONTENT_UNAVAILABLE); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 | 83 |
| 84 if (!web_contents_->GetRenderViewHost()) { | 84 if (!web_contents_->GetRenderViewHost()) { |
| 85 DVLOG(1) << "RenderViewHost is not created yet. Can't create archive."; | 85 DVLOG(1) << "RenderViewHost is not created yet. Can't create archive."; |
| 86 ReportFailure(ArchiverResult::ERROR_CONTENT_UNAVAILABLE); | 86 ReportFailure(ArchiverResult::ERROR_CONTENT_UNAVAILABLE); |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 | 89 |
| 90 // TODO(fgorski): Figure out if the actual URL can be different at | |
| 91 // the end of MHTML generation. Perhaps we should pull it out after the MHTML | |
| 92 // is generated. | |
| 93 GURL url(web_contents_->GetLastCommittedURL()); | 90 GURL url(web_contents_->GetLastCommittedURL()); |
| 94 base::string16 title(web_contents_->GetTitle()); | 91 base::string16 title(web_contents_->GetTitle()); |
| 95 base::FilePath file_path( | 92 base::FilePath file_path( |
| 96 archives_dir.Append(base::GenerateGUID()).AddExtension(kMHTMLExtension)); | 93 archives_dir.Append(base::GenerateGUID()).AddExtension(kMHTMLExtension)); |
| 97 content::MHTMLGenerationParams params(file_path); | 94 content::MHTMLGenerationParams params(file_path); |
| 98 params.use_binary_encoding = true; | 95 params.use_binary_encoding = true; |
| 99 params.remove_popup_overlay = create_archive_params.remove_popup_overlay; | 96 params.remove_popup_overlay = create_archive_params.remove_popup_overlay; |
| 100 | 97 |
| 101 web_contents_->GenerateMHTML( | 98 web_contents_->GenerateMHTML( |
| 102 params, | 99 params, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 131 } |
| 135 | 132 |
| 136 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { | 133 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { |
| 137 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); | 134 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); |
| 138 base::ThreadTaskRunnerHandle::Get()->PostTask( | 135 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 139 FROM_HERE, base::Bind(callback_, this, result, GURL(), base::FilePath(), | 136 FROM_HERE, base::Bind(callback_, this, result, GURL(), base::FilePath(), |
| 140 base::string16(), 0)); | 137 base::string16(), 0)); |
| 141 } | 138 } |
| 142 | 139 |
| 143 } // namespace offline_pages | 140 } // namespace offline_pages |
| OLD | NEW |