Refactor SSLCertificateErrorPageController
SSLCertificateErrorPageController is no longer only used on SSL errors,
renamed it to SecurityInterstitialErrorPageController, and removed the
net::Error code passed to EnablePageHelperFunctions since it's no
longer used.
Bug: 910794
Change-Id: I718e0fcbcb2643cb0c47818dda1f317aef4e75cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1503910
Reviewed-by: Matt Menke <mmenke@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Carlos IL <carlosil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638232}
diff --git a/chrome/renderer/BUILD.gn b/chrome/renderer/BUILD.gn
index e86e1f0..245a710 100644
--- a/chrome/renderer/BUILD.gn
+++ b/chrome/renderer/BUILD.gn
@@ -102,8 +102,8 @@
"sandbox_status_extension_android.h",
"security_filter_peer.cc",
"security_filter_peer.h",
- "ssl/ssl_certificate_error_page_controller.cc",
- "ssl/ssl_certificate_error_page_controller.h",
+ "security_interstitials/security_interstitial_page_controller.cc",
+ "security_interstitials/security_interstitial_page_controller.h",
"supervised_user/supervised_user_error_page_controller.cc",
"supervised_user/supervised_user_error_page_controller.h",
"tts_dispatcher.cc",
diff --git a/chrome/renderer/net/net_error_helper.cc b/chrome/renderer/net/net_error_helper.cc
index 0081b5b..2eb6a96 100644
--- a/chrome/renderer/net/net_error_helper.cc
+++ b/chrome/renderer/net/net_error_helper.cc
@@ -24,7 +24,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/chrome_render_thread_observer.h"
-#include "chrome/renderer/ssl/ssl_certificate_error_page_controller.h"
+#include "chrome/renderer/security_interstitials/security_interstitial_page_controller.h"
#include "chrome/renderer/supervised_user/supervised_user_error_page_controller.h"
#include "components/error_page/common/error.h"
#include "components/error_page/common/error_page_params.h"
@@ -167,7 +167,7 @@
: RenderFrameObserver(render_frame),
content::RenderFrameObserverTracker<NetErrorHelper>(render_frame),
weak_controller_delegate_factory_(this),
- weak_ssl_error_controller_delegate_factory_(this),
+ weak_security_interstitial_controller_delegate_factory_(this),
weak_supervised_user_error_controller_delegate_factory_(this) {
RenderThread::Get()->AddObserver(this);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@@ -324,7 +324,7 @@
// error page, the controller has not yet been attached, so this won't affect
// it.
weak_controller_delegate_factory_.InvalidateWeakPtrs();
- weak_ssl_error_controller_delegate_factory_.InvalidateWeakPtrs();
+ weak_security_interstitial_controller_delegate_factory_.InvalidateWeakPtrs();
weak_supervised_user_error_controller_delegate_factory_.InvalidateWeakPtrs();
core_->OnCommitLoad(GetFrameType(render_frame()),
@@ -433,9 +433,10 @@
failed_url, true /* replace_current_item */);
}
-void NetErrorHelper::EnablePageHelperFunctions(net::Error net_error) {
- SSLCertificateErrorPageController::Install(
- render_frame(), weak_ssl_error_controller_delegate_factory_.GetWeakPtr());
+void NetErrorHelper::EnablePageHelperFunctions() {
+ SecurityInterstitialPageController::Install(
+ render_frame(),
+ weak_security_interstitial_controller_delegate_factory_.GetWeakPtr());
NetErrorPageController::Install(
render_frame(), weak_controller_delegate_factory_.GetWeakPtr());
diff --git a/chrome/renderer/net/net_error_helper.h b/chrome/renderer/net/net_error_helper.h
index cf104cf8..0b259ec 100644
--- a/chrome/renderer/net/net_error_helper.h
+++ b/chrome/renderer/net/net_error_helper.h
@@ -18,7 +18,7 @@
#include "chrome/common/supervised_user_commands.mojom.h"
#include "chrome/renderer/net/net_error_helper_core.h"
#include "chrome/renderer/net/net_error_page_controller.h"
-#include "chrome/renderer/ssl/ssl_certificate_error_page_controller.h"
+#include "chrome/renderer/security_interstitials/security_interstitial_page_controller.h"
#include "chrome/renderer/supervised_user/supervised_user_error_page_controller.h"
#include "chrome/renderer/supervised_user/supervised_user_error_page_controller_delegate.h"
#include "components/error_page/common/net_error_info.h"
@@ -55,7 +55,7 @@
public content::RenderThreadObserver,
public NetErrorHelperCore::Delegate,
public NetErrorPageController::Delegate,
- public SSLCertificateErrorPageController::Delegate,
+ public SecurityInterstitialPageController::Delegate,
public SupervisedUserErrorPageControllerDelegate,
public chrome::mojom::NetworkDiagnosticsClient,
public chrome::mojom::NavigationCorrector {
@@ -75,7 +75,7 @@
void UpdateEasterEggHighScore(int high_score) override;
void ResetEasterEggHighScore() override;
- // SSLCertificateErrorPageController::Delegate implementation
+ // SecurityInterstitialPageController::Delegate implementation
void SendCommand(
security_interstitials::SecurityInterstitialCommand command) override;
@@ -130,7 +130,7 @@
bool* auto_fetch_allowed,
std::string* html) const override;
void LoadErrorPage(const std::string& html, const GURL& failed_url) override;
- void EnablePageHelperFunctions(net::Error net_error) override;
+ void EnablePageHelperFunctions() override;
void UpdateErrorPage(const error_page::Error& error,
bool is_failed_post,
bool can_use_local_diagnostics_service) override;
@@ -207,8 +207,8 @@
base::WeakPtrFactory<NetErrorPageController::Delegate>
weak_controller_delegate_factory_;
- base::WeakPtrFactory<SSLCertificateErrorPageController::Delegate>
- weak_ssl_error_controller_delegate_factory_;
+ base::WeakPtrFactory<SecurityInterstitialPageController::Delegate>
+ weak_security_interstitial_controller_delegate_factory_;
base::WeakPtrFactory<SupervisedUserErrorPageControllerDelegate>
weak_supervised_user_error_controller_delegate_factory_;
diff --git a/chrome/renderer/net/net_error_helper_core.cc b/chrome/renderer/net/net_error_helper_core.cc
index 4ef1d0a8..2f25b7a 100644
--- a/chrome/renderer/net/net_error_helper_core.cc
+++ b/chrome/renderer/net/net_error_helper_core.cc
@@ -678,8 +678,7 @@
delegate_->SetIsShowingDownloadButton(
committed_error_page_info_->download_button_in_page);
- delegate_->EnablePageHelperFunctions(
- static_cast<net::Error>(committed_error_page_info_->error.reason()));
+ delegate_->EnablePageHelperFunctions();
#if defined(OS_ANDROID)
if (committed_error_page_info_->offline_content_feature_state ==
diff --git a/chrome/renderer/net/net_error_helper_core.h b/chrome/renderer/net/net_error_helper_core.h
index 14ebf9c..2720c244 100644
--- a/chrome/renderer/net/net_error_helper_core.h
+++ b/chrome/renderer/net/net_error_helper_core.h
@@ -80,7 +80,7 @@
// Create extra Javascript bindings in the error page. Will only be invoked
// after an error page has finished loading.
- virtual void EnablePageHelperFunctions(net::Error net_error) = 0;
+ virtual void EnablePageHelperFunctions() = 0;
// Updates the currently displayed error page with a new error code. The
// currently displayed error page must have finished loading, and must have
diff --git a/chrome/renderer/net/net_error_helper_core_unittest.cc b/chrome/renderer/net/net_error_helper_core_unittest.cc
index 86a8b86..6847390d 100644
--- a/chrome/renderer/net/net_error_helper_core_unittest.cc
+++ b/chrome/renderer/net/net_error_helper_core_unittest.cc
@@ -390,7 +390,7 @@
last_error_html_ = html;
}
- void EnablePageHelperFunctions(net::Error net_error) override {
+ void EnablePageHelperFunctions() override {
enable_page_helper_functions_count_++;
}
diff --git a/chrome/renderer/ssl/DEPS b/chrome/renderer/security_interstitials/DEPS
similarity index 100%
rename from chrome/renderer/ssl/DEPS
rename to chrome/renderer/security_interstitials/DEPS
diff --git a/chrome/renderer/ssl/OWNERS b/chrome/renderer/security_interstitials/OWNERS
similarity index 100%
rename from chrome/renderer/ssl/OWNERS
rename to chrome/renderer/security_interstitials/OWNERS
diff --git a/chrome/renderer/security_interstitials/security_interstitial_page_controller.cc b/chrome/renderer/security_interstitials/security_interstitial_page_controller.cc
new file mode 100644
index 0000000..126e46c
--- /dev/null
+++ b/chrome/renderer/security_interstitials/security_interstitial_page_controller.cc
@@ -0,0 +1,146 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/security_interstitials/security_interstitial_page_controller.h"
+
+#include "components/security_interstitials/core/controller_client.h"
+#include "content/public/renderer/render_frame.h"
+#include "gin/handle.h"
+#include "gin/object_template_builder.h"
+#include "third_party/blink/public/web/blink.h"
+#include "third_party/blink/public/web/web_local_frame.h"
+
+gin::WrapperInfo SecurityInterstitialPageController::kWrapperInfo = {
+ gin::kEmbedderNativeGin};
+
+SecurityInterstitialPageController::Delegate::~Delegate() {}
+
+void SecurityInterstitialPageController::Install(
+ content::RenderFrame* render_frame,
+ base::WeakPtr<Delegate> delegate) {
+ v8::Isolate* isolate = blink::MainThreadIsolate();
+ v8::HandleScope handle_scope(isolate);
+ v8::Local<v8::Context> context =
+ render_frame->GetWebFrame()->MainWorldScriptContext();
+ if (context.IsEmpty())
+ return;
+
+ v8::Context::Scope context_scope(context);
+
+ gin::Handle<SecurityInterstitialPageController> controller =
+ gin::CreateHandle(isolate,
+ new SecurityInterstitialPageController(delegate));
+ if (controller.IsEmpty())
+ return;
+
+ v8::Local<v8::Object> global = context->Global();
+ global->Set(gin::StringToV8(isolate, "certificateErrorPageController"),
+ controller.ToV8());
+}
+
+SecurityInterstitialPageController::SecurityInterstitialPageController(
+ base::WeakPtr<Delegate> delegate)
+ : delegate_(delegate) {}
+
+SecurityInterstitialPageController::~SecurityInterstitialPageController() {}
+
+void SecurityInterstitialPageController::DontProceed() {
+ SendCommand(
+ security_interstitials::SecurityInterstitialCommand::CMD_DONT_PROCEED);
+}
+
+void SecurityInterstitialPageController::Proceed() {
+ SendCommand(security_interstitials::SecurityInterstitialCommand::CMD_PROCEED);
+}
+
+void SecurityInterstitialPageController::ShowMoreSection() {
+ SendCommand(security_interstitials::SecurityInterstitialCommand::
+ CMD_SHOW_MORE_SECTION);
+}
+
+void SecurityInterstitialPageController::OpenHelpCenter() {
+ SendCommand(security_interstitials::SecurityInterstitialCommand::
+ CMD_OPEN_HELP_CENTER);
+}
+
+void SecurityInterstitialPageController::OpenDiagnostic() {
+ SendCommand(
+ security_interstitials::SecurityInterstitialCommand::CMD_OPEN_DIAGNOSTIC);
+}
+
+void SecurityInterstitialPageController::Reload() {
+ SendCommand(security_interstitials::SecurityInterstitialCommand::CMD_RELOAD);
+}
+
+void SecurityInterstitialPageController::OpenDateSettings() {
+ SendCommand(security_interstitials::SecurityInterstitialCommand::
+ CMD_OPEN_DATE_SETTINGS);
+}
+
+void SecurityInterstitialPageController::OpenLogin() {
+ SendCommand(
+ security_interstitials::SecurityInterstitialCommand::CMD_OPEN_LOGIN);
+}
+
+void SecurityInterstitialPageController::DoReport() {
+ SendCommand(
+ security_interstitials::SecurityInterstitialCommand::CMD_DO_REPORT);
+}
+
+void SecurityInterstitialPageController::DontReport() {
+ SendCommand(
+ security_interstitials::SecurityInterstitialCommand::CMD_DONT_REPORT);
+}
+
+void SecurityInterstitialPageController::OpenReportingPrivacy() {
+ SendCommand(security_interstitials::SecurityInterstitialCommand::
+ CMD_OPEN_REPORTING_PRIVACY);
+}
+
+void SecurityInterstitialPageController::OpenWhitepaper() {
+ SendCommand(
+ security_interstitials::SecurityInterstitialCommand::CMD_OPEN_WHITEPAPER);
+}
+
+void SecurityInterstitialPageController::ReportPhishingError() {
+ SendCommand(security_interstitials::SecurityInterstitialCommand::
+ CMD_REPORT_PHISHING_ERROR);
+}
+
+void SecurityInterstitialPageController::SendCommand(
+ security_interstitials::SecurityInterstitialCommand command) {
+ if (delegate_) {
+ delegate_->SendCommand(command);
+ }
+}
+
+gin::ObjectTemplateBuilder
+SecurityInterstitialPageController::GetObjectTemplateBuilder(
+ v8::Isolate* isolate) {
+ return gin::Wrappable<SecurityInterstitialPageController>::
+ GetObjectTemplateBuilder(isolate)
+ .SetMethod("dontProceed",
+ &SecurityInterstitialPageController::DontProceed)
+ .SetMethod("proceed", &SecurityInterstitialPageController::Proceed)
+ .SetMethod("showMoreSection",
+ &SecurityInterstitialPageController::ShowMoreSection)
+ .SetMethod("openHelpCenter",
+ &SecurityInterstitialPageController::OpenHelpCenter)
+ .SetMethod("openDiagnostic",
+ &SecurityInterstitialPageController::OpenDiagnostic)
+ .SetMethod("reload", &SecurityInterstitialPageController::Reload)
+ .SetMethod("openDateSettings",
+ &SecurityInterstitialPageController::OpenDateSettings)
+ .SetMethod("openLogin",
+ &SecurityInterstitialPageController::OpenLogin)
+ .SetMethod("doReport", &SecurityInterstitialPageController::DoReport)
+ .SetMethod("dontReport",
+ &SecurityInterstitialPageController::DontReport)
+ .SetMethod("openReportingPrivacy",
+ &SecurityInterstitialPageController::OpenReportingPrivacy)
+ .SetMethod("openWhitepaper",
+ &SecurityInterstitialPageController::OpenWhitepaper)
+ .SetMethod("reportPhishingError",
+ &SecurityInterstitialPageController::ReportPhishingError);
+}
diff --git a/chrome/renderer/ssl/ssl_certificate_error_page_controller.h b/chrome/renderer/security_interstitials/security_interstitial_page_controller.h
similarity index 76%
rename from chrome/renderer/ssl/ssl_certificate_error_page_controller.h
rename to chrome/renderer/security_interstitials/security_interstitial_page_controller.h
index b550222..967a9e7 100644
--- a/chrome/renderer/ssl/ssl_certificate_error_page_controller.h
+++ b/chrome/renderer/security_interstitials/security_interstitial_page_controller.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_RENDERER_SSL_SSL_CERTIFICATE_ERROR_PAGE_CONTROLLER_H_
-#define CHROME_RENDERER_SSL_SSL_CERTIFICATE_ERROR_PAGE_CONTROLLER_H_
+#ifndef CHROME_RENDERER_SECURITY_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_CONTROLLER_H_
+#define CHROME_RENDERER_SECURITY_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_CONTROLLER_H_
#include "base/memory/weak_ptr.h"
#include "components/security_interstitials/core/controller_client.h"
@@ -16,8 +16,8 @@
// This class makes various helper functions available to interstitials
// when committed interstitials are on. It is bound to the JavaScript
// window.certificateErrorPageController object.
-class SSLCertificateErrorPageController
- : public gin::Wrappable<SSLCertificateErrorPageController> {
+class SecurityInterstitialPageController
+ : public gin::Wrappable<SecurityInterstitialPageController> {
public:
static gin::WrapperInfo kWrapperInfo;
@@ -40,8 +40,8 @@
base::WeakPtr<Delegate> delegate);
private:
- explicit SSLCertificateErrorPageController(base::WeakPtr<Delegate> delegate);
- ~SSLCertificateErrorPageController() override;
+ explicit SecurityInterstitialPageController(base::WeakPtr<Delegate> delegate);
+ ~SecurityInterstitialPageController() override;
void DontProceed();
void Proceed();
@@ -65,7 +65,7 @@
base::WeakPtr<Delegate> const delegate_;
- DISALLOW_COPY_AND_ASSIGN(SSLCertificateErrorPageController);
+ DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPageController);
};
-#endif // CHROME_RENDERER_SSL_SSL_CERTIFICATE_ERROR_PAGE_CONTROLLER_H_
+#endif // CHROME_RENDERER_SECURITY_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_CONTROLLER_H_
diff --git a/chrome/renderer/ssl/ssl_certificate_error_page_controller.cc b/chrome/renderer/ssl/ssl_certificate_error_page_controller.cc
deleted file mode 100644
index a5516d60..0000000
--- a/chrome/renderer/ssl/ssl_certificate_error_page_controller.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/renderer/ssl/ssl_certificate_error_page_controller.h"
-
-#include "components/security_interstitials/core/controller_client.h"
-#include "content/public/renderer/render_frame.h"
-#include "gin/handle.h"
-#include "gin/object_template_builder.h"
-#include "third_party/blink/public/web/blink.h"
-#include "third_party/blink/public/web/web_local_frame.h"
-
-gin::WrapperInfo SSLCertificateErrorPageController::kWrapperInfo = {
- gin::kEmbedderNativeGin};
-
-SSLCertificateErrorPageController::Delegate::~Delegate() {}
-
-void SSLCertificateErrorPageController::Install(
- content::RenderFrame* render_frame,
- base::WeakPtr<Delegate> delegate) {
- v8::Isolate* isolate = blink::MainThreadIsolate();
- v8::HandleScope handle_scope(isolate);
- v8::Local<v8::Context> context =
- render_frame->GetWebFrame()->MainWorldScriptContext();
- if (context.IsEmpty())
- return;
-
- v8::Context::Scope context_scope(context);
-
- gin::Handle<SSLCertificateErrorPageController> controller = gin::CreateHandle(
- isolate, new SSLCertificateErrorPageController(delegate));
- if (controller.IsEmpty())
- return;
-
- v8::Local<v8::Object> global = context->Global();
- global->Set(gin::StringToV8(isolate, "certificateErrorPageController"),
- controller.ToV8());
-}
-
-SSLCertificateErrorPageController::SSLCertificateErrorPageController(
- base::WeakPtr<Delegate> delegate)
- : delegate_(delegate) {}
-
-SSLCertificateErrorPageController::~SSLCertificateErrorPageController() {}
-
-void SSLCertificateErrorPageController::DontProceed() {
- SendCommand(
- security_interstitials::SecurityInterstitialCommand::CMD_DONT_PROCEED);
-}
-
-void SSLCertificateErrorPageController::Proceed() {
- SendCommand(security_interstitials::SecurityInterstitialCommand::CMD_PROCEED);
-}
-
-void SSLCertificateErrorPageController::ShowMoreSection() {
- SendCommand(security_interstitials::SecurityInterstitialCommand::
- CMD_SHOW_MORE_SECTION);
-}
-
-void SSLCertificateErrorPageController::OpenHelpCenter() {
- SendCommand(security_interstitials::SecurityInterstitialCommand::
- CMD_OPEN_HELP_CENTER);
-}
-
-void SSLCertificateErrorPageController::OpenDiagnostic() {
- SendCommand(
- security_interstitials::SecurityInterstitialCommand::CMD_OPEN_DIAGNOSTIC);
-}
-
-void SSLCertificateErrorPageController::Reload() {
- SendCommand(security_interstitials::SecurityInterstitialCommand::CMD_RELOAD);
-}
-
-void SSLCertificateErrorPageController::OpenDateSettings() {
- SendCommand(security_interstitials::SecurityInterstitialCommand::
- CMD_OPEN_DATE_SETTINGS);
-}
-
-void SSLCertificateErrorPageController::OpenLogin() {
- SendCommand(
- security_interstitials::SecurityInterstitialCommand::CMD_OPEN_LOGIN);
-}
-
-void SSLCertificateErrorPageController::DoReport() {
- SendCommand(
- security_interstitials::SecurityInterstitialCommand::CMD_DO_REPORT);
-}
-
-void SSLCertificateErrorPageController::DontReport() {
- SendCommand(
- security_interstitials::SecurityInterstitialCommand::CMD_DONT_REPORT);
-}
-
-void SSLCertificateErrorPageController::OpenReportingPrivacy() {
- SendCommand(security_interstitials::SecurityInterstitialCommand::
- CMD_OPEN_REPORTING_PRIVACY);
-}
-
-void SSLCertificateErrorPageController::OpenWhitepaper() {
- SendCommand(
- security_interstitials::SecurityInterstitialCommand::CMD_OPEN_WHITEPAPER);
-}
-
-void SSLCertificateErrorPageController::ReportPhishingError() {
- SendCommand(security_interstitials::SecurityInterstitialCommand::
- CMD_REPORT_PHISHING_ERROR);
-}
-
-void SSLCertificateErrorPageController::SendCommand(
- security_interstitials::SecurityInterstitialCommand command) {
- if (delegate_) {
- delegate_->SendCommand(command);
- }
-}
-
-gin::ObjectTemplateBuilder
-SSLCertificateErrorPageController::GetObjectTemplateBuilder(
- v8::Isolate* isolate) {
- return gin::Wrappable<SSLCertificateErrorPageController>::
- GetObjectTemplateBuilder(isolate)
- .SetMethod("dontProceed",
- &SSLCertificateErrorPageController::DontProceed)
- .SetMethod("proceed", &SSLCertificateErrorPageController::Proceed)
- .SetMethod("showMoreSection",
- &SSLCertificateErrorPageController::ShowMoreSection)
- .SetMethod("openHelpCenter",
- &SSLCertificateErrorPageController::OpenHelpCenter)
- .SetMethod("openDiagnostic",
- &SSLCertificateErrorPageController::OpenDiagnostic)
- .SetMethod("reload", &SSLCertificateErrorPageController::Reload)
- .SetMethod("openDateSettings",
- &SSLCertificateErrorPageController::OpenDateSettings)
- .SetMethod("openLogin", &SSLCertificateErrorPageController::OpenLogin)
- .SetMethod("doReport", &SSLCertificateErrorPageController::DoReport)
- .SetMethod("dontReport",
- &SSLCertificateErrorPageController::DontReport)
- .SetMethod("openReportingPrivacy",
- &SSLCertificateErrorPageController::OpenReportingPrivacy)
- .SetMethod("openWhitepaper",
- &SSLCertificateErrorPageController::OpenWhitepaper)
- .SetMethod("reportPhishingError",
- &SSLCertificateErrorPageController::ReportPhishingError);
-}