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

Side by Side Diff: chrome/browser/ui/webui/media/media_internals_ui.cc

Issue 7638002: Apply content-security-policy directive to chrome://media-internals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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/media/media_internals_ui.h" 5 #include "chrome/browser/ui/webui/media/media_internals_ui.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
11 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
11 #include "chrome/browser/ui/webui/media/media_internals_handler.h" 12 #include "chrome/browser/ui/webui/media/media_internals_handler.h"
12 #include "chrome/common/jstemplate_builder.h" 13 #include "chrome/common/jstemplate_builder.h"
13 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
14 #include "grit/browser_resources.h" 15 #include "grit/browser_resources.h"
15 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
16 17
17 namespace { 18 namespace {
18 19
19 class MediaInternalsHTMLSource : public ChromeURLDataManager::DataSource { 20 ChromeWebUIDataSource* CreateMediaInternalsHTMLSource() {
20 public: 21 ChromeWebUIDataSource* source =
21 MediaInternalsHTMLSource(); 22 new ChromeWebUIDataSource(chrome::kChromeUIMediaInternalsHost);
22 23
23 // Called when the network layer has requested a resource underneath 24 source->set_json_path("strings.js");
24 // the path we registered. 25 source->add_resource_path("media_internals.js", IDR_MEDIA_INTERNALS_JS);
25 virtual void StartDataRequest(const std::string& path, 26 source->set_default_resource(IDR_MEDIA_INTERNALS_HTML);
26 bool is_incognito, 27 return source;
27 int request_id);
28 virtual std::string GetMimeType(const std::string& path) const;
29
30 private:
31 virtual ~MediaInternalsHTMLSource() {}
32 DISALLOW_COPY_AND_ASSIGN(MediaInternalsHTMLSource);
33 };
34
35 ////////////////////////////////////////////////////////////////////////////////
36 //
37 // MediaInternalsHTMLSource
38 //
39 ////////////////////////////////////////////////////////////////////////////////
40
41 MediaInternalsHTMLSource::MediaInternalsHTMLSource()
42 : DataSource(chrome::kChromeUIMediaInternalsHost, MessageLoop::current()) {
43 }
44
45 void MediaInternalsHTMLSource::StartDataRequest(const std::string& path,
46 bool is_incognito,
47 int request_id) {
48 DictionaryValue localized_strings;
49 SetFontAndTextDirection(&localized_strings);
50
51 base::StringPiece html_template(
52 ResourceBundle::GetSharedInstance().GetRawDataResource(
53 IDR_MEDIA_INTERNALS_HTML));
54 std::string html(html_template.data(), html_template.size());
55 jstemplate_builder::AppendI18nTemplateSourceHtml(&html);
56 jstemplate_builder::AppendJsTemplateSourceHtml(&html);
57 jstemplate_builder::AppendJsonHtml(&localized_strings, &html);
58 jstemplate_builder::AppendI18nTemplateProcessHtml(&html);
59
60 SendResponse(request_id, base::RefCountedString::TakeString(&html));
61 }
62
63 std::string MediaInternalsHTMLSource::GetMimeType(
64 const std::string& path) const {
65 return "text/html";
66 } 28 }
67 29
68 } // namespace 30 } // namespace
69 31
70 //////////////////////////////////////////////////////////////////////////////// 32 ////////////////////////////////////////////////////////////////////////////////
71 // 33 //
72 // MediaInternalsUI 34 // MediaInternalsUI
73 // 35 //
74 //////////////////////////////////////////////////////////////////////////////// 36 ////////////////////////////////////////////////////////////////////////////////
75 37
76 MediaInternalsUI::MediaInternalsUI(TabContents* contents) 38 MediaInternalsUI::MediaInternalsUI(TabContents* contents)
77 : ChromeWebUI(contents) { 39 : ChromeWebUI(contents) {
78 AddMessageHandler((new MediaInternalsMessageHandler())->Attach(this)); 40 AddMessageHandler((new MediaInternalsMessageHandler())->Attach(this));
79 41
80 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); 42 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
81 profile->GetChromeURLDataManager()->AddDataSource( 43 profile->GetChromeURLDataManager()->AddDataSource(
82 new MediaInternalsHTMLSource()); 44 CreateMediaInternalsHTMLSource());
83 } 45 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/media_internals/media_internals.js ('k') | chrome/test/functional/special_tabs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698