| Index: content/browser/devtools/protocol/security_handler.cc
|
| diff --git a/content/browser/devtools/protocol/security_handler.cc b/content/browser/devtools/protocol/security_handler.cc
|
| index 6b6808e4367c2719ae13e36f62823be48c4487f1..2faec093199e6598efe8aa6ae84f45b07fcff7cd 100644
|
| --- a/content/browser/devtools/protocol/security_handler.cc
|
| +++ b/content/browser/devtools/protocol/security_handler.cc
|
| @@ -146,6 +146,31 @@ void SecurityHandler::DidChangeVisibleSecurityState() {
|
| Maybe<std::string>(security_style_explanations.summary));
|
| }
|
|
|
| +void SecurityHandler::DidFinishNavigation(NavigationHandle* navigation_handle) {
|
| + if (certificate_errors_overriden_)
|
| + FlushPendingCertificateErrorNotifications();
|
| +}
|
| +
|
| +void SecurityHandler::FlushPendingCertificateErrorNotifications() {
|
| + for (auto callback : callbacks_)
|
| + callback.second.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
|
| + callbacks_.clear();
|
| +}
|
| +
|
| +bool SecurityHandler::NotifyCertificateError(int cert_error,
|
| + const GURL& request_url,
|
| + CertErrorCallback handler) {
|
| + if (!enabled_)
|
| + return false;
|
| + frontend_->CertificateError(++last_cert_error_id_,
|
| + net::ErrorToShortString(cert_error),
|
| + request_url.spec());
|
| + if (!certificate_errors_overriden_)
|
| + return false;
|
| + callbacks_[last_cert_error_id_] = handler;
|
| + return true;
|
| +}
|
| +
|
| Response SecurityHandler::Enable() {
|
| enabled_ = true;
|
| if (host_)
|
| @@ -156,7 +181,9 @@ Response SecurityHandler::Enable() {
|
|
|
| Response SecurityHandler::Disable() {
|
| enabled_ = false;
|
| + certificate_errors_overriden_ = false;
|
| WebContentsObserver::Observe(nullptr);
|
| + FlushPendingCertificateErrorNotifications();
|
| return Response::OK();
|
| }
|
|
|
| @@ -173,5 +200,36 @@ Response SecurityHandler::ShowCertificateViewer() {
|
| return Response::OK();
|
| }
|
|
|
| +Response SecurityHandler::HandleCertificateError(int event_id,
|
| + const String& action) {
|
| + if (callbacks_.find(event_id) == callbacks_.end()) {
|
| + return Response::Error(
|
| + String("Unknown event id: " + std::to_string(event_id)));
|
| + }
|
| + content::CertificateRequestResultType type =
|
| + content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
|
| + Response response = Response::OK();
|
| + if (action == Security::CertificateErrorActionEnum::Continue) {
|
| + type = content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE;
|
| + } else if (action == Security::CertificateErrorActionEnum::Cancel) {
|
| + type = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
|
| + } else {
|
| + response =
|
| + Response::Error(String("Unknown Certificate Error Action: " + action));
|
| + }
|
| + callbacks_[event_id].Run(type);
|
| + callbacks_.erase(event_id);
|
| + return response;
|
| +}
|
| +
|
| +Response SecurityHandler::SetOverrideCertificateErrors(bool override) {
|
| + if (override && !enabled_)
|
| + return Response::Error("Security domain not enabled");
|
| + certificate_errors_overriden_ = override;
|
| + if (!override)
|
| + FlushPendingCertificateErrorNotifications();
|
| + return Response::OK();
|
| +}
|
| +
|
| } // namespace protocol
|
| } // namespace content
|
|
|