OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var BatterySettings = Polymer({ | 5 var BatterySettings = Polymer({ |
6 is: 'battery-settings', | 6 is: 'battery-settings', |
7 | 7 |
8 behaviors: [Polymer.NeonAnimatableBehavior], | 8 behaviors: [Polymer.NeonAnimatableBehavior], |
9 | 9 |
10 properties: { | 10 properties: { |
(...skipping 10 matching lines...) Expand all Loading... |
21 }, | 21 }, |
22 | 22 |
23 /** | 23 /** |
24 * An array representing the battery state options. | 24 * An array representing the battery state options. |
25 * The names are ordered based on the | 25 * The names are ordered based on the |
26 * PowerSupplyProperties_BatteryState enumeration. These values must be | 26 * PowerSupplyProperties_BatteryState enumeration. These values must be |
27 * in sync. | 27 * in sync. |
28 */ | 28 */ |
29 batteryStateOptions: { | 29 batteryStateOptions: { |
30 type: Array, | 30 type: Array, |
31 value: function() { return ['Full', 'Charging', 'Discharging', | 31 value: function() { |
32 'Not Present']; }, | 32 return ['Full', 'Charging', 'Discharging', 'Not Present']; |
| 33 }, |
33 }, | 34 }, |
34 | 35 |
35 /** | 36 /** |
36 * Example charging devices that can be connected. Chargers are split | 37 * Example charging devices that can be connected. Chargers are split |
37 * between dedicated chargers (which will always provide power if no | 38 * between dedicated chargers (which will always provide power if no |
38 * higher-power dedicated charger is connected) and dual-role USB chargers | 39 * higher-power dedicated charger is connected) and dual-role USB chargers |
39 * (which only provide power if configured as a source and no dedicated | 40 * (which only provide power if configured as a source and no dedicated |
40 * charger is connected). | 41 * charger is connected). |
41 */ | 42 */ |
42 powerSourceOptions: { | 43 powerSourceOptions: { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 if (!isNaN(this.timeUntilEmpty)) | 113 if (!isNaN(this.timeUntilEmpty)) |
113 chrome.send('updateTimeToEmpty', [this.timeUntilEmpty]); | 114 chrome.send('updateTimeToEmpty', [this.timeUntilEmpty]); |
114 }, | 115 }, |
115 | 116 |
116 onTimeUntilFullChange: function(e) { | 117 onTimeUntilFullChange: function(e) { |
117 this.timeUntilFull = parseInt(e.target.value); | 118 this.timeUntilFull = parseInt(e.target.value); |
118 if (!isNaN(this.timeUntilFull)) | 119 if (!isNaN(this.timeUntilFull)) |
119 chrome.send('updateTimeToFull', [this.timeUntilFull]); | 120 chrome.send('updateTimeToFull', [this.timeUntilFull]); |
120 }, | 121 }, |
121 | 122 |
| 123 onPowerChanged: function(e) { |
| 124 e.model.set('item.power', e.target.value); |
| 125 }, |
| 126 |
122 updatePowerProperties: function(power_properties) { | 127 updatePowerProperties: function(power_properties) { |
123 this.batteryPercent = power_properties.battery_percent; | 128 this.batteryPercent = power_properties.battery_percent; |
124 this.batteryState = | 129 this.batteryState = |
125 this.batteryStateOptions[power_properties.battery_state]; | 130 this.batteryStateOptions[power_properties.battery_state]; |
126 this.timeUntilEmpty = power_properties.battery_time_to_empty_sec; | 131 this.timeUntilEmpty = power_properties.battery_time_to_empty_sec; |
127 this.timeUntilFull = power_properties.battery_time_to_full_sec; | 132 this.timeUntilFull = power_properties.battery_time_to_full_sec; |
128 this.selectedPowerSourceId = power_properties.external_power_source_id; | 133 this.selectedPowerSourceId = power_properties.external_power_source_id; |
129 }, | 134 }, |
130 | 135 |
131 isBatteryPresent: function() { | 136 isBatteryPresent: function() { |
(...skipping 13 matching lines...) Expand all Loading... |
145 }, | 150 }, |
146 | 151 |
147 canBecomeSource: function(source, selectedId, powerSourceOptionsChange) { | 152 canBecomeSource: function(source, selectedId, powerSourceOptionsChange) { |
148 if (!source.connected || !this.isDualRole(source)) | 153 if (!source.connected || !this.isDualRole(source)) |
149 return false; | 154 return false; |
150 return !this.powerSourceOptions.some(function(source) { | 155 return !this.powerSourceOptions.some(function(source) { |
151 return source.connected && source.type == 'DedicatedCharger'; | 156 return source.connected && source.type == 'DedicatedCharger'; |
152 }); | 157 }); |
153 }, | 158 }, |
154 }); | 159 }); |
OLD | NEW |