| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright 2015 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/chromeos/emulator/device_emulator_ui.h" | 
|  | 6 | 
|  | 7 #include "base/strings/string_number_conversions.h" | 
|  | 8 #include "base/values.h" | 
|  | 9 #include "chrome/browser/profiles/profile.h" | 
|  | 10 #include "chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_hand
    ler.h" | 
|  | 11 #include "chrome/common/url_constants.h" | 
|  | 12 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | 
|  | 13 #include "content/public/browser/web_ui.h" | 
|  | 14 #include "content/public/browser/web_ui_data_source.h" | 
|  | 15 #include "grit/browser_resources.h" | 
|  | 16 #include "grit/generated_resources.h" | 
|  | 17 | 
|  | 18 namespace { | 
|  | 19 | 
|  | 20 // Create data source for chrome://device-emulator/. | 
|  | 21 content::WebUIDataSource* CreateDeviceEmulatorUIDataSource() { | 
|  | 22   content::WebUIDataSource* html = | 
|  | 23       content::WebUIDataSource::Create(chrome::kChromeUIDeviceEmulatorHost); | 
|  | 24 | 
|  | 25   // Add variables for the JS to use. | 
|  | 26   html->AddString("AC_POWER", base::IntToString( | 
|  | 27       power_manager::PowerSupplyProperties_ExternalPower_AC)); | 
|  | 28   html->AddString("USB_POWER", base::IntToString( | 
|  | 29       power_manager::PowerSupplyProperties_ExternalPower_USB)); | 
|  | 30   html->AddString("DISCONNECTED", base::IntToString( | 
|  | 31       power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED)); | 
|  | 32   html->SetJsonPath("strings.js"); | 
|  | 33 | 
|  | 34   // Add resources. | 
|  | 35   html->AddResourcePath("device_emulator.css", IDR_DEVICE_EMULATOR_CSS); | 
|  | 36   html->AddResourcePath("device_emulator.js", IDR_DEVICE_EMULATOR_JS); | 
|  | 37   html->SetDefaultResource(IDR_DEVICE_EMULATOR_HTML); | 
|  | 38 | 
|  | 39   return html; | 
|  | 40 } | 
|  | 41 | 
|  | 42 }  // namespace | 
|  | 43 | 
|  | 44 DeviceEmulatorUI::DeviceEmulatorUI(content::WebUI* web_ui) | 
|  | 45     : WebUIController(web_ui) { | 
|  | 46   web_ui->AddMessageHandler(new DeviceEmulatorMessageHandler()); | 
|  | 47 | 
|  | 48   Profile* profile = Profile::FromWebUI(web_ui); | 
|  | 49   content::WebUIDataSource::Add(profile, CreateDeviceEmulatorUIDataSource()); | 
|  | 50 } | 
|  | 51 | 
|  | 52 DeviceEmulatorUI::~DeviceEmulatorUI() { | 
|  | 53 } | 
| OLD | NEW | 
|---|