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

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: Make SecurityHandler a WebContentsObserver itself and rebase onto stub CL. 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 4187a7639a86a199373d4fce0f7b748f30707096..3d6fbd435740fe40960c92216b859f09fee49613 100644
--- a/content/browser/devtools/protocol/security_handler.cc
+++ b/content/browser/devtools/protocol/security_handler.cc
@@ -4,29 +4,75 @@
#include "content/browser/devtools/protocol/security_handler.h"
+#include <string>
+
+#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
+
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<Client> client) {
+ client_.swap(client);
+}
+
+void SecurityHandler::SetRenderFrameHost(RenderFrameHost* host) {
+ 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) {
+ // 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.
+ // landed in protocol.json.
+ switch (security_style) {
+ case SECURITY_STYLE_UNKNOWN:
+ return "unknown";
+ 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:
+ NOTREACHED();
+ }
+}
+
} // namespace security
} // namespace devtools
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698