1 // Copyright 2013 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.
5 #include "chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_ui.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.h"
9 #include "chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.h"
10 #include "chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.h"
11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/web_ui.h"
13 #include "content/public/browser/web_ui_data_source.h"
14 #include "grit/sync_file_system_internals_resources.h"
15 #include "ui/ui_resources/grit/ui_resources.h"
19 content::WebUIDataSource* CreateSyncFileSystemInternalsHTMLSource() {
20 content::WebUIDataSource* source =
21 content::WebUIDataSource::Create(
22 chrome::kChromeUISyncFileSystemInternalsHost);
23 source->SetJsonPath("strings.js");
24 source->AddResourcePath(
26 IDR_SYNC_FILE_SYSTEM_INTERNALS_UTILS_JS);
27 source->AddResourcePath(
28 "extension_statuses.js",
29 IDR_SYNC_FILE_SYSTEM_INTERNALS_EXTENSION_STATUSES_JS);
30 source->AddResourcePath(
31 "file_metadata.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_FILE_METADATA_JS);
32 source->AddResourcePath(
33 "sync_service.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_SYNC_SERVICE_JS);
34 source->AddResourcePath("file.png", IDR_DEFAULT_FAVICON);
35 source->AddResourcePath("folder_closed.png", IDR_FOLDER_CLOSED);
36 source->SetDefaultResource(IDR_SYNC_FILE_SYSTEM_INTERNALS_MAIN_HTML);
42 SyncFileSystemInternalsUI::SyncFileSystemInternalsUI(content::WebUI* web_ui)
43 : WebUIController(web_ui) {
44 Profile* profile = Profile::FromWebUI(web_ui);
45 web_ui->AddMessageHandler(
46 new syncfs_internals::ExtensionStatusesHandler(profile));
47 web_ui->AddMessageHandler(
48 new syncfs_internals::FileMetadataHandler(profile));
49 web_ui->AddMessageHandler(
50 new syncfs_internals::SyncFileSystemInternalsHandler(profile));
51 content::WebUIDataSource::Add(profile,
52 CreateSyncFileSystemInternalsHTMLSource());
55 SyncFileSystemInternalsUI::~SyncFileSystemInternalsUI() {}