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/devtools/protocol/devtools_protocol_dispatcher.h" | 9 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |
| 10 #include "content/public/browser/navigation_controller.h" |
| 11 #include "content/public/browser/navigation_entry.h" |
10 #include "content/public/browser/security_style_explanations.h" | 12 #include "content/public/browser/security_style_explanations.h" |
11 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
12 #include "content/public/browser/web_contents_delegate.h" | 14 #include "content/public/browser/web_contents_delegate.h" |
| 15 #include "content/public/common/ssl_status.h" |
13 | 16 |
14 namespace content { | 17 namespace content { |
15 namespace devtools { | 18 namespace devtools { |
16 namespace security { | 19 namespace security { |
17 | 20 |
18 typedef DevToolsProtocolClient::Response Response; | 21 typedef DevToolsProtocolClient::Response Response; |
19 | 22 |
20 namespace { | 23 namespace { |
21 | 24 |
22 std::string SecurityStyleToProtocolSecurityState( | 25 std::string SecurityStyleToProtocolSecurityState( |
(...skipping 14 matching lines...) Expand all Loading... |
37 return kSecurityStateUnknown; | 40 return kSecurityStateUnknown; |
38 } | 41 } |
39 } | 42 } |
40 | 43 |
41 void AddExplanations( | 44 void AddExplanations( |
42 const std::string& security_style, | 45 const std::string& security_style, |
43 const std::vector<SecurityStyleExplanation>& explanations_to_add, | 46 const std::vector<SecurityStyleExplanation>& explanations_to_add, |
44 std::vector<scoped_refptr<SecurityStateExplanation>>* explanations) { | 47 std::vector<scoped_refptr<SecurityStateExplanation>>* explanations) { |
45 for (const auto& it : explanations_to_add) { | 48 for (const auto& it : explanations_to_add) { |
46 scoped_refptr<SecurityStateExplanation> explanation = | 49 scoped_refptr<SecurityStateExplanation> explanation = |
47 SecurityStateExplanation::Create()->set_security_state(security_style) | 50 SecurityStateExplanation::Create() |
48 ->set_summary(it.summary) | 51 ->set_security_state(security_style) |
49 ->set_description(it.description); | 52 ->set_summary(it.summary) |
50 if (it.cert_id > 0) | 53 ->set_description(it.description) |
51 explanation->set_certificate_id(it.cert_id); | 54 ->set_has_certificate(it.has_certificate); |
52 explanations->push_back(explanation); | 55 explanations->push_back(explanation); |
53 } | 56 } |
54 } | 57 } |
55 | 58 |
56 } // namespace | 59 } // namespace |
57 | 60 |
58 SecurityHandler::SecurityHandler() | 61 SecurityHandler::SecurityHandler() |
59 : enabled_(false), | 62 : enabled_(false), |
60 host_(nullptr) { | 63 host_(nullptr) { |
61 } | 64 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 143 |
141 return Response::OK(); | 144 return Response::OK(); |
142 } | 145 } |
143 | 146 |
144 Response SecurityHandler::Disable() { | 147 Response SecurityHandler::Disable() { |
145 enabled_ = false; | 148 enabled_ = false; |
146 WebContentsObserver::Observe(nullptr); | 149 WebContentsObserver::Observe(nullptr); |
147 return Response::OK(); | 150 return Response::OK(); |
148 } | 151 } |
149 | 152 |
150 Response SecurityHandler::ShowCertificateViewer(int certificate_id) { | 153 Response SecurityHandler::ShowCertificateViewer() { |
151 if (!host_) | 154 if (!host_) |
152 return Response::InternalError("Could not connect to view"); | 155 return Response::InternalError("Could not connect to view"); |
153 WebContents* web_contents = WebContents::FromRenderFrameHost(host_); | 156 WebContents* web_contents = WebContents::FromRenderFrameHost(host_); |
| 157 scoped_refptr<net::X509Certificate> certificate = web_contents-> |
| 158 GetController().GetLastCommittedEntry()->GetSSL().certificate; |
154 web_contents->GetDelegate()->ShowCertificateViewerInDevTools( | 159 web_contents->GetDelegate()->ShowCertificateViewerInDevTools( |
155 web_contents, certificate_id); | 160 web_contents, certificate); |
156 return Response::OK(); | 161 return Response::OK(); |
157 } | 162 } |
158 | 163 |
159 } // namespace security | 164 } // namespace security |
160 } // namespace devtools | 165 } // namespace devtools |
161 } // namespace content | 166 } // namespace content |
OLD | NEW |