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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 if (command == "version") { | 452 if (command == "version") { |
453 base::DictionaryValue version; | 453 base::DictionaryValue version; |
454 version.SetString("Protocol-Version", | 454 version.SetString("Protocol-Version", |
455 WebKit::WebDevToolsAgent::inspectorProtocolVersion()); | 455 WebKit::WebDevToolsAgent::inspectorProtocolVersion()); |
456 version.SetString("WebKit-Version", | 456 version.SetString("WebKit-Version", |
457 webkit_glue::GetWebKitVersion()); | 457 webkit_glue::GetWebKitVersion()); |
458 version.SetString("Browser", | 458 version.SetString("Browser", |
459 content::GetContentClient()->GetProduct()); | 459 content::GetContentClient()->GetProduct()); |
460 version.SetString("User-Agent", | 460 version.SetString("User-Agent", |
461 webkit_glue::GetUserAgent(GURL(chrome::kAboutBlankURL))); | 461 webkit_glue::GetUserAgent(GURL(chrome::kAboutBlankURL))); |
462 SendJson(connection_id, net::HTTP_OK, &version, ""); | 462 SendJson(connection_id, net::HTTP_OK, &version, std::string()); |
463 return; | 463 return; |
464 } | 464 } |
465 | 465 |
466 if (command == "list") { | 466 if (command == "list") { |
467 typedef std::vector<PageInfo> PageList; | 467 typedef std::vector<PageInfo> PageList; |
468 PageList page_list; | 468 PageList page_list; |
469 | 469 |
470 std::vector<RenderViewHost*> rvh_list = | 470 std::vector<RenderViewHost*> rvh_list = |
471 DevToolsAgentHost::GetValidRenderViewHosts(); | 471 DevToolsAgentHost::GetValidRenderViewHosts(); |
472 for (std::vector<RenderViewHost*>::iterator it = rvh_list.begin(); | 472 for (std::vector<RenderViewHost*>::iterator it = rvh_list.begin(); |
(...skipping 26 matching lines...) Expand all Loading... |
499 RenderViewHost* rvh = delegate_->CreateNewTarget(); | 499 RenderViewHost* rvh = delegate_->CreateNewTarget(); |
500 if (!rvh) { | 500 if (!rvh) { |
501 SendJson(connection_id, | 501 SendJson(connection_id, |
502 net::HTTP_INTERNAL_SERVER_ERROR, | 502 net::HTTP_INTERNAL_SERVER_ERROR, |
503 NULL, | 503 NULL, |
504 "Could not create new page"); | 504 "Could not create new page"); |
505 return; | 505 return; |
506 } | 506 } |
507 std::string host = info.headers["Host"]; | 507 std::string host = info.headers["Host"]; |
508 scoped_ptr<base::DictionaryValue> dictionary(SerializePageInfo(rvh, host)); | 508 scoped_ptr<base::DictionaryValue> dictionary(SerializePageInfo(rvh, host)); |
509 SendJson(connection_id, net::HTTP_OK, dictionary.get(), ""); | 509 SendJson(connection_id, net::HTTP_OK, dictionary.get(), std::string()); |
510 return; | 510 return; |
511 } | 511 } |
512 | 512 |
513 if (command == "activate" || command == "close") { | 513 if (command == "activate" || command == "close") { |
514 DevToolsAgentHost* agent_host = binding_->ForIdentifier(target_id); | 514 DevToolsAgentHost* agent_host = binding_->ForIdentifier(target_id); |
515 RenderViewHost* rvh = agent_host ? agent_host->GetRenderViewHost() : NULL; | 515 RenderViewHost* rvh = agent_host ? agent_host->GetRenderViewHost() : NULL; |
516 if (!rvh) { | 516 if (!rvh) { |
517 SendJson(connection_id, | 517 SendJson(connection_id, |
518 net::HTTP_NOT_FOUND, | 518 net::HTTP_NOT_FOUND, |
519 NULL, | 519 NULL, |
(...skipping 25 matching lines...) Expand all Loading... |
545 | 545 |
546 std::vector<WorkerService::WorkerInfo> worker_info = | 546 std::vector<WorkerService::WorkerInfo> worker_info = |
547 WorkerService::GetInstance()->GetWorkers(); | 547 WorkerService::GetInstance()->GetWorkers(); |
548 | 548 |
549 for (size_t i = 0; i < worker_info.size(); ++i) | 549 for (size_t i = 0; i < worker_info.size(); ++i) |
550 target_list->Append(SerializeWorkerInfo(worker_info[i], host)); | 550 target_list->Append(SerializeWorkerInfo(worker_info[i], host)); |
551 } | 551 } |
552 | 552 |
553 void DevToolsHttpHandlerImpl::SendTargetList(int connection_id, | 553 void DevToolsHttpHandlerImpl::SendTargetList(int connection_id, |
554 ListValue* target_list) { | 554 ListValue* target_list) { |
555 SendJson(connection_id, net::HTTP_OK, target_list, ""); | 555 SendJson(connection_id, net::HTTP_OK, target_list, std::string()); |
556 delete target_list; | 556 delete target_list; |
557 Release(); // Balanced OnJsonRequestUI. | 557 Release(); // Balanced OnJsonRequestUI. |
558 } | 558 } |
559 | 559 |
560 void DevToolsHttpHandlerImpl::OnThumbnailRequestUI( | 560 void DevToolsHttpHandlerImpl::OnThumbnailRequestUI( |
561 int connection_id, const GURL& page_url) { | 561 int connection_id, const GURL& page_url) { |
562 std::string data = delegate_->GetPageThumbnailData(page_url); | 562 std::string data = delegate_->GetPageThumbnailData(page_url); |
563 if (!data.empty()) | 563 if (!data.empty()) |
564 Send200(connection_id, data, "image/png"); | 564 Send200(connection_id, data, "image/png"); |
565 else | 565 else |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 host.c_str(), | 851 host.c_str(), |
852 kPageUrlPrefix, | 852 kPageUrlPrefix, |
853 id.c_str())); | 853 id.c_str())); |
854 std::string devtools_frontend_url = GetFrontendURLInternal( | 854 std::string devtools_frontend_url = GetFrontendURLInternal( |
855 id.c_str(), | 855 id.c_str(), |
856 host); | 856 host); |
857 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 857 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
858 } | 858 } |
859 | 859 |
860 } // namespace content | 860 } // namespace content |
OLD | NEW |