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

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

Issue 7003064: Add placeholder chrome://media-internals page. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add placeholder chrome://media-internals page. Created 9 years, 6 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/ui/webui/media_internals_ui.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/media_internals_ui.cc
diff --git a/chrome/browser/ui/webui/media_internals_ui.cc b/chrome/browser/ui/webui/media_internals_ui.cc
new file mode 100644
index 0000000000000000000000000000000000000000..de2f4227113effe68db6fbd58a91fd8c1faac324
--- /dev/null
+++ b/chrome/browser/ui/webui/media_internals_ui.cc
@@ -0,0 +1,86 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/media_internals_ui.h"
+
+#include "base/memory/ref_counted_memory.h"
+#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
+#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/url_constants.h"
+#include "grit/browser_resources.h"
+#include "ui/base/resource/resource_bundle.h"
+
+namespace {
+
+class MediaInternalsHTMLSource : public ChromeURLDataManager::DataSource {
+ public:
+ MediaInternalsHTMLSource();
+
+ // 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& path) const;
+
+ private:
+ virtual ~MediaInternalsHTMLSource() {}
+ DISALLOW_COPY_AND_ASSIGN(MediaInternalsHTMLSource);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// MediaInternalsHTMLSource
+//
+////////////////////////////////////////////////////////////////////////////////
+
+MediaInternalsHTMLSource::MediaInternalsHTMLSource()
+ : DataSource(chrome::kChromeUIMediaInternalsHost, MessageLoop::current()) {
+}
+
+void MediaInternalsHTMLSource::StartDataRequest(const std::string& path,
+ bool is_incognito,
+ int request_id) {
+ DictionaryValue localized_strings;
+ SetFontAndTextDirection(&localized_strings);
+
+ base::StringPiece html_template(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_MEDIA_INTERNALS_HTML));
+ std::string html(html_template.data(), html_template.size());
+ jstemplate_builder::AppendI18nTemplateSourceHtml(&html);
+ jstemplate_builder::AppendJsTemplateSourceHtml(&html);
+ jstemplate_builder::AppendJsonHtml(&localized_strings, &html);
+ jstemplate_builder::AppendI18nTemplateProcessHtml(&html);
+
+ scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes());
+ bytes->data.resize(html.size());
+ std::copy(html.begin(), html.end(), bytes->data.begin());
+
+ SendResponse(request_id, bytes);
+}
+
+std::string MediaInternalsHTMLSource::GetMimeType(
+ const std::string& path) const {
+ return "text/html";
+}
+
+} // namespace
+
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// MediaInternalsUI
+//
+////////////////////////////////////////////////////////////////////////////////
+
+MediaInternalsUI::MediaInternalsUI(TabContents* contents)
+ : ChromeWebUI(contents) {
+ contents->profile()->GetChromeURLDataManager()->AddDataSource(
+ new MediaInternalsHTMLSource());
+}
+
« no previous file with comments | « chrome/browser/ui/webui/media_internals_ui.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698