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

Unified 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: add comments and fix tests 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc b/chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc
index d8560f1e05a4decd9683d68e844ed3399141b3f7..9b6cb1e60f99cc7c262d937dbcf6e616ff1f7e97 100644
--- a/chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc
+++ b/chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "components/security_state/core/security_state.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/mhtml_generation_params.h"
#include "net/base/filename_util.h"
@@ -58,11 +59,26 @@ void OfflinePageMHTMLArchiver::CreateArchive(
DCHECK(!callback.is_null());
callback_ = callback;
+ // TODO(chili): crbug/710248 These checks should probably be done inside
+ // the offliner.
if (HasConnectionSecurityError()) {
ReportFailure(ArchiverResult::ERROR_SECURITY_CERTIFICATE);
return;
}
+ // Don't save chrome error pages.
+ if (GetPageType() == content::PageType::PAGE_TYPE_ERROR) {
+ ReportFailure(ArchiverResult::ERROR_ERROR_PAGE);
+ return;
+ }
+
+ // Don't save chrome-injected interstitial info pages
+ // i.e. "This site may be dangerous. Are you sure you want to continue?"
+ if (GetPageType() == content::PageType::PAGE_TYPE_INTERSTITIAL) {
+ ReportFailure(ArchiverResult::ERROR_INTERSTITIAL_PAGE);
+ return;
+ }
+
GenerateMHTML(archives_dir, create_archive_params);
}
@@ -130,6 +146,10 @@ bool OfflinePageMHTMLArchiver::HasConnectionSecurityError() {
security_info.security_level;
}
+content::PageType OfflinePageMHTMLArchiver::GetPageType() {
+ return web_contents_->GetController().GetVisibleEntry()->GetPageType();
+}
+
void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) {
DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED);
base::ThreadTaskRunnerHandle::Get()->PostTask(

Powered by Google App Engine
This is Rietveld 408576698