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> | |
| 8 | |
| 9 #include "base/logging.h" | |
|
estark
2015/06/09 05:18:54
not needed
lgarron
2015/06/09 18:16:57
Done.
(This got lost in a re-rebase. Thanks for c
| |
| 10 | |
| 7 namespace content { | 11 namespace content { |
| 8 namespace devtools { | 12 namespace devtools { |
| 9 namespace security { | 13 namespace security { |
| 10 | 14 |
| 11 typedef DevToolsProtocolClient::Response Response; | 15 typedef DevToolsProtocolClient::Response Response; |
| 12 | 16 |
| 13 SecurityHandler::SecurityHandler() { | 17 SecurityHandler::SecurityHandler() : enabled_(false), host_(nullptr) { |
| 14 } | 18 } |
| 15 | 19 |
| 16 SecurityHandler::~SecurityHandler() { | 20 SecurityHandler::~SecurityHandler() { |
| 17 } | 21 } |
| 18 | 22 |
| 19 void SecurityHandler::SetClient(scoped_ptr<Client> client) { | 23 void SecurityHandler::SetClient(scoped_ptr<Client> client) { |
| 24 client_.swap(client); | |
| 25 } | |
| 26 | |
| 27 void SecurityHandler::SetRenderFrameHost(RenderFrameHost* host) { | |
| 28 host_ = host; | |
| 29 if (enabled_ && host_) | |
| 30 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host_)); | |
| 31 } | |
| 32 | |
| 33 void SecurityHandler::SecurityStyleChanged(SecurityStyle security_style) { | |
| 34 if (!enabled_) | |
| 35 return; | |
| 36 | |
| 37 const std::string security_state = | |
| 38 SecurityStyleToProtocolSecurityState(security_style); | |
| 39 client_->SecurityStateChanged( | |
| 40 SecurityStateChangedParams::Create()->set_security_state(security_state)); | |
| 20 } | 41 } |
| 21 | 42 |
| 22 Response SecurityHandler::Enable() { | 43 Response SecurityHandler::Enable() { |
| 44 enabled_ = true; | |
| 45 if (host_) | |
| 46 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host_)); | |
| 23 return Response::OK(); | 47 return Response::OK(); |
| 24 } | 48 } |
| 25 | 49 |
| 26 Response SecurityHandler::Disable() { | 50 Response SecurityHandler::Disable() { |
| 51 enabled_ = false; | |
| 52 WebContentsObserver::Observe(nullptr); | |
| 27 return Response::OK(); | 53 return Response::OK(); |
| 28 } | 54 } |
| 29 | 55 |
| 56 std::string SecurityHandler::SecurityStyleToProtocolSecurityState( | |
| 57 SecurityStyle security_style) { | |
| 58 // TODO: Replace these values with literals once the Security domain has | |
|
estark
2015/06/09 05:18:54
You can do this TODO now, right? Since you're plan
lgarron
2015/06/09 18:16:57
Done.
| |
| 59 // landed in protocol.json. | |
| 60 switch (security_style) { | |
| 61 case SECURITY_STYLE_UNKNOWN: | |
| 62 return "unknown"; | |
| 63 case SECURITY_STYLE_UNAUTHENTICATED: | |
| 64 return "http"; | |
| 65 case SECURITY_STYLE_AUTHENTICATION_BROKEN: | |
| 66 return "insecure"; | |
| 67 case SECURITY_STYLE_WARNING: | |
| 68 return "warning"; | |
| 69 case SECURITY_STYLE_AUTHENTICATED: | |
| 70 return "secure"; | |
| 71 default: | |
| 72 NOTREACHED(); | |
| 73 } | |
| 74 } | |
| 75 | |
| 30 } // namespace security | 76 } // namespace security |
| 31 } // namespace devtools | 77 } // namespace devtools |
| 32 } // namespace content | 78 } // namespace content |
| OLD | NEW |