Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/dom_ui/net_internals_ui.cc

Issue 5228004: Switch the about:gpu implementation from an about handler to dom_ui.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/dom_ui/gpu_internals_ui.cc ('k') | chrome/browser/resources/gpu_internals.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" 25 #include "chrome/browser/dom_ui/chrome_url_data_manager.h"
26 #include "chrome/browser/io_thread.h" 26 #include "chrome/browser/io_thread.h"
27 #include "chrome/browser/net/chrome_net_log.h" 27 #include "chrome/browser/net/chrome_net_log.h"
28 #include "chrome/browser/net/connection_tester.h" 28 #include "chrome/browser/net/connection_tester.h"
29 #include "chrome/browser/net/passive_log_collector.h" 29 #include "chrome/browser/net/passive_log_collector.h"
30 #include "chrome/browser/net/url_fixer_upper.h" 30 #include "chrome/browser/net/url_fixer_upper.h"
31 #include "chrome/browser/platform_util.h" 31 #include "chrome/browser/platform_util.h"
32 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
34 #include "chrome/common/chrome_version_info.h" 34 #include "chrome/common/chrome_version_info.h"
35 #include "chrome/common/jstemplate_builder.h"
35 #include "chrome/common/net/url_request_context_getter.h" 36 #include "chrome/common/net/url_request_context_getter.h"
36 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
37 #include "grit/generated_resources.h" 38 #include "grit/generated_resources.h"
38 #include "grit/net_internals_resources.h" 39 #include "grit/net_internals_resources.h"
39 #include "net/base/escape.h" 40 #include "net/base/escape.h"
40 #include "net/base/host_resolver_impl.h" 41 #include "net/base/host_resolver_impl.h"
41 #include "net/base/net_errors.h" 42 #include "net/base/net_errors.h"
42 #include "net/base/net_util.h" 43 #include "net/base/net_util.h"
43 #include "net/base/sys_addrinfo.h" 44 #include "net/base/sys_addrinfo.h"
44 #include "net/disk_cache/disk_cache.h" 45 #include "net/disk_cache/disk_cache.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // 313 //
313 //////////////////////////////////////////////////////////////////////////////// 314 ////////////////////////////////////////////////////////////////////////////////
314 315
315 NetInternalsHTMLSource::NetInternalsHTMLSource() 316 NetInternalsHTMLSource::NetInternalsHTMLSource()
316 : DataSource(chrome::kChromeUINetInternalsHost, MessageLoop::current()) { 317 : DataSource(chrome::kChromeUINetInternalsHost, MessageLoop::current()) {
317 } 318 }
318 319
319 void NetInternalsHTMLSource::StartDataRequest(const std::string& path, 320 void NetInternalsHTMLSource::StartDataRequest(const std::string& path,
320 bool is_off_the_record, 321 bool is_off_the_record,
321 int request_id) { 322 int request_id) {
323 DictionaryValue localized_strings;
324 SetFontAndTextDirection(&localized_strings);
325
322 // The provided "path" may contain a fragment, or query section. We only 326 // The provided "path" may contain a fragment, or query section. We only
323 // care about the path itself, and will disregard anything else. 327 // care about the path itself, and will disregard anything else.
324 std::string filename = 328 std::string filename =
325 GURL(std::string("chrome://net/") + path).path().substr(1); 329 GURL(std::string("chrome://net/") + path).path().substr(1);
326 330
327 // The source for the net internals page is flattened during compilation, so 331 // The source for the net internals page is flattened during compilation, so
328 // the only resource that should legitimately be requested is the main file. 332 // the only resource that should legitimately be requested is the main file.
329 // Note that users can type anything into the address bar, though, so we must 333 // Note that users can type anything into the address bar, though, so we must
330 // handle arbitrary input. 334 // handle arbitrary input.
331 if (filename.empty() || filename == "index.html") { 335 if (filename.empty() || filename == "index.html") {
332 scoped_refptr<RefCountedStaticMemory> bytes( 336 base::StringPiece html(
333 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 337 ResourceBundle::GetSharedInstance().GetRawDataResource(
334 IDR_NET_INTERNALS_INDEX_HTML)); 338 IDR_NET_INTERNALS_INDEX_HTML));
335 if (bytes && bytes->front()) { 339 std::string full_html(html.data(), html.size());
336 SendResponse(request_id, bytes); 340 jstemplate_builder::AppendJsonHtml(&localized_strings, &full_html);
337 return; 341 jstemplate_builder::AppendI18nTemplateSourceHtml(&full_html);
338 } 342 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html);
343 jstemplate_builder::AppendJsTemplateSourceHtml(&full_html);
344
345 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
346 html_bytes->data.resize(full_html.size());
347 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin());
348 SendResponse(request_id, html_bytes);
349 return;
339 } 350 }
340 351
341 const std::string data_string("<p style='color:red'>Failed to read resource" + 352 const std::string data_string("<p style='color:red'>Failed to read resource" +
342 EscapeForHTML(filename) + "</p>"); 353 EscapeForHTML(filename) + "</p>");
343 scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes); 354 scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes);
344 bytes->data.resize(data_string.size()); 355 bytes->data.resize(data_string.size());
345 std::copy(data_string.begin(), data_string.end(), bytes->data.begin()); 356 std::copy(data_string.begin(), data_string.end(), bytes->data.begin());
346 SendResponse(request_id, bytes); 357 SendResponse(request_id, bytes);
347 } 358 }
348 359
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); 1035 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource();
1025 1036
1026 // Set up the chrome://net-internals/ source. 1037 // Set up the chrome://net-internals/ source.
1027 BrowserThread::PostTask( 1038 BrowserThread::PostTask(
1028 BrowserThread::IO, FROM_HERE, 1039 BrowserThread::IO, FROM_HERE,
1029 NewRunnableMethod( 1040 NewRunnableMethod(
1030 Singleton<ChromeURLDataManager>::get(), 1041 Singleton<ChromeURLDataManager>::get(),
1031 &ChromeURLDataManager::AddDataSource, 1042 &ChromeURLDataManager::AddDataSource,
1032 make_scoped_refptr(html_source))); 1043 make_scoped_refptr(html_source)));
1033 } 1044 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/gpu_internals_ui.cc ('k') | chrome/browser/resources/gpu_internals.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698