| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/network_handler.h" | 5 #include "content/browser/devtools/protocol/network_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 417 |
| 418 Response NetworkHandler::EmulateNetworkConditions( | 418 Response NetworkHandler::EmulateNetworkConditions( |
| 419 bool offline, | 419 bool offline, |
| 420 double latency, | 420 double latency, |
| 421 double download_throughput, | 421 double download_throughput, |
| 422 double upload_throughput, | 422 double upload_throughput, |
| 423 const std::string* connection_type) { | 423 const std::string* connection_type) { |
| 424 return Response::FallThrough(); | 424 return Response::FallThrough(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 Response NetworkHandler::GetCertificateDetails( | |
| 428 int certificate_id, | |
| 429 scoped_refptr<CertificateDetails>* result) { | |
| 430 scoped_refptr<net::X509Certificate> cert; | |
| 431 content::CertStore* cert_store = CertStore::GetInstance(); | |
| 432 cert_store->RetrieveCert(certificate_id, &cert); | |
| 433 if (!cert.get()) | |
| 434 return Response::InvalidParams("certificateId"); | |
| 435 | |
| 436 std::string name(cert->subject().GetDisplayName()); | |
| 437 std::string issuer(cert->issuer().GetDisplayName()); | |
| 438 base::Time valid_from = cert->valid_start(); | |
| 439 base::Time valid_to = cert->valid_expiry(); | |
| 440 | |
| 441 std::vector<std::string> dns_names; | |
| 442 std::vector<std::string> ip_addrs; | |
| 443 cert->GetSubjectAltName(&dns_names, &ip_addrs); | |
| 444 | |
| 445 // IP addresses are in raw network bytes and must be converted to string form | |
| 446 std::vector<std::string> ip_addrs_string; | |
| 447 for (const std::string& ip : ip_addrs) { | |
| 448 net::IPAddress ip_addr(reinterpret_cast<const uint8_t*>(ip.c_str()), | |
| 449 ip.length()); | |
| 450 ip_addrs_string.push_back(ip_addr.ToString()); | |
| 451 } | |
| 452 | |
| 453 *result = CertificateDetails::Create() | |
| 454 ->set_subject(CertificateSubject::Create() | |
| 455 ->set_name(name) | |
| 456 ->set_san_dns_names(dns_names) | |
| 457 ->set_san_ip_addresses(ip_addrs_string)) | |
| 458 ->set_issuer(issuer) | |
| 459 ->set_valid_from(valid_from.ToDoubleT()) | |
| 460 ->set_valid_to(valid_to.ToDoubleT()); | |
| 461 return Response::OK(); | |
| 462 } | |
| 463 | |
| 464 Response NetworkHandler::ShowCertificateViewer(int certificate_id) { | 427 Response NetworkHandler::ShowCertificateViewer(int certificate_id) { |
| 465 if (!host_) | 428 if (!host_) |
| 466 return Response::InternalError("Could not connect to view"); | 429 return Response::InternalError("Could not connect to view"); |
| 467 WebContents* web_contents = WebContents::FromRenderFrameHost(host_); | 430 WebContents* web_contents = WebContents::FromRenderFrameHost(host_); |
| 468 web_contents->GetDelegate()->ShowCertificateViewerInDevTools( | 431 web_contents->GetDelegate()->ShowCertificateViewerInDevTools( |
| 469 web_contents, certificate_id); | 432 web_contents, certificate_id); |
| 470 return Response::OK(); | 433 return Response::OK(); |
| 471 } | 434 } |
| 472 | 435 |
| 473 } // namespace network | 436 } // namespace network |
| 474 } // namespace devtools | 437 } // namespace devtools |
| 475 } // namespace content | 438 } // namespace content |
| OLD | NEW |