| 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 return true; | 418 return true; |
| 419 } | 419 } |
| 420 | 420 |
| 421 void DevToolsHttpHandlerImpl::OnJsonRequestUI( | 421 void DevToolsHttpHandlerImpl::OnJsonRequestUI( |
| 422 int connection_id, | 422 int connection_id, |
| 423 const net::HttpServerRequestInfo& info) { | 423 const net::HttpServerRequestInfo& info) { |
| 424 // Trim /json | 424 // Trim /json |
| 425 std::string path = info.path.substr(5); | 425 std::string path = info.path.substr(5); |
| 426 | 426 |
| 427 // Trim fragment and query | 427 // Trim fragment and query |
| 428 std::string query; | |
| 429 size_t query_pos = path.find("?"); | 428 size_t query_pos = path.find("?"); |
| 430 if (query_pos != std::string::npos) { | 429 if (query_pos != std::string::npos) |
| 431 query = path.substr(query_pos + 1); | |
| 432 path = path.substr(0, query_pos); | 430 path = path.substr(0, query_pos); |
| 433 } | |
| 434 | 431 |
| 435 size_t fragment_pos = path.find("#"); | 432 size_t fragment_pos = path.find("#"); |
| 436 if (fragment_pos != std::string::npos) | 433 if (fragment_pos != std::string::npos) |
| 437 path = path.substr(0, fragment_pos); | 434 path = path.substr(0, fragment_pos); |
| 438 | 435 |
| 439 std::string command; | 436 std::string command; |
| 440 std::string target_id; | 437 std::string target_id; |
| 441 if (!ParseJsonPath(path, &command, &target_id)) { | 438 if (!ParseJsonPath(path, &command, &target_id)) { |
| 442 SendJson(connection_id, | 439 SendJson(connection_id, |
| 443 net::HTTP_NOT_FOUND, | 440 net::HTTP_NOT_FOUND, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 460 if (command == "list") { | 457 if (command == "list") { |
| 461 std::string host = info.headers["host"]; | 458 std::string host = info.headers["host"]; |
| 462 AddRef(); // Balanced in OnTargetListReceived. | 459 AddRef(); // Balanced in OnTargetListReceived. |
| 463 delegate_->EnumerateTargets( | 460 delegate_->EnumerateTargets( |
| 464 base::Bind(&DevToolsHttpHandlerImpl::OnTargetListReceived, | 461 base::Bind(&DevToolsHttpHandlerImpl::OnTargetListReceived, |
| 465 this, connection_id, host)); | 462 this, connection_id, host)); |
| 466 return; | 463 return; |
| 467 } | 464 } |
| 468 | 465 |
| 469 if (command == "new") { | 466 if (command == "new") { |
| 470 GURL url(net::UnescapeURLComponent( | 467 scoped_ptr<DevToolsTarget> target(delegate_->CreateNewTarget()); |
| 471 query, net::UnescapeRule::URL_SPECIAL_CHARS)); | |
| 472 if (!url.is_valid()) | |
| 473 url = GURL(kAboutBlankURL); | |
| 474 scoped_ptr<DevToolsTarget> target(delegate_->CreateNewTarget(url)); | |
| 475 if (!target) { | 468 if (!target) { |
| 476 SendJson(connection_id, | 469 SendJson(connection_id, |
| 477 net::HTTP_INTERNAL_SERVER_ERROR, | 470 net::HTTP_INTERNAL_SERVER_ERROR, |
| 478 NULL, | 471 NULL, |
| 479 "Could not create new page"); | 472 "Could not create new page"); |
| 480 return; | 473 return; |
| 481 } | 474 } |
| 482 std::string host = info.headers["host"]; | 475 std::string host = info.headers["host"]; |
| 483 scoped_ptr<base::DictionaryValue> dictionary( | 476 scoped_ptr<base::DictionaryValue> dictionary( |
| 484 SerializeTarget(*target.get(), host)); | 477 SerializeTarget(*target.get(), host)); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 id.c_str(), | 765 id.c_str(), |
| 773 host); | 766 host); |
| 774 dictionary->SetString( | 767 dictionary->SetString( |
| 775 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 768 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
| 776 } | 769 } |
| 777 | 770 |
| 778 return dictionary; | 771 return dictionary; |
| 779 } | 772 } |
| 780 | 773 |
| 781 } // namespace content | 774 } // namespace content |
| OLD | NEW |