local_discovery_ui.cc revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
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/local_discovery/local_discovery_ui.h" 6 7#include "chrome/browser/profiles/profile.h" 8#include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_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 "grit/browser_resources.h" 13#include "grit/generated_resources.h" 14 15namespace { 16 17content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() { 18 content::WebUIDataSource* source = 19 content::WebUIDataSource::Create(chrome::kChromeUIDevicesHost); 20 21 source->SetDefaultResource(IDR_LOCAL_DISCOVERY_HTML); 22 source->AddResourcePath("local_discovery.css", IDR_LOCAL_DISCOVERY_CSS); 23 source->AddResourcePath("local_discovery.js", IDR_LOCAL_DISCOVERY_JS); 24 25 source->SetUseJsonJSFormatV2(); 26 source->AddLocalizedString("serviceRegister", 27 IDS_LOCAL_DISCOVERY_SERVICE_REGISTER); 28 29 source->AddLocalizedString("registerConfirmMessage", 30 IDS_LOCAL_DISCOVERY_REGISTER_CONFIRMATION); 31 source->AddLocalizedString("registerUser", 32 IDS_LOCAL_DISCOVERY_REGISTER_USER); 33 source->AddLocalizedString("confirmRegistration", 34 IDS_LOCAL_DISCOVERY_CONFIRM_REGISTRATION); 35 source->AddLocalizedString("addingPrinter", 36 IDS_LOCAL_DISCOVERY_ADDING_PRINTER); 37 source->AddLocalizedString("addingError", 38 IDS_LOCAL_DISCOVERY_ERROR_OCURRED); 39 source->AddLocalizedString("addingErrorMessage", 40 IDS_LOCAL_DISCOVERY_ERROR_OCURRED_MESSAGE); 41 source->AddLocalizedString("addingMessage1", 42 IDS_LOCAL_DISCOVERY_ADDING_PRINTER_MESSAGE1); 43 source->AddLocalizedString("addingMessage2", 44 IDS_LOCAL_DISCOVERY_ADDING_PRINTER_MESSAGE2); 45 source->AddLocalizedString("registeredDevicesTitle", 46 IDS_LOCAL_DISCOVERY_REGISTERED_DEVICES_TITLE); 47 source->AddLocalizedString("unregisteredDevicesTitle", 48 IDS_LOCAL_DISCOVERY_UNREGISTERED_DEVICES_TITLE); 49 source->AddLocalizedString("devicesTitle", 50 IDS_LOCAL_DISCOVERY_DEVICES_PAGE_TITLE); 51 52 source->SetJsonPath("strings.js"); 53 54 source->DisableDenyXFrameOptions(); 55 56 return source; 57} 58 59} // namespace 60 61LocalDiscoveryUI::LocalDiscoveryUI(content::WebUI* web_ui) 62 : WebUIController(web_ui) { 63 // Set up the chrome://devices/ source. 64 Profile* profile = Profile::FromWebUI(web_ui); 65 content::WebUIDataSource::Add(profile, CreateLocalDiscoveryHTMLSource()); 66 67 // TODO(gene): Use LocalDiscoveryUIHandler to send updated to the devices 68 // page. For example 69 web_ui->AddMessageHandler(local_discovery::LocalDiscoveryUIHandler::Create()); 70} 71