summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui/sync_internals_html_source.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/dom_ui/sync_internals_html_source.cc')
-rw-r--r--chrome/browser/dom_ui/sync_internals_html_source.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/chrome/browser/dom_ui/sync_internals_html_source.cc b/chrome/browser/dom_ui/sync_internals_html_source.cc
new file mode 100644
index 0000000..456c93f
--- /dev/null
+++ b/chrome/browser/dom_ui/sync_internals_html_source.cc
@@ -0,0 +1,49 @@
+// 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/dom_ui/sync_internals_html_source.h"
+
+#include <algorithm>
+
+#include "app/resource_bundle.h"
+#include "base/message_loop.h"
+#include "base/ref_counted.h"
+#include "base/ref_counted_memory.h"
+#include "base/string_piece.h"
+#include "base/values.h"
+#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/url_constants.h"
+#include "grit/sync_internals_resources.h"
+
+SyncInternalsHTMLSource::SyncInternalsHTMLSource()
+ : DataSource(chrome::kChromeUISyncInternalsHost,
+ MessageLoop::current()) {}
+
+SyncInternalsHTMLSource::~SyncInternalsHTMLSource() {}
+
+void SyncInternalsHTMLSource::StartDataRequest(const std::string& path,
+ bool is_off_the_record,
+ int request_id) {
+ base::StringPiece html_template(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_SYNC_INTERNALS_INDEX_HTML));
+ DictionaryValue localized_strings;
+ SetFontAndTextDirection(&localized_strings);
+
+ 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 SyncInternalsHTMLSource::GetMimeType(
+ const std::string& path) const {
+ return "text/html";
+}