| 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 d3b52e4a8c8fb879a8848f2e36cd6b4801c178ea..38857505d170df9db7d16a61a82e03b4203b93ce 100644
|
| --- a/content/browser/devtools/protocol/security_handler.cc
|
| +++ b/content/browser/devtools/protocol/security_handler.cc
|
| @@ -4,26 +4,76 @@
|
|
|
| #include "content/browser/devtools/protocol/security_handler.h"
|
|
|
| +#include <string>
|
| +
|
| +#include "content/public/browser/web_contents.h"
|
| +
|
| namespace content {
|
| namespace devtools {
|
| namespace security {
|
|
|
| typedef DevToolsProtocolClient::Response Response;
|
|
|
| -SecurityHandler::SecurityHandler() {
|
| +namespace {
|
| +
|
| +std::string SecurityStyleToProtocolSecurityState(
|
| + SecurityStyle security_style) {
|
| + switch (security_style) {
|
| + case SECURITY_STYLE_UNKNOWN:
|
| + return kSecurityStateUnknown;
|
| + case SECURITY_STYLE_UNAUTHENTICATED:
|
| + return kSecurityStateHttp;
|
| + case SECURITY_STYLE_AUTHENTICATION_BROKEN:
|
| + return kSecurityStateInsecure;
|
| + case SECURITY_STYLE_WARNING:
|
| + return kSecurityStateWarning;
|
| + case SECURITY_STYLE_AUTHENTICATED:
|
| + return kSecurityStateSecure;
|
| + default:
|
| + NOTREACHED();
|
| + return kSecurityStateUnknown;
|
| + }
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +SecurityHandler::SecurityHandler()
|
| + : enabled_(false),
|
| + host_(nullptr) {
|
| }
|
|
|
| SecurityHandler::~SecurityHandler() {
|
| }
|
|
|
| -void SecurityHandler::SetClient(scoped_ptr<DevToolsProtocolClient> client) {
|
| +void SecurityHandler::SetClient(scoped_ptr<Client> client) {
|
| + client_.swap(client);
|
| +}
|
| +
|
| +void SecurityHandler::SetRenderFrameHost(RenderFrameHost* host) {
|
| + host_ = host;
|
| + if (enabled_ && host_)
|
| + WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host_));
|
| +}
|
| +
|
| +void SecurityHandler::SecurityStyleChanged(SecurityStyle security_style) {
|
| + DCHECK(enabled_);
|
| +
|
| + const std::string security_state =
|
| + SecurityStyleToProtocolSecurityState(security_style);
|
| + client_->SecurityStateChanged(
|
| + SecurityStateChangedParams::Create()->set_security_state(security_state));
|
| }
|
|
|
| Response SecurityHandler::Enable() {
|
| + enabled_ = true;
|
| + if (host_)
|
| + WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host_));
|
| return Response::OK();
|
| }
|
|
|
| Response SecurityHandler::Disable() {
|
| + enabled_ = false;
|
| + WebContentsObserver::Observe(nullptr);
|
| return Response::OK();
|
| }
|
|
|
|
|