Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.cc

Issue 1205753002: Create chrome://device-emulator and add the ability to get a battery percentage and send an updated… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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("acPower", base::IntToString(
27 power_manager::PowerSupplyProperties_ExternalPower_AC));
28 html->AddString("usbPower", 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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698