| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/dom_ui/net_internals_ui.h" | 5 #include "chrome/browser/dom_ui/net_internals_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // care about the path itself, and will disregard anything else. | 316 // care about the path itself, and will disregard anything else. |
| 317 filename = GURL(std::string("chrome://net/") + path).path().substr(1); | 317 filename = GURL(std::string("chrome://net/") + path).path().substr(1); |
| 318 | 318 |
| 319 if (filename.empty()) | 319 if (filename.empty()) |
| 320 filename = "index.html"; | 320 filename = "index.html"; |
| 321 | 321 |
| 322 file_path = file_path.AppendASCII(filename); | 322 file_path = file_path.AppendASCII(filename); |
| 323 | 323 |
| 324 if (!file_util::ReadFileToString(file_path, &data_string)) { | 324 if (!file_util::ReadFileToString(file_path, &data_string)) { |
| 325 LOG(WARNING) << "Could not read resource: " << file_path.value(); | 325 LOG(WARNING) << "Could not read resource: " << file_path.value(); |
| 326 data_string = StringPrintf( | 326 data_string = StringPrintf("<p style='color:red'>Failed to read file " |
| 327 "Failed to read file RESOURCES/net_internals/%s", | 327 "RESOURCES/net_internals/%s</p>", |
| 328 filename.c_str()); | 328 EscapeForHTML(filename).c_str()); |
| 329 |
| 330 // During the transition from old implementation to new implementation, |
| 331 // users may be entering the URLs for the old frontend. |
| 332 data_string.append( |
| 333 "<p>Note that the URL scheme for net-internals has changed because of " |
| 334 "its new implementation (bug 37421):</p>" |
| 335 "<ul>" |
| 336 "<li>chrome://net-internals/proxyservice.* → " |
| 337 "<a href='chrome://net-internals#proxy'>chrome://net-internals#proxy" |
| 338 "</a></li>" |
| 339 "<li>chrome://net-internals/hostresolver.* → <a href='chrome://net" |
| 340 "-internals#dns'>chrome://net-internals#dns</a></li>" |
| 341 "<li>chrome://net-internals/urlrequest.* → <a href='chrome://net-" |
| 342 "internals#requests'>chrome://net-internals#requests</a></li>" |
| 343 "<li>chrome://net-internals/ (overview for copy-pasting) → <a href" |
| 344 "='chrome://net-internals#data'>chrome://net-internals#data</a></li>" |
| 345 "<li>chrome://net-internals/view-cache/* → <a href=" |
| 346 "'chrome://view-http-cache'>chrome://view-http-cache</a></li>" |
| 347 "</ul>"); |
| 329 } | 348 } |
| 330 | 349 |
| 331 scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes); | 350 scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes); |
| 332 bytes->data.resize(data_string.size()); | 351 bytes->data.resize(data_string.size()); |
| 333 std::copy(data_string.begin(), data_string.end(), bytes->data.begin()); | 352 std::copy(data_string.begin(), data_string.end(), bytes->data.begin()); |
| 334 | 353 |
| 335 SendResponse(request_id, bytes); | 354 SendResponse(request_id, bytes); |
| 336 } | 355 } |
| 337 | 356 |
| 338 std::string NetInternalsHTMLSource::GetMimeType(const std::string&) const { | 357 std::string NetInternalsHTMLSource::GetMimeType(const std::string&) const { |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); | 851 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); |
| 833 | 852 |
| 834 // Set up the chrome://net-internals/ source. | 853 // Set up the chrome://net-internals/ source. |
| 835 ChromeThread::PostTask( | 854 ChromeThread::PostTask( |
| 836 ChromeThread::IO, FROM_HERE, | 855 ChromeThread::IO, FROM_HERE, |
| 837 NewRunnableMethod( | 856 NewRunnableMethod( |
| 838 Singleton<ChromeURLDataManager>::get(), | 857 Singleton<ChromeURLDataManager>::get(), |
| 839 &ChromeURLDataManager::AddDataSource, | 858 &ChromeURLDataManager::AddDataSource, |
| 840 make_scoped_refptr(html_source))); | 859 make_scoped_refptr(html_source))); |
| 841 } | 860 } |
| OLD | NEW |