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

Side by Side Diff: chrome/browser/ui/webui/net_internals_ui.cc

Issue 7397021: Re-land r93365 - add RefCountedString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 5 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/webui/net_internals_ui.h" 5 #include "chrome/browser/ui/webui/net_internals_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 if (filename.empty() || filename == "index.html") { 476 if (filename.empty() || filename == "index.html") {
477 base::StringPiece html( 477 base::StringPiece html(
478 ResourceBundle::GetSharedInstance().GetRawDataResource( 478 ResourceBundle::GetSharedInstance().GetRawDataResource(
479 IDR_NET_INTERNALS_INDEX_HTML)); 479 IDR_NET_INTERNALS_INDEX_HTML));
480 std::string full_html(html.data(), html.size()); 480 std::string full_html(html.data(), html.size());
481 jstemplate_builder::AppendJsonHtml(&localized_strings, &full_html); 481 jstemplate_builder::AppendJsonHtml(&localized_strings, &full_html);
482 jstemplate_builder::AppendI18nTemplateSourceHtml(&full_html); 482 jstemplate_builder::AppendI18nTemplateSourceHtml(&full_html);
483 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html); 483 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html);
484 jstemplate_builder::AppendJsTemplateSourceHtml(&full_html); 484 jstemplate_builder::AppendJsTemplateSourceHtml(&full_html);
485 485
486 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); 486 SendResponse(request_id, base::RefCountedString::TakeString(&full_html));
487 html_bytes->data.resize(full_html.size());
488 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin());
489 SendResponse(request_id, html_bytes);
490 return; 487 return;
491 } 488 }
492 489
493 const std::string data_string("<p style='color:red'>Failed to read resource" + 490 std::string data_string("<p style='color:red'>Failed to read resource" +
494 EscapeForHTML(filename) + "</p>"); 491 EscapeForHTML(filename) + "</p>");
495 scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes); 492 SendResponse(request_id, base::RefCountedString::TakeString(&data_string));
496 bytes->data.resize(data_string.size());
497 std::copy(data_string.begin(), data_string.end(), bytes->data.begin());
498 SendResponse(request_id, bytes);
499 } 493 }
500 494
501 std::string NetInternalsHTMLSource::GetMimeType(const std::string&) const { 495 std::string NetInternalsHTMLSource::GetMimeType(const std::string&) const {
502 return "text/html"; 496 return "text/html";
503 } 497 }
504 498
505 //////////////////////////////////////////////////////////////////////////////// 499 ////////////////////////////////////////////////////////////////////////////////
506 // 500 //
507 // NetInternalsMessageHandler 501 // NetInternalsMessageHandler
508 // 502 //
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 } 1607 }
1614 1608
1615 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { 1609 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) {
1616 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); 1610 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this));
1617 1611
1618 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); 1612 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource();
1619 1613
1620 // Set up the chrome://net-internals/ source. 1614 // Set up the chrome://net-internals/ source.
1621 GetProfile()->GetChromeURLDataManager()->AddDataSource(html_source); 1615 GetProfile()->GetChromeURLDataManager()->AddDataSource(html_source);
1622 } 1616 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/media/media_internals_ui.cc ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698