Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1a6486926663012a01edd38f653510c843285d1a |
| --- /dev/null |
| +++ b/content/browser/devtools/protocol/security_handler.cc |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
estark
2015/06/04 01:09:15
copyright should be 2015
lgarron
2015/06/05 01:29:18
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <string> |
| + |
| +#include "base/logging.h" |
| +#include "content/browser/devtools/protocol/security_handler.h" |
|
estark
2015/06/04 01:09:14
This should be at the top of the #include list.
|
| + |
| +namespace content { |
| +namespace devtools { |
| +namespace security { |
| + |
| +typedef DevToolsProtocolClient::Response Response; |
| + |
| +SecurityHandler::SecurityHandler() : enabled_(false) { |
| +} |
| + |
| +SecurityHandler::~SecurityHandler() { |
| +} |
| + |
| +void SecurityHandler::SetClient(scoped_ptr<Client> client) { |
| + client_.swap(client); |
| +} |
| + |
| +void SecurityHandler::SecurityStyleChanged(SecurityStyle security_style) { |
| + if (!enabled_) |
| + return; |
| + |
| + const std::string security_state = |
| + SecurityStyleToProtocolSecurityState(security_style); |
| + client_->SecurityStateChanged( |
|
estark
2015/06/05 00:59:10
Ah, just realized this won't build without the pro
lgarron
2015/06/06 00:57:40
I think it would make more sense to land protocol.
|
| + SecurityStateChangedParams::Create()->set_security_state(security_state)); |
| +} |
| + |
| +Response SecurityHandler::Enable() { |
| + enabled_ = true; |
| + return Response::OK(); |
| +} |
| + |
| +Response SecurityHandler::Disable() { |
| + enabled_ = false; |
| + return Response::FallThrough(); |
|
estark
2015/06/04 01:09:14
I think this should be Response::OK() like Enable(
lgarron
2015/06/05 01:29:18
Makes sense (I trust you on verifying that's what
|
| +} |
| + |
| +std::string SecurityHandler::SecurityStyleToProtocolSecurityState( |
| + SecurityStyle security_style) { |
| + switch (security_style) { |
| + case SECURITY_STYLE_UNKNOWN: |
| + return "UNKNOWN"; |
|
estark
2015/06/04 01:09:15
It looks like constants for these enum values will
lgarron
2015/06/05 01:29:18
Done.
|
| + case SECURITY_STYLE_UNAUTHENTICATED: |
| + return "HTTP"; |
| + case SECURITY_STYLE_AUTHENTICATION_BROKEN: |
| + return "INSECURE"; |
| + case SECURITY_STYLE_WARNING: |
| + return "WARNING"; |
| + case SECURITY_STYLE_AUTHENTICATED: |
| + return "SECURE"; |
| + default: |
|
estark
2015/06/04 01:09:14
Same comment here that I put in the other CL; I pr
pfeldman
2015/06/04 09:28:35
@estark: it is a good idea here, but don't do that
lgarron
2015/06/05 01:29:18
Good point. I'll leave it this way for now.
|
| + NOTREACHED(); |
| + } |
| +} |
| + |
| +} // namespace security |
| +} // namespace devtools |
| +} // namespace content |