OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/devtools_http_handler_impl.h" | 5 #include "content/browser/devtools/devtools_http_handler_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 Send500(connection_id, "No such target id: " + page_id); | 634 Send500(connection_id, "No such target id: " + page_id); |
635 return; | 635 return; |
636 } | 636 } |
637 | 637 |
638 if (agent->IsAttached()) { | 638 if (agent->IsAttached()) { |
639 Send500(connection_id, | 639 Send500(connection_id, |
640 "Target with given id is being inspected: " + page_id); | 640 "Target with given id is being inspected: " + page_id); |
641 return; | 641 return; |
642 } | 642 } |
643 | 643 |
644 DevToolsClientHostImpl* client_host = | 644 DevToolsClientHostImpl* client_host = new DevToolsClientHostImpl( |
645 new DevToolsClientHostImpl(thread_->message_loop(), | 645 thread_->message_loop(), server_.get(), connection_id); |
646 server_, | |
647 connection_id); | |
648 connection_to_client_host_ui_[connection_id] = client_host; | 646 connection_to_client_host_ui_[connection_id] = client_host; |
649 | 647 |
650 DevToolsManager::GetInstance()-> | 648 DevToolsManager::GetInstance()-> |
651 RegisterDevToolsClientHostFor(agent, client_host); | 649 RegisterDevToolsClientHostFor(agent, client_host); |
652 | 650 |
653 AcceptWebSocket(connection_id, request); | 651 AcceptWebSocket(connection_id, request); |
654 } | 652 } |
655 | 653 |
656 void DevToolsHttpHandlerImpl::OnWebSocketMessageUI( | 654 void DevToolsHttpHandlerImpl::OnWebSocketMessageUI( |
657 int connection_id, | 655 int connection_id, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 } | 809 } |
812 | 810 |
813 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializePageInfo( | 811 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializePageInfo( |
814 RenderViewHost* rvh, | 812 RenderViewHost* rvh, |
815 const std::string& host) { | 813 const std::string& host) { |
816 base::DictionaryValue* dictionary = new base::DictionaryValue; | 814 base::DictionaryValue* dictionary = new base::DictionaryValue; |
817 | 815 |
818 scoped_refptr<DevToolsAgentHost> agent( | 816 scoped_refptr<DevToolsAgentHost> agent( |
819 DevToolsAgentHost::GetOrCreateFor(rvh)); | 817 DevToolsAgentHost::GetOrCreateFor(rvh)); |
820 | 818 |
821 std::string id = binding_->GetIdentifier(agent); | 819 std::string id = binding_->GetIdentifier(agent.get()); |
822 dictionary->SetString(kTargetIdField, id); | 820 dictionary->SetString(kTargetIdField, id); |
823 | 821 |
824 switch (delegate_->GetTargetType(rvh)) { | 822 switch (delegate_->GetTargetType(rvh)) { |
825 case DevToolsHttpHandlerDelegate::kTargetTypeTab: | 823 case DevToolsHttpHandlerDelegate::kTargetTypeTab: |
826 dictionary->SetString(kTargetTypeField, kTargetTypePage); | 824 dictionary->SetString(kTargetTypeField, kTargetTypePage); |
827 break; | 825 break; |
828 default: | 826 default: |
829 dictionary->SetString(kTargetTypeField, kTargetTypeOther); | 827 dictionary->SetString(kTargetTypeField, kTargetTypeOther); |
830 } | 828 } |
831 | 829 |
(...skipping 21 matching lines...) Expand all Loading... |
853 } | 851 } |
854 | 852 |
855 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializeWorkerInfo( | 853 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializeWorkerInfo( |
856 const WorkerService::WorkerInfo& worker, | 854 const WorkerService::WorkerInfo& worker, |
857 const std::string& host) { | 855 const std::string& host) { |
858 base::DictionaryValue* dictionary = new base::DictionaryValue; | 856 base::DictionaryValue* dictionary = new base::DictionaryValue; |
859 | 857 |
860 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetForWorker( | 858 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetForWorker( |
861 worker.process_id, worker.route_id)); | 859 worker.process_id, worker.route_id)); |
862 | 860 |
863 std::string id = binding_->GetIdentifier(agent); | 861 std::string id = binding_->GetIdentifier(agent.get()); |
864 | 862 |
865 dictionary->SetString(kTargetIdField, id); | 863 dictionary->SetString(kTargetIdField, id); |
866 dictionary->SetString(kTargetTypeField, kTargetTypeOther); | 864 dictionary->SetString(kTargetTypeField, kTargetTypeOther); |
867 dictionary->SetString(kTargetTitleField, | 865 dictionary->SetString(kTargetTitleField, |
868 UTF16ToUTF8(net::EscapeForHTML(worker.name))); | 866 UTF16ToUTF8(net::EscapeForHTML(worker.name))); |
869 dictionary->SetString(kTargetUrlField, worker.url.spec()); | 867 dictionary->SetString(kTargetUrlField, worker.url.spec()); |
870 dictionary->SetString(kTargetDescriptionField, | 868 dictionary->SetString(kTargetDescriptionField, |
871 base::StringPrintf("Worker pid:%d", base::GetProcId(worker.handle))); | 869 base::StringPrintf("Worker pid:%d", base::GetProcId(worker.handle))); |
872 | 870 |
873 if (!agent->IsAttached()) | 871 if (!agent->IsAttached()) |
(...skipping 10 matching lines...) Expand all Loading... |
884 host.c_str(), | 882 host.c_str(), |
885 kPageUrlPrefix, | 883 kPageUrlPrefix, |
886 id.c_str())); | 884 id.c_str())); |
887 std::string devtools_frontend_url = GetFrontendURLInternal( | 885 std::string devtools_frontend_url = GetFrontendURLInternal( |
888 id.c_str(), | 886 id.c_str(), |
889 host); | 887 host); |
890 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 888 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
891 } | 889 } |
892 | 890 |
893 } // namespace content | 891 } // namespace content |
OLD | NEW |