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. 4 5 #include "chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_ui.h" 6 7 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.h" 9 #include "chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.h" 10 #include "chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.h" 11 #include "chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.h" 12 #include "chrome/common/url_constants.h" 13 #include "content/public/browser/web_ui.h" 14 #include "content/public/browser/web_ui_data_source.h" 15 #include "grit/sync_file_system_internals_resources.h" 16 #include "ui/resources/grit/ui_resources.h" 17 18 namespace { 19 20 content::WebUIDataSource* CreateSyncFileSystemInternalsHTMLSource() { 21 content::WebUIDataSource* source = 22 content::WebUIDataSource::Create( 23 chrome::kChromeUISyncFileSystemInternalsHost); 24 source->SetUseJsonJSFormatV2(); 25 source->SetJsonPath("strings.js"); 26 source->AddResourcePath( 27 "utils.js", 28 IDR_SYNC_FILE_SYSTEM_INTERNALS_UTILS_JS); 29 source->AddResourcePath( 30 "extension_statuses.js", 31 IDR_SYNC_FILE_SYSTEM_INTERNALS_EXTENSION_STATUSES_JS); 32 source->AddResourcePath( 33 "file_metadata.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_FILE_METADATA_JS); 34 source->AddResourcePath( 35 "sync_service.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_SYNC_SERVICE_JS); 36 source->AddResourcePath( 37 "task_log.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_TASK_LOG_JS); 38 source->AddResourcePath( 39 "dump_database.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_DUMP_DATABASE_JS); 40 source->AddResourcePath("file.png", IDR_DEFAULT_FAVICON); 41 source->AddResourcePath("folder_closed.png", IDR_FOLDER_CLOSED); 42 source->SetDefaultResource(IDR_SYNC_FILE_SYSTEM_INTERNALS_MAIN_HTML); 43 return source; 44 } 45 46 } // namespace 47 48 SyncFileSystemInternalsUI::SyncFileSystemInternalsUI(content::WebUI* web_ui) 49 : WebUIController(web_ui) { 50 Profile* profile = Profile::FromWebUI(web_ui); 51 web_ui->AddMessageHandler( 52 new syncfs_internals::SyncFileSystemInternalsHandler(profile)); 53 web_ui->AddMessageHandler( 54 new syncfs_internals::ExtensionStatusesHandler(profile)); 55 web_ui->AddMessageHandler( 56 new syncfs_internals::FileMetadataHandler(profile)); 57 web_ui->AddMessageHandler( 58 new syncfs_internals::DumpDatabaseHandler(profile)); 59 content::WebUIDataSource::Add(profile, 60 CreateSyncFileSystemInternalsHTMLSource()); 61 } 62 63 SyncFileSystemInternalsUI::~SyncFileSystemInternalsUI() {} 64