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/debugger/devtools_http_handler_impl.h" | 5 #include "content/browser/debugger/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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 std::string devtools_frontend_url = GetFrontendURLInternal(i->id.c_str(), | 421 std::string devtools_frontend_url = GetFrontendURLInternal(i->id.c_str(), |
422 host); | 422 host); |
423 page_info->SetString("devtoolsFrontendUrl", devtools_frontend_url); | 423 page_info->SetString("devtoolsFrontendUrl", devtools_frontend_url); |
424 } | 424 } |
425 } | 425 } |
426 | 426 |
427 std::string response; | 427 std::string response; |
428 base::JSONWriter::WriteWithOptions(&json_pages_list, | 428 base::JSONWriter::WriteWithOptions(&json_pages_list, |
429 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 429 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
430 &response); | 430 &response); |
431 Send200(connection_id, response, "application/json; charset=UTF-8"); | 431 |
| 432 size_t jsonp_pos = info.path.find("?jsonp="); |
| 433 if (jsonp_pos == std::string::npos) { |
| 434 Send200(connection_id, response, "application/json; charset=UTF-8"); |
| 435 return; |
| 436 } |
| 437 |
| 438 std::string jsonp = info.path.substr(jsonp_pos + 7); |
| 439 response = StringPrintf("%s(%s);", jsonp.c_str(), response.c_str()); |
| 440 Send200(connection_id, response, "text/javascript; charset=UTF-8"); |
432 } | 441 } |
433 | 442 |
434 void DevToolsHttpHandlerImpl::OnWebSocketRequestUI( | 443 void DevToolsHttpHandlerImpl::OnWebSocketRequestUI( |
435 int connection_id, | 444 int connection_id, |
436 const net::HttpServerRequestInfo& request) { | 445 const net::HttpServerRequestInfo& request) { |
437 std::string prefix = "/devtools/page/"; | 446 std::string prefix = "/devtools/page/"; |
438 size_t pos = request.path.find(prefix); | 447 size_t pos = request.path.find(prefix); |
439 if (pos != 0) { | 448 if (pos != 0) { |
440 Send404(connection_id); | 449 Send404(connection_id); |
441 return; | 450 return; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 void DevToolsHttpHandlerImpl::AcceptWebSocket( | 645 void DevToolsHttpHandlerImpl::AcceptWebSocket( |
637 int connection_id, | 646 int connection_id, |
638 const net::HttpServerRequestInfo& request) { | 647 const net::HttpServerRequestInfo& request) { |
639 BrowserThread::PostTask( | 648 BrowserThread::PostTask( |
640 BrowserThread::IO, FROM_HERE, | 649 BrowserThread::IO, FROM_HERE, |
641 base::Bind(&net::HttpServer::AcceptWebSocket, server_.get(), | 650 base::Bind(&net::HttpServer::AcceptWebSocket, server_.get(), |
642 connection_id, request)); | 651 connection_id, request)); |
643 } | 652 } |
644 | 653 |
645 } // namespace content | 654 } // namespace content |
OLD | NEW |