Commit 56b63485 authored by tsepez@chromium.org's avatar tsepez@chromium.org

Add content-security-policy to chrome://quota-internals.

Review URL: http://codereview.chromium.org/7637026

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96630 0039d316-1c4b-4281-b951-d872f2087c98
parent 457aae7d
......@@ -5,6 +5,7 @@ Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<html i18n-values="dir:textdirection;">
<include src="../content_security_policy.html"/>
<title>Quota Internals</title>
<link rel="stylesheet" href="main.css"/>
......@@ -21,8 +22,8 @@ found in the LICENSE file.
<script src="chrome://resources/css/tree.css.js"></script>
<script src="chrome://resources/js/cr/ui/focus_outline_manager.js"></script>
<script src="message_dispatcher.js"></script>
<script src="event_handler.js"></script>
<script src="chrome://quota-internals/message_dispatcher.js"></script>
<script src="chrome://quota-internals/event_handler.js"></script>
<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
......
......@@ -10,7 +10,9 @@
</outputs>
<release seq="1">
<includes>
<include name="IDR_QUOTA_INTERNALS_MAIN_HTML" file="quota_internals/main.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_QUOTA_INTERNALS_MAIN_HTML" file="quota_internals/main.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_QUOTA_INTERNALS_EVENT_HANDLER_JS" file="quota_internals/event_handler.js" type="BINDATA" />
<include name="IDR_QUOTA_INTERNALS_MESSAGE_DISPATCHER_JS" file="quota_internals/message_dispatcher.js" type="BINDATA" />
</includes>
</release>
</grit>
......@@ -8,6 +8,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/browser/ui/webui/quota_internals_handler.h"
#include "chrome/common/url_constants.h"
#include "content/browser/tab_contents/tab_contents.h"
......@@ -16,38 +17,29 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
QuotaInternalsUI::QuotaInternalsUI(TabContents* contents)
: ChromeWebUI(contents) {
WebUIMessageHandler* handler = new quota_internals::QuotaInternalsHandler;
AddMessageHandler(handler->Attach(this));
Profile* profile = Profile::FromBrowserContext(contents->browser_context());
profile->GetChromeURLDataManager()->AddDataSource(
new quota_internals::QuotaInternalsHTMLSource);
}
namespace quota_internals {
namespace {
const char QuotaInternalsHTMLSource::kStringsJSPath[] = "strings.js";
ChromeWebUIDataSource* CreateQuotaInternalsHTMLSource() {
ChromeWebUIDataSource* source =
new ChromeWebUIDataSource(chrome::kChromeUIQuotaInternalsHost);
QuotaInternalsHTMLSource::QuotaInternalsHTMLSource()
: ChromeWebUIDataSource(chrome::kChromeUIQuotaInternalsHost) {
source->set_json_path("strings.js");
source->add_resource_path(
"event_handler.js", IDR_QUOTA_INTERNALS_EVENT_HANDLER_JS);
source->add_resource_path(
"message_dispatcher.js", IDR_QUOTA_INTERNALS_MESSAGE_DISPATCHER_JS);
source->set_default_resource(IDR_QUOTA_INTERNALS_MAIN_HTML);
return source;
}
void QuotaInternalsHTMLSource::StartDataRequest(const std::string& path,
bool is_incognito,
int request_id) {
if (path == kStringsJSPath)
SendLocalizedStringsAsJSON(request_id);
else
SendFromResourceBundle(request_id, IDR_QUOTA_INTERNALS_MAIN_HTML);
}
} // namespace
std::string QuotaInternalsHTMLSource::GetMimeType(
const std::string& path) const {
if (path == kStringsJSPath)
return "application/javascript";
else
return "text/html";
QuotaInternalsUI::QuotaInternalsUI(TabContents* contents)
: ChromeWebUI(contents) {
WebUIMessageHandler* handler = new quota_internals::QuotaInternalsHandler;
AddMessageHandler(handler->Attach(this));
Profile* profile = Profile::FromBrowserContext(contents->browser_context());
profile->GetChromeURLDataManager()->AddDataSource(
CreateQuotaInternalsHTMLSource());
}
} // namespace quota_internals
......@@ -9,7 +9,6 @@
#include <string>
#include "chrome/browser/ui/webui/chrome_web_ui.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
class QuotaInternalsUI : public ChromeWebUI {
public:
......@@ -19,24 +18,4 @@ class QuotaInternalsUI : public ChromeWebUI {
DISALLOW_COPY_AND_ASSIGN(QuotaInternalsUI);
};
namespace quota_internals {
class QuotaInternalsHTMLSource : public ChromeWebUIDataSource {
public:
static const char kStringsJSPath[];
QuotaInternalsHTMLSource();
virtual void StartDataRequest(const std::string& path,
bool is_incognito,
int request_id) OVERRIDE;
virtual std::string GetMimeType(const std::string& path) const OVERRIDE;
private:
virtual ~QuotaInternalsHTMLSource() {}
DISALLOW_COPY_AND_ASSIGN(QuotaInternalsHTMLSource);
};
} // namespace quota_internals
#endif // CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_UI_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment