summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui/net_internals_ui.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-21 22:12:39 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-21 22:12:39 +0000
commit26c2b23471dafa0db5254e28907e3741b98ac3ed (patch)
tree805b9575d20911ef40791e48910700584afdd847 /chrome/browser/dom_ui/net_internals_ui.cc
parent7b1bf816970d76ef2a062f3bd1e235e7e584746b (diff)
downloadchromium_src-26c2b23471dafa0db5254e28907e3741b98ac3ed.zip
chromium_src-26c2b23471dafa0db5254e28907e3741b98ac3ed.tar.gz
chromium_src-26c2b23471dafa0db5254e28907e3741b98ac3ed.tar.bz2
Speculatively revert 50374 (miniinstaller breakage) - Load netinternals resources from resources.pak.
This is the same as r50257 with 2 fixes: 1) Copy resources.pak to <(PRODUCT_DIR) on mac so it will work for things tests. 2) Add back the check in chrome_paths.cc to see if we're in a mac bundle or not. BUG=35793,42770 TEST=none Review URL: http://codereview.chromium.org/2865010 TBR=erg@chromium.org Review URL: http://codereview.chromium.org/2799022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50392 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui/net_internals_ui.cc')
-rw-r--r--chrome/browser/dom_ui/net_internals_ui.cc78
1 files changed, 35 insertions, 43 deletions
diff --git a/chrome/browser/dom_ui/net_internals_ui.cc b/chrome/browser/dom_ui/net_internals_ui.cc
index 96ee59e..553d197 100644
--- a/chrome/browser/dom_ui/net_internals_ui.cc
+++ b/chrome/browser/dom_ui/net_internals_ui.cc
@@ -36,8 +36,6 @@
#include "chrome/common/net/url_request_context_getter.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
-#include "grit/net_internals_resources.h"
-#include "grit/net_internals_resources_map.h"
#include "net/base/escape.h"
#include "net/base/host_resolver_impl.h"
#include "net/base/net_errors.h"
@@ -318,57 +316,51 @@ NetInternalsHTMLSource::NetInternalsHTMLSource()
void NetInternalsHTMLSource::StartDataRequest(const std::string& path,
bool is_off_the_record,
int request_id) {
+ // The provided |path| identifies a file in resources/net_internals/.
+ std::string data_string;
+ FilePath file_path;
+ PathService::Get(chrome::DIR_NET_INTERNALS, &file_path);
+ std::string filename;
+
// The provided "path" may contain a fragment, or query section. We only
// care about the path itself, and will disregard anything else.
- std::string filename =
- GURL(std::string("chrome://net/") + path).path().substr(1);
+ filename = GURL(std::string("chrome://net/") + path).path().substr(1);
+
if (filename.empty())
filename = "index.html";
- // The name of the files in the grd list are prefixed with the following
- // directory:
- std::string key("net_internals/");
- key += filename;
-
- const ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- for (size_t i = 0; i < kNetInternalsResourcesSize; ++i) {
- if (kNetInternalsResources[i].name == key) {
- scoped_refptr<RefCountedStaticMemory> bytes(
- rb.LoadDataResourceBytes(kNetInternalsResources[i].value));
- if (bytes && bytes->front()) {
- SendResponse(request_id, bytes);
- return;
- }
- }
+ file_path = file_path.AppendASCII(filename);
+
+ if (!file_util::ReadFileToString(file_path, &data_string)) {
+ LOG(WARNING) << "Could not read resource: " << file_path.value();
+ data_string = StringPrintf("<p style='color:red'>Failed to read file "
+ "RESOURCES/net_internals/%s</p>",
+ EscapeForHTML(filename).c_str());
+
+ // During the transition from old implementation to new implementation,
+ // users may be entering the URLs for the old frontend.
+ data_string.append(
+ "<p>Note that the URL scheme for net-internals has changed because of "
+ "its new implementation (bug 37421):</p>"
+ "<ul>"
+ "<li>chrome://net-internals/proxyservice.* &rarr; "
+ "<a href='chrome://net-internals#proxy'>chrome://net-internals#proxy"
+ "</a></li>"
+ "<li>chrome://net-internals/hostresolver.* &rarr; <a href='chrome://net"
+ "-internals#dns'>chrome://net-internals#dns</a></li>"
+ "<li>chrome://net-internals/urlrequest.* &rarr; <a href='chrome://net-"
+ "internals#requests'>chrome://net-internals#requests</a></li>"
+ "<li>chrome://net-internals/ (overview for copy-pasting) &rarr; <a href"
+ "='chrome://net-internals#data'>chrome://net-internals#data</a></li>"
+ "<li>chrome://net-internals/view-cache/* &rarr; <a href="
+ "'chrome://view-http-cache'>chrome://view-http-cache</a></li>"
+ "</ul>");
}
- LOG(WARNING) << "Could not read resource: " << path;
- std::string data_string = "<p style='color:red'>Failed to read resource";
- data_string.append(EscapeForHTML(filename));
- data_string.append("</p>");
-
- // During the transition from old implementation to new implementation,
- // users may be entering the URLs for the old frontend.
- data_string.append(
- "<p>Note that the URL scheme for net-internals has changed because of "
- "its new implementation (bug 37421):</p>"
- "<ul>"
- "<li>chrome://net-internals/proxyservice.* &rarr; "
- "<a href='chrome://net-internals#proxy'>chrome://net-internals#proxy"
- "</a></li>"
- "<li>chrome://net-internals/hostresolver.* &rarr; <a href='chrome://net"
- "-internals#dns'>chrome://net-internals#dns</a></li>"
- "<li>chrome://net-internals/urlrequest.* &rarr; <a href='chrome://net-"
- "internals#requests'>chrome://net-internals#requests</a></li>"
- "<li>chrome://net-internals/ (overview for copy-pasting) &rarr; <a href"
- "='chrome://net-internals#data'>chrome://net-internals#data</a></li>"
- "<li>chrome://net-internals/view-cache/* &rarr; <a href="
- "'chrome://view-http-cache'>chrome://view-http-cache</a></li>"
- "</ul>");
-
scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes);
bytes->data.resize(data_string.size());
std::copy(data_string.begin(), data_string.end(), bytes->data.begin());
+
SendResponse(request_id, bytes);
}