• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/ui/webui/sync_internals_ui.h"
6 
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/webui/sync_internals_message_handler.h"
9 #include "chrome/common/url_constants.h"
10 #include "content/public/browser/web_ui.h"
11 #include "content/public/browser/web_ui_data_source.h"
12 #include "extensions/common/extension_messages.h"
13 #include "grit/sync_internals_resources.h"
14 #include "ui/base/resource/resource_bundle.h"
15 
16 namespace {
17 
CreateSyncInternalsHTMLSource()18 content::WebUIDataSource* CreateSyncInternalsHTMLSource() {
19   content::WebUIDataSource* source =
20       content::WebUIDataSource::Create(chrome::kChromeUISyncInternalsHost);
21 
22   source->SetUseJsonJSFormatV2();
23   source->SetJsonPath("strings.js");
24   source->AddResourcePath("sync_index.js", IDR_SYNC_INTERNALS_INDEX_JS);
25   source->AddResourcePath("chrome_sync.js",
26                           IDR_SYNC_INTERNALS_CHROME_SYNC_JS);
27   source->AddResourcePath("types.js", IDR_SYNC_INTERNALS_TYPES_JS);
28   source->AddResourcePath("sync_log.js", IDR_SYNC_INTERNALS_SYNC_LOG_JS);
29   source->AddResourcePath("sync_node_browser.js",
30                           IDR_SYNC_INTERNALS_SYNC_NODE_BROWSER_JS);
31   source->AddResourcePath("sync_search.js",
32                           IDR_SYNC_INTERNALS_SYNC_SEARCH_JS);
33   source->AddResourcePath("about.js", IDR_SYNC_INTERNALS_ABOUT_JS);
34   source->AddResourcePath("data.js", IDR_SYNC_INTERNALS_DATA_JS);
35   source->AddResourcePath("events.js", IDR_SYNC_INTERNALS_EVENTS_JS);
36   source->AddResourcePath("search.js", IDR_SYNC_INTERNALS_SEARCH_JS);
37   source->SetDefaultResource(IDR_SYNC_INTERNALS_INDEX_HTML);
38   return source;
39 }
40 
41 }  // namespace
42 
SyncInternalsUI(content::WebUI * web_ui)43 SyncInternalsUI::SyncInternalsUI(content::WebUI* web_ui)
44     : WebUIController(web_ui) {
45   Profile* profile = Profile::FromWebUI(web_ui);
46   content::WebUIDataSource::Add(profile, CreateSyncInternalsHTMLSource());
47 
48   web_ui->AddMessageHandler(new SyncInternalsMessageHandler);
49 }
50 
~SyncInternalsUI()51 SyncInternalsUI::~SyncInternalsUI() {}
52 
53