| 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" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 18 #include "chrome/browser/ssl/security_state_tab_helper.h" |
| 19 #include "components/security_state/security_state_model.h" | 19 #include "components/security_state/core/security_state.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/mhtml_generation_params.h" | 22 #include "content/public/common/mhtml_generation_params.h" |
| 23 #include "net/base/filename_util.h" | 23 #include "net/base/filename_util.h" |
| 24 | 24 |
| 25 namespace offline_pages { | 25 namespace offline_pages { |
| 26 namespace { | 26 namespace { |
| 27 const base::FilePath::CharType kMHTMLExtension[] = FILE_PATH_LITERAL("mhtml"); | 27 const base::FilePath::CharType kMHTMLExtension[] = FILE_PATH_LITERAL("mhtml"); |
| 28 const base::FilePath::CharType kDefaultFileName[] = | 28 const base::FilePath::CharType kDefaultFileName[] = |
| 29 FILE_PATH_LITERAL("offline_page"); | 29 FILE_PATH_LITERAL("offline_page"); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 ArchiverResult::ERROR_ARCHIVE_CREATION_FAILED)); | 153 ArchiverResult::ERROR_ARCHIVE_CREATION_FAILED)); |
| 154 } else { | 154 } else { |
| 155 base::ThreadTaskRunnerHandle::Get()->PostTask( | 155 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 156 FROM_HERE, | 156 FROM_HERE, |
| 157 base::Bind(callback_, this, ArchiverResult::SUCCESSFULLY_CREATED, url, | 157 base::Bind(callback_, this, ArchiverResult::SUCCESSFULLY_CREATED, url, |
| 158 file_path, title, file_size)); | 158 file_path, title, file_size)); |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 bool OfflinePageMHTMLArchiver::HasConnectionSecurityError() { | 162 bool OfflinePageMHTMLArchiver::HasConnectionSecurityError() { |
| 163 ChromeSecurityStateModelClient::CreateForWebContents(web_contents_); | 163 SecurityStateTabHelper::CreateForWebContents(web_contents_); |
| 164 ChromeSecurityStateModelClient* model_client = | 164 SecurityStateTabHelper* helper = |
| 165 ChromeSecurityStateModelClient::FromWebContents(web_contents_); | 165 SecurityStateTabHelper::FromWebContents(web_contents_); |
| 166 DCHECK(model_client); | 166 DCHECK(helper); |
| 167 security_state::SecurityStateModel::SecurityInfo security_info; | 167 security_state::SecurityInfo security_info; |
| 168 model_client->GetSecurityInfo(&security_info); | 168 helper->GetSecurityInfo(&security_info); |
| 169 return security_state::SecurityStateModel::SecurityLevel::DANGEROUS == | 169 return security_state::SecurityLevel::DANGEROUS == |
| 170 security_info.security_level; | 170 security_info.security_level; |
| 171 } | 171 } |
| 172 | 172 |
| 173 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { | 173 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { |
| 174 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); | 174 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); |
| 175 base::ThreadTaskRunnerHandle::Get()->PostTask( | 175 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 176 FROM_HERE, base::Bind(callback_, this, result, GURL(), base::FilePath(), | 176 FROM_HERE, base::Bind(callback_, this, result, GURL(), base::FilePath(), |
| 177 base::string16(), 0)); | 177 base::string16(), 0)); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace offline_pages | 180 } // namespace offline_pages |
| OLD | NEW |