Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: content/browser/devtools/protocol/security_handler.cc

Issue 1163963002: Implement SecurityHandler to send the lock icon status to DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change destructor to override. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
7 namespace content { 9 namespace content {
8 namespace devtools { 10 namespace devtools {
9 namespace security { 11 namespace security {
10 12
11 typedef DevToolsProtocolClient::Response Response; 13 typedef DevToolsProtocolClient::Response Response;
12 14
13 SecurityHandler::SecurityHandler() { 15 SecurityHandler::SecurityHandler() : enabled_(false), host_(nullptr) {
14 } 16 }
15 17
16 SecurityHandler::~SecurityHandler() { 18 SecurityHandler::~SecurityHandler() {
17 } 19 }
18 20
19 void SecurityHandler::SetClient(scoped_ptr<DevToolsProtocolClient> client) { 21 void SecurityHandler::SetClient(scoped_ptr<Client> client) {
22 client_.swap(client);
23 }
24
25 void SecurityHandler::SetRenderFrameHost(RenderFrameHost* host) {
estark 2015/06/09 21:51:45 swap these two definitions (SetRFH and SecuritySty
lgarron 2015/06/09 22:12:09 I've swapped the declarations in the .h (which kee
26 host_ = host;
27 if (enabled_ && host_)
28 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host_));
29 }
30
31 void SecurityHandler::SecurityStyleChanged(SecurityStyle security_style) {
32 if (!enabled_)
33 return;
34
35 const std::string security_state =
36 SecurityStyleToProtocolSecurityState(security_style);
37 client_->SecurityStateChanged(
38 SecurityStateChangedParams::Create()->set_security_state(security_state));
20 } 39 }
21 40
22 Response SecurityHandler::Enable() { 41 Response SecurityHandler::Enable() {
42 enabled_ = true;
43 if (host_)
44 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host_));
23 return Response::OK(); 45 return Response::OK();
24 } 46 }
25 47
26 Response SecurityHandler::Disable() { 48 Response SecurityHandler::Disable() {
49 enabled_ = false;
50 WebContentsObserver::Observe(nullptr);
27 return Response::OK(); 51 return Response::OK();
28 } 52 }
29 53
54 std::string SecurityHandler::SecurityStyleToProtocolSecurityState(
55 SecurityStyle security_style) {
56 switch (security_style) {
57 case SECURITY_STYLE_UNKNOWN:
58 return kSecurityStateUnknown;
59 case SECURITY_STYLE_UNAUTHENTICATED:
60 return kSecurityStateHttp;
61 case SECURITY_STYLE_AUTHENTICATION_BROKEN:
62 return kSecurityStateInsecure;
63 case SECURITY_STYLE_WARNING:
64 return kSecurityStateWarning;
65 case SECURITY_STYLE_AUTHENTICATED:
66 return kSecurityStateSecure;
67 default:
68 NOTREACHED();
estark 2015/06/09 21:51:45 I think builds on some platforms will fail without
lgarron 2015/06/09 22:12:09 Done (although I admit, I kind of want to see some
69 }
70 }
71
30 } // namespace security 72 } // namespace security
31 } // namespace devtools 73 } // namespace devtools
32 } // namespace content 74 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698