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/devtools/protocol/devtools_protocol_dispatcher.h" | 9 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |
| 10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 68 |
| 69 void SecurityHandler::SetClient(std::unique_ptr<Client> client) { | 69 void SecurityHandler::SetClient(std::unique_ptr<Client> client) { |
| 70 client_.swap(client); | 70 client_.swap(client); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void SecurityHandler::AttachToRenderFrameHost() { | 73 void SecurityHandler::AttachToRenderFrameHost() { |
| 74 DCHECK(host_); | 74 DCHECK(host_); |
| 75 WebContents* web_contents = WebContents::FromRenderFrameHost(host_); | 75 WebContents* web_contents = WebContents::FromRenderFrameHost(host_); |
| 76 WebContentsObserver::Observe(web_contents); | 76 WebContentsObserver::Observe(web_contents); |
| 77 | 77 |
| 78 // Send an initial SecurityStyleChanged event. | 78 // Send an initial DidChangeVisibleSecurityState event. |
| 79 DCHECK(enabled_); | 79 DCHECK(enabled_); |
| 80 SecurityStyleExplanations security_style_explanations; | 80 DidChangeVisibleSecurityState(); |
| 81 blink::WebSecurityStyle security_style = | |
| 82 web_contents->GetDelegate()->GetSecurityStyle( | |
| 83 web_contents, &security_style_explanations); | |
| 84 SecurityStyleChanged(security_style, security_style_explanations); | |
| 85 } | 81 } |
| 86 | 82 |
| 87 void SecurityHandler::SetRenderFrameHost(RenderFrameHost* host) { | 83 void SecurityHandler::SetRenderFrameHost(RenderFrameHost* host) { |
| 88 host_ = host; | 84 host_ = host; |
| 89 if (enabled_ && host_) | 85 if (enabled_ && host_) |
| 90 AttachToRenderFrameHost(); | 86 AttachToRenderFrameHost(); |
| 91 } | 87 } |
| 92 | 88 |
| 93 void SecurityHandler::SecurityStyleChanged( | 89 void SecurityHandler::DidChangeVisibleSecurityState() { |
| 94 blink::WebSecurityStyle security_style, | |
| 95 const SecurityStyleExplanations& security_style_explanations) { | |
| 96 DCHECK(enabled_); | 90 DCHECK(enabled_); |
| 97 | 91 |
| 92 SecurityStyleExplanations security_style_explanations; | |
| 93 blink::WebSecurityStyle security_style = | |
| 94 web_contents()->GetDelegate()->GetSecurityStyle( | |
|
boliu
2016/12/08 05:11:30
there's prior example with ShowCertificateViewerIn
dgozman
2016/12/08 19:07:49
Feel free to discuss this with content API owners:
| |
| 95 web_contents(), &security_style_explanations); | |
| 96 | |
| 98 const std::string security_state = | 97 const std::string security_state = |
| 99 SecurityStyleToProtocolSecurityState(security_style); | 98 SecurityStyleToProtocolSecurityState(security_style); |
| 100 | 99 |
| 101 std::vector<scoped_refptr<SecurityStateExplanation>> explanations; | 100 std::vector<scoped_refptr<SecurityStateExplanation>> explanations; |
| 102 AddExplanations(kSecurityStateInsecure, | 101 AddExplanations(kSecurityStateInsecure, |
| 103 security_style_explanations.broken_explanations, | 102 security_style_explanations.broken_explanations, |
| 104 &explanations); | 103 &explanations); |
| 105 AddExplanations(kSecurityStateNeutral, | 104 AddExplanations(kSecurityStateNeutral, |
| 106 security_style_explanations.unauthenticated_explanations, | 105 security_style_explanations.unauthenticated_explanations, |
| 107 &explanations); | 106 &explanations); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 if (!certificate) | 158 if (!certificate) |
| 160 return Response::InternalError("Could not find certificate"); | 159 return Response::InternalError("Could not find certificate"); |
| 161 web_contents->GetDelegate()->ShowCertificateViewerInDevTools( | 160 web_contents->GetDelegate()->ShowCertificateViewerInDevTools( |
| 162 web_contents, certificate); | 161 web_contents, certificate); |
| 163 return Response::OK(); | 162 return Response::OK(); |
| 164 } | 163 } |
| 165 | 164 |
| 166 } // namespace security | 165 } // namespace security |
| 167 } // namespace devtools | 166 } // namespace devtools |
| 168 } // namespace content | 167 } // namespace content |
| OLD | NEW |