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

Unified Diff: chrome/browser/ui/webui/gpu_internals_ui.cc

Issue 7411004: Apply content-security-policy to chrome://gpu-internals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/gpu_internals.js ('k') | chrome/test/functional/special_tabs.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/gpu_internals_ui.cc
===================================================================
--- chrome/browser/ui/webui/gpu_internals_ui.cc (revision 93892)
+++ chrome/browser/ui/webui/gpu_internals_ui.cc (working copy)
@@ -29,6 +29,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/shell_dialogs.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/jstemplate_builder.h"
@@ -49,22 +50,16 @@
namespace {
-class GpuHTMLSource : public ChromeURLDataManager::DataSource {
- public:
- GpuHTMLSource();
+ChromeWebUIDataSource* CreateGpuHTMLSource() {
+ ChromeWebUIDataSource* source =
+ new ChromeWebUIDataSource(chrome::kChromeUIGpuInternalsHost);
- // Called when the network layer has requested a resource underneath
- // the path we registered.
- virtual void StartDataRequest(const std::string& path,
- bool is_incognito,
- int request_id);
- virtual std::string GetMimeType(const std::string&) const;
+ source->set_json_path("strings.js");
+ source->add_resource_path("gpu_internals.js", IDR_GPU_INTERNALS_JS);
+ source->set_default_resource(IDR_GPU_INTERNALS_HTML);
+ return source;
+}
- private:
- ~GpuHTMLSource() {}
- DISALLOW_COPY_AND_ASSIGN(GpuHTMLSource);
-};
-
// This class receives javascript messages from the renderer.
// Note that the WebUI infrastructure runs on the UI thread, therefore all of
// this class's methods are expected to run on the UI thread.
@@ -151,39 +146,6 @@
////////////////////////////////////////////////////////////////////////////////
//
-// GpuHTMLSource
-//
-////////////////////////////////////////////////////////////////////////////////
-
-GpuHTMLSource::GpuHTMLSource()
- : DataSource(chrome::kChromeUIGpuInternalsHost, MessageLoop::current()) {
-}
-
-void GpuHTMLSource::StartDataRequest(const std::string& path,
- bool is_incognito,
- int request_id) {
- DictionaryValue localized_strings;
- SetFontAndTextDirection(&localized_strings);
-
- base::StringPiece gpu_html(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_GPU_INTERNALS_HTML));
- std::string full_html(gpu_html.data(), gpu_html.size());
- jstemplate_builder::AppendJsonHtml(&localized_strings, &full_html);
- jstemplate_builder::AppendI18nTemplateSourceHtml(&full_html);
- jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html);
- jstemplate_builder::AppendJsTemplateSourceHtml(&full_html);
-
-
- SendResponse(request_id, base::RefCountedString::TakeString(&full_html));
-}
-
-std::string GpuHTMLSource::GetMimeType(const std::string&) const {
- return "text/html";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
// GpuMessageHandler
//
////////////////////////////////////////////////////////////////////////////////
@@ -639,8 +601,7 @@
GpuInternalsUI::GpuInternalsUI(TabContents* contents) : ChromeWebUI(contents) {
AddMessageHandler((new GpuMessageHandler())->Attach(this));
- GpuHTMLSource* html_source = new GpuHTMLSource();
-
- // Set up the chrome://gpu/ source.
- contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
+ // Set up the chrome://gpu-internals/ source.
+ contents->profile()->GetChromeURLDataManager()->AddDataSource(
+ CreateGpuHTMLSource());
}
« no previous file with comments | « chrome/browser/resources/gpu_internals.js ('k') | chrome/test/functional/special_tabs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698