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

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: Only attach SecurityHandler to top-level frames. 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
9 #include "content/public/browser/web_contents.h"
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 namespace {
18
19 std::string SecurityStyleToProtocolSecurityState(
20 SecurityStyle security_style) {
21 switch (security_style) {
22 case SECURITY_STYLE_UNKNOWN:
23 return kSecurityStateUnknown;
24 case SECURITY_STYLE_UNAUTHENTICATED:
25 return kSecurityStateHttp;
26 case SECURITY_STYLE_AUTHENTICATION_BROKEN:
27 return kSecurityStateInsecure;
28 case SECURITY_STYLE_WARNING:
29 return kSecurityStateWarning;
30 case SECURITY_STYLE_AUTHENTICATED:
31 return kSecurityStateSecure;
32 default:
33 NOTREACHED();
34 return kSecurityStateUnknown;
35 }
36 }
37
38 } // namespace
39
40 SecurityHandler::SecurityHandler()
41 : enabled_(false),
42 host_(nullptr) {
14 } 43 }
15 44
16 SecurityHandler::~SecurityHandler() { 45 SecurityHandler::~SecurityHandler() {
17 } 46 }
18 47
19 void SecurityHandler::SetClient(scoped_ptr<DevToolsProtocolClient> client) { 48 void SecurityHandler::SetClient(scoped_ptr<Client> client) {
49 client_.swap(client);
50 }
51
52 void SecurityHandler::SetRenderFrameHost(RenderFrameHost* host) {
53 host_ = host;
54 if (enabled_ && host_)
55 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host_));
56 }
57
58 void SecurityHandler::SecurityStyleChanged(SecurityStyle security_style) {
59 DCHECK(enabled_);
60
61 const std::string security_state =
62 SecurityStyleToProtocolSecurityState(security_style);
63 client_->SecurityStateChanged(
64 SecurityStateChangedParams::Create()->set_security_state(security_state));
20 } 65 }
21 66
22 Response SecurityHandler::Enable() { 67 Response SecurityHandler::Enable() {
68 enabled_ = true;
69 if (host_)
70 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host_));
23 return Response::OK(); 71 return Response::OK();
24 } 72 }
25 73
26 Response SecurityHandler::Disable() { 74 Response SecurityHandler::Disable() {
75 enabled_ = false;
76 WebContentsObserver::Observe(nullptr);
27 return Response::OK(); 77 return Response::OK();
28 } 78 }
29 79
30 } // namespace security 80 } // namespace security
31 } // namespace devtools 81 } // namespace devtools
32 } // namespace content 82 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/security_handler.h ('k') | content/browser/devtools/render_frame_devtools_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698