Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/browser/devtools/protocol/security_handler.h" | 5 #include "content/browser/devtools/protocol/security_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "content/browser/frame_host/render_frame_host_impl.h" | 9 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 .Build(); | 129 .Build(); |
| 130 | 130 |
| 131 frontend_->SecurityStateChanged( | 131 frontend_->SecurityStateChanged( |
| 132 security_state, | 132 security_state, |
| 133 security_style_explanations.scheme_is_cryptographic, | 133 security_style_explanations.scheme_is_cryptographic, |
| 134 std::move(explanations), | 134 std::move(explanations), |
| 135 std::move(insecure_status), | 135 std::move(insecure_status), |
| 136 Maybe<std::string>(security_style_explanations.summary)); | 136 Maybe<std::string>(security_style_explanations.summary)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool SecurityHandler::NotifyCertificateError(CertErrorHandler handler) { | |
| 140 handlers_[++cert_error_id_] = handler; | |
|
Eric Seckler
2017/01/19 11:42:28
nit: with next_cert_error_id_, this should become
irisu
2017/02/07 23:30:19
Done.
| |
| 141 frontend_->CertificateError(cert_error_id_); | |
| 142 return true; | |
| 143 } | |
| 144 | |
| 139 Response SecurityHandler::Enable() { | 145 Response SecurityHandler::Enable() { |
| 140 enabled_ = true; | 146 enabled_ = true; |
| 141 if (host_) | 147 if (host_) |
| 142 AttachToRenderFrameHost(); | 148 AttachToRenderFrameHost(); |
| 143 | 149 |
| 144 return Response::OK(); | 150 return Response::OK(); |
| 145 } | 151 } |
| 146 | 152 |
| 147 Response SecurityHandler::Disable() { | 153 Response SecurityHandler::Disable() { |
| 148 enabled_ = false; | 154 enabled_ = false; |
| 149 WebContentsObserver::Observe(nullptr); | 155 WebContentsObserver::Observe(nullptr); |
| 150 return Response::OK(); | 156 return Response::OK(); |
| 151 } | 157 } |
| 152 | 158 |
| 153 Response SecurityHandler::ShowCertificateViewer() { | 159 Response SecurityHandler::ShowCertificateViewer() { |
| 154 if (!host_) | 160 if (!host_) |
| 155 return Response::InternalError(); | 161 return Response::InternalError(); |
| 156 WebContents* web_contents = WebContents::FromRenderFrameHost(host_); | 162 WebContents* web_contents = WebContents::FromRenderFrameHost(host_); |
| 157 scoped_refptr<net::X509Certificate> certificate = | 163 scoped_refptr<net::X509Certificate> certificate = |
| 158 web_contents->GetController().GetVisibleEntry()->GetSSL().certificate; | 164 web_contents->GetController().GetVisibleEntry()->GetSSL().certificate; |
| 159 if (!certificate) | 165 if (!certificate) |
| 160 return Response::Error("Could not find certificate"); | 166 return Response::Error("Could not find certificate"); |
| 161 web_contents->GetDelegate()->ShowCertificateViewerInDevTools( | 167 web_contents->GetDelegate()->ShowCertificateViewerInDevTools( |
| 162 web_contents, certificate); | 168 web_contents, certificate); |
| 163 return Response::OK(); | 169 return Response::OK(); |
| 164 } | 170 } |
| 165 | 171 |
| 172 Response SecurityHandler::HandleCertificateError(int event_id, | |
| 173 const String& in_action) { | |
| 174 content::CertificateRequestResultType type = | |
| 175 content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY; | |
| 176 Response response = Response::OK(); | |
| 177 if (in_action == "continue") { | |
| 178 type = content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE; | |
| 179 } else if (in_action == "cancel") { | |
| 180 type = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; | |
| 181 } else if (in_action == "deny") { | |
| 182 type = content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY; | |
| 183 } else { | |
| 184 response = Response::Error( | |
| 185 String("Unknown Certificate Error Action: " + in_action)); | |
| 186 } | |
| 187 handlers_[event_id].Run(type); | |
|
Eric Seckler
2017/01/19 11:42:28
We should probably check above whether the provide
irisu
2017/02/07 23:30:19
Done.
| |
| 188 handlers_.erase(event_id); | |
| 189 return response; | |
| 190 } | |
| 191 | |
| 166 } // namespace protocol | 192 } // namespace protocol |
| 167 } // namespace content | 193 } // namespace content |
| OLD | NEW |