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

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

Issue 2810913002: [Offline pages] Add new Error page failure status inside the MHTML archiver and update correspondin… (Closed)
Patch Set: Created 3 years, 8 months 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
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"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "chrome/browser/ssl/security_state_tab_helper.h" 16 #include "chrome/browser/ssl/security_state_tab_helper.h"
17 #include "components/security_state/core/security_state.h" 17 #include "components/security_state/core/security_state.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "content/public/common/mhtml_generation_params.h" 21 #include "content/public/common/mhtml_generation_params.h"
22 #include "content/public/common/page_type.h"
21 #include "net/base/filename_util.h" 23 #include "net/base/filename_util.h"
22 24
23 namespace offline_pages { 25 namespace offline_pages {
24 namespace { 26 namespace {
25 const base::FilePath::CharType kMHTMLExtension[] = FILE_PATH_LITERAL("mhtml"); 27 const base::FilePath::CharType kMHTMLExtension[] = FILE_PATH_LITERAL("mhtml");
26 28
27 void DeleteFileOnFileThread(const base::FilePath& file_path, 29 void DeleteFileOnFileThread(const base::FilePath& file_path,
28 const base::Closure& callback) { 30 const base::Closure& callback) {
29 content::BrowserThread::PostTaskAndReply( 31 content::BrowserThread::PostTaskAndReply(
30 content::BrowserThread::FILE, FROM_HERE, 32 content::BrowserThread::FILE, FROM_HERE,
(...skipping 25 matching lines...) Expand all
56 const CreateArchiveCallback& callback) { 58 const CreateArchiveCallback& callback) {
57 DCHECK(callback_.is_null()); 59 DCHECK(callback_.is_null());
58 DCHECK(!callback.is_null()); 60 DCHECK(!callback.is_null());
59 callback_ = callback; 61 callback_ = callback;
60 62
61 if (HasConnectionSecurityError()) { 63 if (HasConnectionSecurityError()) {
62 ReportFailure(ArchiverResult::ERROR_SECURITY_CERTIFICATE); 64 ReportFailure(ArchiverResult::ERROR_SECURITY_CERTIFICATE);
63 return; 65 return;
64 } 66 }
65 67
68 if (web_contents_->GetController().GetVisibleEntry()->GetPageType() !=
69 content::PageType::PAGE_TYPE_NORMAL) {
chili 2017/04/10 20:27:18 The error page types are: NORMAL, ERROR, INTERSTIT
romax 2017/04/10 21:19:34 would it be possible that the INTERSTITIAL page is
Pete Williamson 2017/04/11 17:08:50 Good comment, please add it to the code instead of
chili 2017/04/11 20:40:16 As the code is currently implemented, that's not v
70 ReportFailure(ArchiverResult::ERROR_PAGE);
71 return;
72 }
73
66 GenerateMHTML(archives_dir, create_archive_params); 74 GenerateMHTML(archives_dir, create_archive_params);
67 } 75 }
68 76
69 void OfflinePageMHTMLArchiver::GenerateMHTML( 77 void OfflinePageMHTMLArchiver::GenerateMHTML(
70 const base::FilePath& archives_dir, 78 const base::FilePath& archives_dir,
71 const CreateArchiveParams& create_archive_params) { 79 const CreateArchiveParams& create_archive_params) {
72 if (archives_dir.empty()) { 80 if (archives_dir.empty()) {
73 DVLOG(1) << "Archive path was empty. Can't create archive."; 81 DVLOG(1) << "Archive path was empty. Can't create archive.";
74 ReportFailure(ArchiverResult::ERROR_ARCHIVE_CREATION_FAILED); 82 ReportFailure(ArchiverResult::ERROR_ARCHIVE_CREATION_FAILED);
75 return; 83 return;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 139 }
132 140
133 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { 141 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) {
134 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); 142 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED);
135 base::ThreadTaskRunnerHandle::Get()->PostTask( 143 base::ThreadTaskRunnerHandle::Get()->PostTask(
136 FROM_HERE, base::Bind(callback_, this, result, GURL(), base::FilePath(), 144 FROM_HERE, base::Bind(callback_, this, result, GURL(), base::FilePath(),
137 base::string16(), 0)); 145 base::string16(), 0));
138 } 146 }
139 147
140 } // namespace offline_pages 148 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698