| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "net/url_request/url_request_view_net_internals_job.h" | 5 #include "net/url_request/url_request_view_net_internals_job.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 | 529 |
| 530 bool URLRequestViewNetInternalsJob::GetData(std::string* mime_type, | 530 bool URLRequestViewNetInternalsJob::GetData(std::string* mime_type, |
| 531 std::string* charset, | 531 std::string* charset, |
| 532 std::string* data) const { | 532 std::string* data) const { |
| 533 mime_type->assign("text/html"); | 533 mime_type->assign("text/html"); |
| 534 charset->assign("UTF-8"); | 534 charset->assign("UTF-8"); |
| 535 | 535 |
| 536 URLRequestContext* context = request_->context(); | 536 URLRequestContext* context = request_->context(); |
| 537 std::string details = url_format_->GetDetails(request_->url()); | 537 std::string details = url_format_->GetDetails(request_->url()); |
| 538 | 538 |
| 539 data->clear(); |
| 540 |
| 541 // Use a different handler for "view-cache/*" subpaths. |
| 542 std::string cache_key; |
| 543 if (GetViewCacheKeyFromPath(details, &cache_key)) { |
| 544 GURL url = url_format_->MakeURL(kViewHttpCacheSubPath + std::string("/")); |
| 545 ViewCacheHelper::GetEntryInfoHTML(cache_key, context, url.spec(), data); |
| 546 return true; |
| 547 } |
| 548 |
| 539 std::string query; | 549 std::string query; |
| 540 | 550 |
| 541 // Split out the query parameters. | 551 // Split out the query parameters. |
| 542 std::string::size_type query_start = details.find('?'); | 552 std::string::size_type query_start = details.find('?'); |
| 543 if (query_start != std::string::npos) { | 553 if (query_start != std::string::npos) { |
| 544 if (query_start + 1 < details.size()) | 554 if (query_start + 1 < details.size()) |
| 545 query = details.substr(query_start + 1); | 555 query = details.substr(query_start + 1); |
| 546 details = details.substr(0, query_start); | 556 details = details.substr(0, query_start); |
| 547 } | 557 } |
| 548 | 558 |
| 549 data->clear(); | |
| 550 | |
| 551 // Use a different handler for "view-cache/*" subpaths. | |
| 552 std::string cache_key; | |
| 553 if (GetViewCacheKeyFromPath(details, &cache_key)) { | |
| 554 GURL url = url_format_->MakeURL(kViewHttpCacheSubPath + std::string("/")); | |
| 555 ViewCacheHelper::GetEntryInfoHTML(cache_key, context, url.spec(), data); | |
| 556 return true; | |
| 557 } | |
| 558 | |
| 559 data->append("<!DOCTYPE HTML>" | 559 data->append("<!DOCTYPE HTML>" |
| 560 "<html><head><title>Network internals</title>" | 560 "<html><head><title>Network internals</title>" |
| 561 "<style>" | 561 "<style>" |
| 562 "body { font-family: sans-serif; font-size: 0.8em; }\n" | 562 "body { font-family: sans-serif; font-size: 0.8em; }\n" |
| 563 "tt, code, pre { font-family: WebKitHack, monospace; }\n" | 563 "tt, code, pre { font-family: WebKitHack, monospace; }\n" |
| 564 ".subsection_body { margin: 10px 0 10px 2em; }\n" | 564 ".subsection_body { margin: 10px 0 10px 2em; }\n" |
| 565 ".subsection_title { font-weight: bold; }\n" | 565 ".subsection_title { font-weight: bold; }\n" |
| 566 "</style>" | 566 "</style>" |
| 567 "</head><body>" | 567 "</head><body>" |
| 568 "<p><a href='http://dev.chromium.org/" | 568 "<p><a href='http://dev.chromium.org/" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 584 } else { | 584 } else { |
| 585 data->append("<i>Nothing found for \""); | 585 data->append("<i>Nothing found for \""); |
| 586 data->append(EscapeForHTML(details)); | 586 data->append(EscapeForHTML(details)); |
| 587 data->append("\"</i>"); | 587 data->append("\"</i>"); |
| 588 } | 588 } |
| 589 | 589 |
| 590 data->append("</body></html>"); | 590 data->append("</body></html>"); |
| 591 | 591 |
| 592 return true; | 592 return true; |
| 593 } | 593 } |
| OLD | NEW |