Commit 41d18672 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

weblayer: removes dead code in ErrorPageHelper

And simplifies the implementation a bit.

BUG=none
TEST=none

Change-Id: I1464e636597952f94f5a960eccbefec810fb686c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343786Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796160}
parent f5899cff
......@@ -130,11 +130,8 @@ void ContentRendererClientImpl::PrepareErrorPage(
const std::string& http_method,
std::string* error_html) {
auto* error_page_helper = ErrorPageHelper::GetForFrame(render_frame);
if (error_page_helper) {
error_page_helper->PrepareErrorPage(error_page::Error::NetError(
error.url(), error.reason(), error.resolve_error_info(),
error.has_copy_in_cache()));
}
if (error_page_helper)
error_page_helper->PrepareErrorPage();
#if defined(OS_ANDROID)
// This does nothing if |error_html| is non-null (which happens if the
......
......@@ -5,28 +5,14 @@
#include "weblayer/renderer/error_page_helper.h"
#include "base/command_line.h"
#include "components/error_page/common/error.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "components/security_interstitials/content/renderer/security_interstitial_page_controller.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "weblayer/common/features.h"
namespace weblayer {
struct ErrorPageHelper::ErrorPageInfo {
explicit ErrorPageInfo(const error_page::Error& error) : error(error) {}
// Information about the failed page load.
error_page::Error error;
// True if a page has completed loading, at which point it can receive
// updates.
bool is_finished_loading = false;
};
// static
void ErrorPageHelper::Create(content::RenderFrame* render_frame) {
if (render_frame->IsMainFrame())
......@@ -39,34 +25,31 @@ ErrorPageHelper* ErrorPageHelper::GetForFrame(
return render_frame->IsMainFrame() ? Get(render_frame) : nullptr;
}
void ErrorPageHelper::PrepareErrorPage(const error_page::Error& error) {
void ErrorPageHelper::PrepareErrorPage() {
if (is_disabled_for_next_error_) {
is_disabled_for_next_error_ = false;
return;
}
pending_error_page_info_ = std::make_unique<ErrorPageInfo>(error);
is_preparing_for_error_page_ = true;
}
void ErrorPageHelper::DidCommitProvisionalLoad(ui::PageTransition transition) {
is_disabled_for_next_error_ = false;
committed_error_page_info_ = std::move(pending_error_page_info_);
show_error_page_in_finish_load_ = is_preparing_for_error_page_;
is_preparing_for_error_page_ = false;
}
void ErrorPageHelper::DidFinishLoad() {
if (!committed_error_page_info_)
if (!show_error_page_in_finish_load_)
return;
security_interstitials::SecurityInterstitialPageController::Install(
render_frame());
committed_error_page_info_->is_finished_loading = true;
}
void ErrorPageHelper::OnDestruct() {
delete this;
}
void ErrorPageHelper::DisableErrorPageHelperForNextError() {
is_disabled_for_next_error_ = true;
}
......@@ -81,12 +64,6 @@ ErrorPageHelper::ErrorPageHelper(content::RenderFrame* render_frame)
ErrorPageHelper::~ErrorPageHelper() = default;
void ErrorPageHelper::Reload() {
if (!committed_error_page_info_)
return;
render_frame()->GetWebFrame()->StartReload(blink::WebFrameLoadType::kReload);
}
void ErrorPageHelper::BindErrorPageHelper(
mojo::PendingAssociatedReceiver<mojom::ErrorPageHelper> receiver) {
// There is only a need for a single receiver to be bound at a time.
......
......@@ -5,17 +5,12 @@
#ifndef WEBLAYER_RENDERER_ERROR_PAGE_HELPER_H_
#define WEBLAYER_RENDERER_ERROR_PAGE_HELPER_H_
#include "components/security_interstitials/content/renderer/security_interstitial_page_controller.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_frame_observer_tracker.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "weblayer/common/error_page_helper.mojom.h"
namespace error_page {
class Error;
}
namespace weblayer {
// A class that allows error pages to handle user interaction by handling their
......@@ -40,7 +35,7 @@ class ErrorPageHelper
static ErrorPageHelper* GetForFrame(content::RenderFrame* render_frame);
// Called when the current navigation results in an error.
void PrepareErrorPage(const error_page::Error& error);
void PrepareErrorPage();
// content::RenderFrameObserver:
void DidCommitProvisionalLoad(ui::PageTransition transition) override;
......@@ -51,23 +46,19 @@ class ErrorPageHelper
void DisableErrorPageHelperForNextError() override;
private:
struct ErrorPageInfo;
explicit ErrorPageHelper(content::RenderFrame* render_frame);
~ErrorPageHelper() override;
void Reload();
void BindErrorPageHelper(
mojo::PendingAssociatedReceiver<mojom::ErrorPageHelper> receiver);
// Information for the provisional / "pre-provisional" error page. Null when
// there's no page pending, or the pending page is not an error page.
std::unique_ptr<ErrorPageInfo> pending_error_page_info_;
// Set to true in PrepareErrorPage().
bool is_preparing_for_error_page_ = false;
// Information for the committed error page. Null when the committed page is
// not an error page.
std::unique_ptr<ErrorPageInfo> committed_error_page_info_;
// Set to the value of |is_preparing_for_error_page_| in
// DidCommitProvisionalLoad(). Used to determine if the security interstitial
// should be shown when the load finishes.
bool show_error_page_in_finish_load_ = false;
// Set to true when the embedder injects its own error page. When the
// embedder injects its own error page the support here is not needed and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment