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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.cc
diff --git a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.cc b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d4fc0f85b1a2bfcd84f865273e35421d8174e0cd
--- /dev/null
+++ b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.cc
@@ -0,0 +1,53 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.h"
+
+#include "base/strings/string_number_conversions.h"
+#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h"
+#include "chrome/common/url_constants.h"
+#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "grit/browser_resources.h"
+#include "grit/generated_resources.h"
+
+namespace {
+
+// Create data source for chrome://device-emulator/.
+content::WebUIDataSource* CreateDeviceEmulatorUIDataSource() {
+ content::WebUIDataSource* html =
+ content::WebUIDataSource::Create(chrome::kChromeUIDeviceEmulatorHost);
+
+ // Add variables for the JS to use.
+ html->AddString("acPower", base::IntToString(
+ power_manager::PowerSupplyProperties_ExternalPower_AC));
+ html->AddString("usbPower", base::IntToString(
+ power_manager::PowerSupplyProperties_ExternalPower_USB));
+ html->AddString("disconnected", base::IntToString(
+ power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED));
+ html->SetJsonPath("strings.js");
+
+ // Add resources.
+ html->AddResourcePath("device_emulator.css", IDR_DEVICE_EMULATOR_CSS);
+ html->AddResourcePath("device_emulator.js", IDR_DEVICE_EMULATOR_JS);
+ html->SetDefaultResource(IDR_DEVICE_EMULATOR_HTML);
+
+ return html;
+}
+
+} // namespace
+
+DeviceEmulatorUI::DeviceEmulatorUI(content::WebUI* web_ui)
+ : WebUIController(web_ui) {
+ web_ui->AddMessageHandler(new DeviceEmulatorMessageHandler());
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource::Add(profile, CreateDeviceEmulatorUIDataSource());
+}
+
+DeviceEmulatorUI::~DeviceEmulatorUI() {
+}
« 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