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

Unified Diff: content/browser/devtools/protocol/security_handler.cc

Issue 2567343003: Revert of [DevTools] Migrate security handler to new generator. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « content/browser/devtools/protocol/security_handler.h ('k') | content/browser/devtools/protocol_config.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2074fa6e6ee7d6c322a7d319e2dc1f99f8fcbe64..f21ff9f9453a470f342bc6bfe42b94dcf40433ea 100644
--- a/content/browser/devtools/protocol/security_handler.cc
+++ b/content/browser/devtools/protocol/security_handler.cc
@@ -6,7 +6,7 @@
#include <string>
-#include "content/browser/frame_host/render_frame_host_impl.h"
+#include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/security_style_explanations.h"
@@ -15,9 +15,10 @@
#include "content/public/browser/web_contents_delegate.h"
namespace content {
-namespace protocol {
+namespace devtools {
+namespace security {
-using Explanations = protocol::Array<Security::SecurityStateExplanation>;
+typedef DevToolsProtocolClient::Response Response;
namespace {
@@ -25,32 +26,33 @@
blink::WebSecurityStyle security_style) {
switch (security_style) {
case blink::WebSecurityStyleUnknown:
- return Security::SecurityStateEnum::Unknown;
+ return kSecurityStateUnknown;
case blink::WebSecurityStyleUnauthenticated:
- return Security::SecurityStateEnum::Neutral;
+ return kSecurityStateNeutral;
case blink::WebSecurityStyleAuthenticationBroken:
- return Security::SecurityStateEnum::Insecure;
+ return kSecurityStateInsecure;
case blink::WebSecurityStyleWarning:
- return Security::SecurityStateEnum::Warning;
+ return kSecurityStateWarning;
case blink::WebSecurityStyleAuthenticated:
- return Security::SecurityStateEnum::Secure;
+ return kSecurityStateSecure;
default:
NOTREACHED();
- return Security::SecurityStateEnum::Unknown;
+ return kSecurityStateUnknown;
}
}
void AddExplanations(
const std::string& security_style,
const std::vector<SecurityStyleExplanation>& explanations_to_add,
- Explanations* explanations) {
+ std::vector<scoped_refptr<SecurityStateExplanation>>* explanations) {
for (const auto& it : explanations_to_add) {
- explanations->addItem(Security::SecurityStateExplanation::Create()
- .SetSecurityState(security_style)
- .SetSummary(it.summary)
- .SetDescription(it.description)
- .SetHasCertificate(it.has_certificate)
- .Build());
+ scoped_refptr<SecurityStateExplanation> explanation =
+ SecurityStateExplanation::Create()
+ ->set_security_state(security_style)
+ ->set_summary(it.summary)
+ ->set_description(it.description)
+ ->set_has_certificate(it.has_certificate);
+ explanations->push_back(explanation);
}
}
@@ -64,9 +66,8 @@
SecurityHandler::~SecurityHandler() {
}
-void SecurityHandler::Wire(UberDispatcher* dispatcher) {
- frontend_.reset(new Security::Frontend(dispatcher->channel()));
- Security::Dispatcher::wire(dispatcher, this);
+void SecurityHandler::SetClient(std::unique_ptr<Client> client) {
+ client_.swap(client);
}
void SecurityHandler::AttachToRenderFrameHost() {
@@ -79,7 +80,7 @@
DidChangeVisibleSecurityState();
}
-void SecurityHandler::SetRenderFrameHost(RenderFrameHostImpl* host) {
+void SecurityHandler::SetRenderFrameHost(RenderFrameHost* host) {
host_ = host;
if (enabled_ && host_)
AttachToRenderFrameHost();
@@ -96,42 +97,42 @@
const std::string security_state =
SecurityStyleToProtocolSecurityState(security_style);
- std::unique_ptr<Explanations> explanations = Explanations::create();
- AddExplanations(Security::SecurityStateEnum::Insecure,
+ std::vector<scoped_refptr<SecurityStateExplanation>> explanations;
+ AddExplanations(kSecurityStateInsecure,
security_style_explanations.broken_explanations,
- explanations.get());
- AddExplanations(Security::SecurityStateEnum::Neutral,
+ &explanations);
+ AddExplanations(kSecurityStateNeutral,
security_style_explanations.unauthenticated_explanations,
- explanations.get());
- AddExplanations(Security::SecurityStateEnum::Secure,
+ &explanations);
+ AddExplanations(kSecurityStateSecure,
security_style_explanations.secure_explanations,
- explanations.get());
- AddExplanations(Security::SecurityStateEnum::Info,
- security_style_explanations.info_explanations,
- explanations.get());
+ &explanations);
+ AddExplanations(kSecurityStateInfo,
+ security_style_explanations.info_explanations, &explanations);
- std::unique_ptr<Security::InsecureContentStatus> insecure_content_status =
- Security::InsecureContentStatus::Create()
- .SetRanMixedContent(security_style_explanations.ran_mixed_content)
- .SetDisplayedMixedContent(
+ scoped_refptr<InsecureContentStatus> insecure_content_status =
+ InsecureContentStatus::Create()
+ ->set_ran_mixed_content(security_style_explanations.ran_mixed_content)
+ ->set_displayed_mixed_content(
security_style_explanations.displayed_mixed_content)
- .SetRanContentWithCertErrors(
+ ->set_ran_content_with_cert_errors(
security_style_explanations.ran_content_with_cert_errors)
- .SetDisplayedContentWithCertErrors(
+ ->set_displayed_content_with_cert_errors(
security_style_explanations.displayed_content_with_cert_errors)
- .SetRanInsecureContentStyle(SecurityStyleToProtocolSecurityState(
+ ->set_ran_insecure_content_style(SecurityStyleToProtocolSecurityState(
security_style_explanations.ran_insecure_content_style))
- .SetDisplayedInsecureContentStyle(
+ ->set_displayed_insecure_content_style(
SecurityStyleToProtocolSecurityState(
security_style_explanations
- .displayed_insecure_content_style))
- .Build();
+ .displayed_insecure_content_style));
- frontend_->SecurityStateChanged(
- security_state,
- std::move(explanations),
- std::move(insecure_content_status),
- security_style_explanations.scheme_is_cryptographic);
+ client_->SecurityStateChanged(
+ SecurityStateChangedParams::Create()
+ ->set_security_state(security_state)
+ ->set_scheme_is_cryptographic(
+ security_style_explanations.scheme_is_cryptographic)
+ ->set_insecure_content_status(insecure_content_status)
+ ->set_explanations(explanations));
}
Response SecurityHandler::Enable() {
@@ -150,16 +151,17 @@
Response SecurityHandler::ShowCertificateViewer() {
if (!host_)
- return Response::InternalError();
+ return Response::InternalError("Could not connect to view");
WebContents* web_contents = WebContents::FromRenderFrameHost(host_);
scoped_refptr<net::X509Certificate> certificate =
web_contents->GetController().GetVisibleEntry()->GetSSL().certificate;
if (!certificate)
- return Response::Error("Could not find certificate");
+ return Response::InternalError("Could not find certificate");
web_contents->GetDelegate()->ShowCertificateViewerInDevTools(
web_contents, certificate);
return Response::OK();
}
-} // namespace protocol
+} // namespace security
+} // namespace devtools
} // namespace content
« no previous file with comments | « content/browser/devtools/protocol/security_handler.h ('k') | content/browser/devtools/protocol_config.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698