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 "chrome/browser/devtools/devtools_ui_bindings.h" | 5 #include "chrome/browser/devtools/devtools_ui_bindings.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 file_system_path)); | 674 file_system_path)); |
675 } | 675 } |
676 | 676 |
677 void DevToolsUIBindings::SetWhitelistedShortcuts(const std::string& message) { | 677 void DevToolsUIBindings::SetWhitelistedShortcuts(const std::string& message) { |
678 delegate_->SetWhitelistedShortcuts(message); | 678 delegate_->SetWhitelistedShortcuts(message); |
679 } | 679 } |
680 | 680 |
681 void DevToolsUIBindings::ShowCertificateViewer(const std::string& cert_chain) { | 681 void DevToolsUIBindings::ShowCertificateViewer(const std::string& cert_chain) { |
682 std::unique_ptr<base::Value> value = | 682 std::unique_ptr<base::Value> value = |
683 base::JSONReader::Read(cert_chain); | 683 base::JSONReader::Read(cert_chain); |
684 if (!value || value->GetType() != base::Value::TYPE_LIST) | 684 if (!value || value->GetType() != base::Value::TYPE_LIST) { |
| 685 NOTREACHED(); |
685 return; | 686 return; |
| 687 } |
686 | 688 |
687 std::unique_ptr<base::ListValue> list = | 689 std::unique_ptr<base::ListValue> list = |
688 base::ListValue::From(std::move(value)); | 690 base::ListValue::From(std::move(value)); |
689 std::vector<base::StringPiece> cert_string_piece; | 691 std::vector<std::string> decoded; |
690 for (size_t i = 0; i < list->GetSize(); ++i) { | 692 for (size_t i = 0; i < list->GetSize(); ++i) { |
691 base::Value* item; | 693 base::Value* item; |
692 if (!list->Get(i, &item) || item->GetType() != base::Value::TYPE_STRING) | 694 if (!list->Get(i, &item) || item->GetType() != base::Value::TYPE_STRING) { |
| 695 NOTREACHED(); |
693 return; | 696 return; |
694 cert_string_piece.push_back( | 697 } |
695 *static_cast<base::StringValue*>(item)->GetString()); | 698 std::string temp; |
| 699 if (!item->GetAsString(&temp)) { |
| 700 NOTREACHED(); |
| 701 return; |
| 702 } |
| 703 if (!base::Base64Decode(temp, &temp)) { |
| 704 NOTREACHED(); |
| 705 return; |
| 706 } |
| 707 decoded.push_back(temp); |
696 } | 708 } |
| 709 |
| 710 std::vector<base::StringPiece> cert_string_piece; |
| 711 for (const auto& str : decoded) |
| 712 cert_string_piece.push_back(str); |
697 scoped_refptr<net::X509Certificate> cert = | 713 scoped_refptr<net::X509Certificate> cert = |
698 net::X509Certificate::CreateFromDERCertChain(cert_string_piece); | 714 net::X509Certificate::CreateFromDERCertChain(cert_string_piece); |
699 if (!cert) | 715 if (!cert) { |
| 716 NOTREACHED(); |
700 return; | 717 return; |
| 718 } |
701 | 719 |
702 // TODO(jam): temporarily add the certificate to the cert store to get an ID | 720 // TODO(jam): temporarily add the certificate to the cert store to get an ID |
703 // so that we don't have to change the WCD method signature | 721 // so that we don't have to change the WCD method signature |
704 // (will be done in followups). | 722 // (will be done in followups). |
705 if (!agent_host_ || !agent_host_->GetWebContents()) | 723 if (!agent_host_ || !agent_host_->GetWebContents()) |
706 return; | 724 return; |
707 content::WebContents* inspected_wc = agent_host_->GetWebContents(); | 725 content::WebContents* inspected_wc = agent_host_->GetWebContents(); |
708 content::RenderProcessHost* rph = inspected_wc->GetRenderProcessHost(); | 726 content::RenderProcessHost* rph = inspected_wc->GetRenderProcessHost(); |
709 int cert_id = content::CertStore::GetInstance()->StoreCert( | 727 int cert_id = content::CertStore::GetInstance()->StoreCert( |
710 cert.get(), rph->GetID()); | 728 cert.get(), rph->GetID()); |
711 web_contents_->GetDelegate()->ShowCertificateViewerInDevTools( | 729 web_contents_->GetDelegate()->ShowCertificateViewerInDevTools( |
712 web_contents_, cert_id); | 730 inspected_wc, cert_id); |
713 } | 731 } |
714 | 732 |
715 void DevToolsUIBindings::ZoomIn() { | 733 void DevToolsUIBindings::ZoomIn() { |
716 zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_IN); | 734 zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_IN); |
717 } | 735 } |
718 | 736 |
719 void DevToolsUIBindings::ZoomOut() { | 737 void DevToolsUIBindings::ZoomOut() { |
720 zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_OUT); | 738 zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_OUT); |
721 } | 739 } |
722 | 740 |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 void DevToolsUIBindings::FrontendLoaded() { | 1154 void DevToolsUIBindings::FrontendLoaded() { |
1137 if (frontend_loaded_) | 1155 if (frontend_loaded_) |
1138 return; | 1156 return; |
1139 frontend_loaded_ = true; | 1157 frontend_loaded_ = true; |
1140 | 1158 |
1141 // Call delegate first - it seeds importants bit of information. | 1159 // Call delegate first - it seeds importants bit of information. |
1142 delegate_->OnLoadCompleted(); | 1160 delegate_->OnLoadCompleted(); |
1143 | 1161 |
1144 AddDevToolsExtensionsToClient(); | 1162 AddDevToolsExtensionsToClient(); |
1145 } | 1163 } |
OLD | NEW |