diff options
-rw-r--r-- | chrome/browser/resources/quota_internals/main.html | 5 | ||||
-rw-r--r-- | chrome/browser/resources/quota_internals_resources.grd | 4 | ||||
-rw-r--r-- | chrome/browser/ui/webui/quota_internals_ui.cc | 48 | ||||
-rw-r--r-- | chrome/browser/ui/webui/quota_internals_ui.h | 21 |
4 files changed, 26 insertions, 52 deletions
diff --git a/chrome/browser/resources/quota_internals/main.html b/chrome/browser/resources/quota_internals/main.html index f4293da..64972c4 100644 --- a/chrome/browser/resources/quota_internals/main.html +++ b/chrome/browser/resources/quota_internals/main.html @@ -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"> diff --git a/chrome/browser/resources/quota_internals_resources.grd b/chrome/browser/resources/quota_internals_resources.grd index 81f44f1..2443fb2 100644 --- a/chrome/browser/resources/quota_internals_resources.grd +++ b/chrome/browser/resources/quota_internals_resources.grd @@ -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> diff --git a/chrome/browser/ui/webui/quota_internals_ui.cc b/chrome/browser/ui/webui/quota_internals_ui.cc index 1e15f18..1b658a3 100644 --- a/chrome/browser/ui/webui/quota_internals_ui.cc +++ b/chrome/browser/ui/webui/quota_internals_ui.cc @@ -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 diff --git a/chrome/browser/ui/webui/quota_internals_ui.h b/chrome/browser/ui/webui/quota_internals_ui.h index d805b2b..29077d4 100644 --- a/chrome/browser/ui/webui/quota_internals_ui.h +++ b/chrome/browser/ui/webui/quota_internals_ui.h @@ -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_ |