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

Unified 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 side-by-side diff with in-line comments
Download patch
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..86c965736c37b846569662b9602d446747ef1c80 100644
--- a/content/browser/devtools/protocol/security_handler.cc
+++ b/content/browser/devtools/protocol/security_handler.cc
@@ -4,29 +4,71 @@
#include "content/browser/devtools/protocol/security_handler.h"
+#include <string>
+
namespace content {
namespace devtools {
namespace security {
typedef DevToolsProtocolClient::Response Response;
-SecurityHandler::SecurityHandler() {
+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) {
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
+ host_ = host;
+ if (enabled_ && host_)
+ WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host_));
+}
+
+void SecurityHandler::SecurityStyleChanged(SecurityStyle security_style) {
+ if (!enabled_)
+ return;
+
+ 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();
}
+std::string SecurityHandler::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();
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
+ }
+}
+
} // namespace security
} // namespace devtools
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698