cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / emulator / battery_settings.js
blob9696161813cb61ca96e5fd6cb75ebe2d7a83ab3f
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.
5 var BatterySettings = Polymer({
6 is: 'battery-settings',
8 properties: {
9 /**
10 * The system's battery percentage.
12 batteryPercent: {
13 type: Number,
14 observer: 'batteryPercentChanged',
17 /**
18 * A string representing a value in the
19 * PowerSupplyProperties_BatteryState enumeration.
21 batteryState: {
22 type: String,
23 observer: 'batteryStateChanged',
26 /**
27 * An array representing the battery state options.
28 * The names are ordered based on the
29 * PowerSupplyProperties_BatteryState enumeration. These values must be
30 * in sync.
32 batteryStateOptions: {
33 type: Array,
34 value: function() { return ['Full', 'Charging', 'Disharging',
35 'Not Present']; },
38 /**
39 * A string representing a value in the
40 * PowerSupplyProperties_ExternalPower enumeration.
42 externalPower: {
43 type: String,
44 observer: 'externalPowerChanged',
47 /**
48 * An array representing the external power options.
49 * The names are ordered based on the
50 * PowerSupplyProperties_ExternalPower enumeration. These values must be
51 * in sync.
53 externalPowerOptions: {
54 type: Array,
55 value: function() { return ['AC', 'USB (Low Power)', 'Disconnected']; }
58 /**
59 * A string representing the time left until the battery is discharged.
61 timeUntilEmpty: {
62 type: String,
63 observer: 'timeUntilEmptyChanged',
66 /**
67 * A string representing the time left until the battery is at 100%.
69 timeUntilFull: {
70 type: String,
71 observer: 'timeUntilFullChanged',
74 /**
75 * The title for the settings section.
77 title: {
78 type: String,
82 ready: function() {
83 this.title = 'Power';
86 initialize: function() {
87 if (!this.initialized) {
88 chrome.send('requestPowerInfo');
89 this.initialized = true;
93 batteryPercentChanged: function(percent, oldPercent) {
94 if (oldPercent != undefined)
95 chrome.send('updateBatteryPercent', [parseInt(percent)]);
98 batteryStateChanged: function(state) {
99 // Find the index of the selected battery state.
100 var index = this.batteryStateOptions.indexOf(state);
101 if (index >= 0)
102 chrome.send('updateBatteryState', [index]);
105 externalPowerChanged: function(source) {
106 // Find the index of the selected power source.
107 var index = this.externalPowerOptions.indexOf(source);
108 if (index >= 0)
109 chrome.send('updateExternalPower', [index]);
112 timeUntilEmptyChanged: function(time, oldTime) {
113 if (oldTime != undefined)
114 chrome.send('updateTimeToEmpty', [parseInt(time)]);
117 timeUntilFullChanged: function(time, oldTime) {
118 if (oldTime != undefined)
119 chrome.send('updateTimeToFull', [parseInt(time)]);
122 updatePowerProperties: function(power_properties) {
123 this.batteryPercent = power_properties.battery_percent;
124 this.batteryState =
125 this.batteryStateOptions[power_properties.battery_state];
126 this.externalPower =
127 this.externalPowerOptions[power_properties.external_power];
128 this.timeUntilEmpty = power_properties.battery_time_to_empty_sec;
129 this.timeUntilFull = power_properties.battery_time_to_full_sec;