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

Unified Diff: chrome/browser/resources/chromeos/emulator/battery_settings.js

Issue 1256303002: Creating Ui for Battery State Option in Chrome Os Emulator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added radio group for battery state with functionality 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/emulator/battery_settings.js
diff --git a/chrome/browser/resources/chromeos/emulator/battery_settings.js b/chrome/browser/resources/chromeos/emulator/battery_settings.js
index b70921f072a6c4988512a916f4e5770edd4af27f..fe7b60cdc2f84596830dbe8ac2d447e3b5cc2bec 100644
--- a/chrome/browser/resources/chromeos/emulator/battery_settings.js
+++ b/chrome/browser/resources/chromeos/emulator/battery_settings.js
@@ -15,6 +15,26 @@ var BatterySettings = Polymer({
/**
* A string representing the value of an
michaelpg 2015/07/27 20:46:22 nit: "of a"
mozartalouis 2015/07/27 23:58:41 Done.
+ * PowerSupplyProperties_BatteryState enumeration.
+ */
+ batteryState: {
+ type: String,
+ },
+
+ /**
+ * An array representing the battery state options.
michaelpg 2015/07/27 20:46:22 fix indent (-1)
mozartalouis 2015/07/27 23:58:41 Done.
+ * The names are ordered based on the
+ * PowerSupplyProperties_BatteryState enumeration. These values must be
+ * in sync.
+ */
+ batteryStateOptions: {
+ type: Array,
+ value: function() { return ['Full', 'Charging', 'Disharging',
+ 'Not Present']; }
+ },
+
+ /**
+ * A string representing the value of an
michaelpg 2015/07/27 20:46:22 nit: "of a"
mozartalouis 2015/07/27 23:58:41 Done.
* PowerSupplyProperties_ExternalPower enumeration.
*/
externalPower: {
@@ -60,6 +80,7 @@ var BatterySettings = Polymer({
observers: [
'batteryPercentChanged(batteryPercent)',
+ 'batteryStateChanged(batteryState)',
'externalPowerChanged(externalPower)',
'timeUntilEmptyChanged(timeUntilEmpty)',
'timeUntilFullChanged(timeUntilFull)',
@@ -69,6 +90,21 @@ var BatterySettings = Polymer({
chrome.send('updateBatteryPercent', [parseInt(percent)]);
},
+ batteryStateChanged: function(state) {
+ var index = -1;
+
+ // Find the index of the selected battery state.
+ for (var i = 0; i < this.batteryStateOptions.length; i++) {
michaelpg 2015/07/27 20:46:22 var index = this.batteryStateOptions.indexOf(state
mozartalouis 2015/07/27 23:58:41 Done.
michaelpg 2015/07/28 00:05:39 Take another look at how indexOf works -- you don'
+ if (this.batteryStateOptions[i] == state) {
+ index = i;
+ break;
+ }
+ }
+
+ if (index >= 0)
+ chrome.send('updateBatteryState', [index]);
michaelpg 2015/07/27 20:46:22 indent
mozartalouis 2015/07/27 23:58:41 Done.
+ },
+
externalPowerChanged: function(source) {
var index = -1;
@@ -92,9 +128,10 @@ var BatterySettings = Polymer({
chrome.send('updateTimeToFull', [parseInt(time)]);
},
- updatePowerProperties: function(percent, external_power, empty, full) {
+ updatePowerProperties: function(percent, state, source, empty, full) {
this.batteryPercent = percent;
- this.externalPower = this.externalPowerOptions[external_power];
+ this.batteryState = this.batteryStateOptions[state];
+ this.externalPower = this.externalPowerOptions[source];
this.timeUntilEmpty = empty;
this.timeUntilFull = full;
}

Powered by Google App Engine
This is Rietveld 408576698